/**
 * Page Outils UNSA : élargit les conteneurs de thème (Divi, etc.) autour du shortcode.
 * Chargé avec ?ver=filemtime pour éviter le cache navigateur / CDN obsolète.
 *
 * Bloc :has() : réservé aux moteurs qui le supportent (Safari iOS 15.4+).
 * Sans :has(), s’appuyer sur body.unsa-outils-frontend (body_class) + règles ci-dessous.
 */
@supports selector(:has(*)) {
body:has(.unsa-outils-shortcode-inner) .entry-content,
body:has(#unsa_outils_page_layout) .entry-content,
body:has(.unsa-outils-shortcode-inner) .site-main .entry-content,
body:has(#unsa_outils_page_layout) .site-main .entry-content {
    max-width: none !important;
    width: 100% !important;
}
body:has(.unsa-outils-shortcode-inner) .site-main,
body:has(#unsa_outils_page_layout) .site-main,
body:has(.unsa-outils-shortcode-inner) .content-area,
body:has(#unsa_outils_page_layout) .content-area {
    max-width: none !important;
}
body:has(.unsa-outils-shortcode-inner) .et_pb_row:has(.unsa-outils-shortcode-inner),
body:has(.unsa-outils-shortcode-inner) .et_pb_row:has(#unsa_outils_page_layout),
body:has(#unsa_outils_page_layout) .et_pb_row:has(#unsa_outils_page_layout),
body:has(.unsa-outils-shortcode-inner) .et_pb_section:has(.unsa-outils-shortcode-inner),
body:has(.unsa-outils-shortcode-inner) .et_pb_section:has(#unsa_outils_page_layout),
body:has(#unsa_outils_page_layout) .et_pb_section:has(#unsa_outils_page_layout) {
    max-width: none !important;
    width: 100% !important;
}
body:has(.unsa-outils-shortcode-inner) .et_pb_column:has(.unsa-outils-shortcode-inner),
body:has(.unsa-outils-shortcode-inner) .et_pb_column:has(#unsa_outils_page_layout),
body:has(#unsa_outils_page_layout) .et_pb_column:has(#unsa_outils_page_layout) {
    width: 100% !important;
    max-width: none !important;
}
body:has(.unsa-outils-shortcode-inner) .et_pb_row_inner:has(.unsa-outils-shortcode-inner),
body:has(.unsa-outils-shortcode-inner) .et_pb_row_inner:has(#unsa_outils_page_layout),
body:has(#unsa_outils_page_layout) .et_pb_row_inner:has(#unsa_outils_page_layout),
body:has(.unsa-outils-shortcode-inner) .et_pb_module:has(.unsa-outils-shortcode-inner),
body:has(.unsa-outils-shortcode-inner) .et_pb_module:has(#unsa_outils_page_layout),
body:has(#unsa_outils_page_layout) .et_pb_module:has(#unsa_outils_page_layout),
body:has(.unsa-outils-shortcode-inner) .et_builder_inner_content:has(.unsa-outils-shortcode-inner),
body:has(.unsa-outils-shortcode-inner) .et_builder_inner_content:has(#unsa_outils_page_layout),
body:has(#unsa_outils_page_layout) .et_builder_inner_content:has(#unsa_outils_page_layout) {
    max-width: none !important;
    width: 100% !important;
}
body:has(.unsa-outils-shortcode-inner) #et-main-area .et_pb_row:has(.unsa-outils-shortcode-inner),
body:has(#unsa_outils_page_layout) #et-main-area .et_pb_row:has(#unsa_outils_page_layout) {
    max-width: none !important;
    width: 100% !important;
}
body:has(.unsa-outils-shortcode-inner) .e-con:has(.unsa-outils-shortcode-inner),
body:has(.unsa-outils-shortcode-inner) .e-con:has(#unsa_outils_page_layout),
body:has(#unsa_outils_page_layout) .e-con:has(#unsa_outils_page_layout) {
    --container-max-width: 100% !important;
    max-width: none !important;
}
body:has(.unsa-outils-shortcode-inner) .elementor-section .elementor-container:has(.unsa-outils-shortcode-inner),
body:has(.unsa-outils-shortcode-inner) .elementor-section .elementor-container:has(#unsa_outils_page_layout),
body:has(#unsa_outils_page_layout) .elementor-section .elementor-container:has(#unsa_outils_page_layout) {
    max-width: none !important;
}
}

/* Sans :has() : largeur racine Outils (complète body.unsa-outils-frontend plus bas). */
@supports not (selector(:has(*))) {
    body.unsa-outils-frontend .unsa-outils-shortcode-inner,
    body.unsa-outils-frontend #unsa_outils_page_layout {
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box;
    }
}

/**
 * Divi sans Visual Builder : pas de .et_pb_* — la largeur est surtout limitée par .container dans #main-content / #et-main-area.
 * body.unsa-outils-frontend est ajouté via body_class (pas besoin de :has() sur body).
 */
body.unsa-outils-frontend #et-main-area,
body.unsa-outils-frontend #main-content {
    max-width: none !important;
    width: 100% !important;
    box-sizing: border-box;
}
body.unsa-outils-frontend #et-main-area .container,
body.unsa-outils-frontend #main-content .container {
    max-width: none !important;
    width: 100% !important;
    box-sizing: border-box;
}
body.unsa-outils-frontend #content-area,
body.unsa-outils-frontend #left-area {
    max-width: none !important;
    width: 100% !important;
    box-sizing: border-box;
}
body.unsa-outils-frontend .entry-content,
body.unsa-outils-frontend .post-content {
    max-width: none !important;
    width: 100% !important;
    box-sizing: border-box;
}

/*
 * CDI / CDD — panneaux d’étapes et cartes étape 1 : règles ici (feuille head) pour éviter qu’un thème
 * ou un optimiseur neutralise le <style> inline du shortcode ; au-dessus des .unsa-cc-panel masqués globalement.
 */
body.unsa-outils-frontend #unsa_cdi_cdd_root.unsa-cdi-cdd .unsa-cc-panel:not(.unsa-cc-panel-active) {
    display: none !important;
}
body.unsa-outils-frontend #unsa_cdi_cdd_root.unsa-cdi-cdd .unsa-cc-panel.unsa-cc-panel-active {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}
body.unsa-outils-frontend #unsa_cdi_cdd_root.unsa-cdi-cdd #unsa_cc_panel_1.unsa-cc-panel-active .unsa-cc-section {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-height: none !important;
    overflow: visible !important;
}
body.unsa-outils-frontend #unsa_cdi_cdd_root.unsa-cdi-cdd #unsa_cc_panel_1.unsa-cc-panel-active .unsa-cc-nav-buttons {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    visibility: visible !important;
    opacity: 1 !important;
    max-height: none !important;
    overflow: visible !important;
}

/* Même logique sans body.unsa-outils-frontend (shortcode CDI seul sur une page sans [unsa_outils] ni ?outil=). */
#unsa_cdi_cdd_root.unsa-cdi-cdd .unsa-cc-panel:not(.unsa-cc-panel-active) {
    display: none !important;
}
#unsa_cdi_cdd_root.unsa-cdi-cdd .unsa-cc-panel.unsa-cc-panel-active {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}
#unsa_cdi_cdd_root.unsa-cdi-cdd #unsa_cc_panel_1.unsa-cc-panel-active .unsa-cc-section {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-height: none !important;
    overflow: visible !important;
}
#unsa_cdi_cdd_root.unsa-cdi-cdd #unsa_cc_panel_1.unsa-cc-panel-active .unsa-cc-nav-buttons {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    visibility: visible !important;
    opacity: 1 !important;
    max-height: none !important;
    overflow: visible !important;
}

/*
 * CDI / CDD — flux dans la colonne principale (évite l’aspect « pop-up » centré : Divi / flex parents
 * align-items:center, position fixed sur .et_pb_* ou largeur réduite des cartes).
 */
@supports selector(:has(*)) {
    body.unsa-outils-frontend #unsa_outils_main:has(.unsa-outil-fullscreen-wrap--impots) {
        display: block !important;
    }
    body.unsa-outils-frontend #unsa_outils_main:has(.unsa-outil-fullscreen-wrap--cdi-cdd) {
        display: block !important;
    }
}

/* Même effet sans :has() : la colonne principale reste en flux bloc (outils plein écran). */
@supports not (selector(:has(*))) {
    body.unsa-outils-frontend #unsa_outils_main {
        display: block !important;
    }
}

body.unsa-outils-frontend #unsa_outils_main .unsa-outil-fullscreen-wrap--impots,
body.unsa-outils-frontend #unsa_outils_main .unsa-outil-fullscreen-wrap--impots #unsa_declaration_impots.unsa-outil-impots {
    align-self: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box;
}

body.unsa-outils-frontend #unsa_outils_main .unsa-outil-fullscreen-wrap--cdi-cdd,
body.unsa-outils-frontend #unsa_outils_main .unsa-outil-fullscreen-wrap--cdi-cdd #unsa_cdi_cdd_root.unsa-cdi-cdd {
    align-self: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box;
    background: transparent !important;
}
#unsa_cdi_cdd_root.unsa-cdi-cdd .unsa-cc-panel {
    position: static !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    transform: none !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
}
#unsa_cdi_cdd_root.unsa-cdi-cdd .unsa-cc-section {
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    background: #fff !important;
    color: #1f2937 !important;
    border: 1px solid #e5e7eb !important;
    box-shadow: none !important;
}
#unsa_cdi_cdd_root.unsa-cdi-cdd .unsa-cc-section.unsa-cc-import {
    background: #fdf2f8 !important;
    border: 2px solid #fbcfe8 !important;
    color: #1f2937 !important;
}
#unsa_cdi_cdd_root.unsa-cdi-cdd .unsa-cc-section.unsa-cc-saved {
    background: #f0fdf4 !important;
    border: 2px solid #bbf7d0 !important;
    color: #1f2937 !important;
}
#unsa_cdi_cdd_root.unsa-cdi-cdd .unsa-cc-section.unsa-cc-results,
#unsa_cdi_cdd_root.unsa-cdi-cdd .unsa-cc-section.unsa-cc-recap-annuel {
    background: #f9fafb !important;
    color: #1f2937 !important;
    border: 1px solid #e5e7eb !important;
}
#unsa_cdi_cdd_root.unsa-cdi-cdd .unsa-cc-nav-buttons {
    background: #fafafa !important;
    color: #1f2937 !important;
    border-top: 1px solid #e5e7eb !important;
    box-shadow: none !important;
}
#unsa_cdi_cdd_root.unsa-cdi-cdd label {
    color: #1f2937 !important;
}
#unsa_cdi_cdd_root.unsa-cdi-cdd .unsa-cc-section-title {
    color: #c43d7a !important;
}
#unsa_cdi_cdd_root.unsa-cdi-cdd .unsa-cc-results {
    background: #f9fafb !important;
    border: 1px solid #e5e7eb !important;
    color: #1f2937 !important;
    box-shadow: none !important;
}
#unsa_cdi_cdd_root.unsa-cdi-cdd .unsa-cc-results p > span:first-child,
#unsa_cdi_cdd_root.unsa-cdi-cdd .unsa-cc-bulletin-results p > span:first-child {
    color: #374151 !important;
    font-weight: 600;
}
#unsa_cdi_cdd_root.unsa-cdi-cdd .unsa-cc-results .unsa-cc-val,
#unsa_cdi_cdd_root.unsa-cdi-cdd .unsa-cc-bulletin-results .unsa-cc-val {
    color: #9d174d !important;
}
#unsa_cdi_cdd_root #unsa_cc_main_desc {
    color: #374151 !important;
    font-size: 1rem !important;
    line-height: 1.55 !important;
}

/* CDI/CDD — panneau étape 1 & conteneur import : fond neutre (cadre sombre / fond Divi sur divs imbriqués). */
body.unsa-outils-frontend #unsa_cdi_cdd_root.unsa-cdi-cdd,
#unsa_cdi_cdd_root.unsa-cdi-cdd {
    background: transparent !important;
}
body.unsa-outils-frontend #unsa_cdi_cdd_root.unsa-cdi-cdd #unsa_cc_import_block.unsa-cc-import-block,
#unsa_cdi_cdd_root.unsa-cdi-cdd #unsa_cc_import_block.unsa-cc-import-block {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

/* Titre de page WordPress / Divi (éditeur classique) : redondant avec le hub / la sidebar Outils */
body.unsa-outils-frontend #main-content h1.entry-title,
body.unsa-outils-frontend #left-area h1.entry-title,
body.unsa-outils-frontend article.post h1.entry-title,
body.unsa-outils-frontend article.page h1.entry-title,
body.unsa-outils-frontend .et_pb_title_container h1.entry-title,
body.unsa-outils-frontend .et_pb_title_container h1,
body.unsa-outils-frontend .et_post_title .entry-title {
    display: none !important;
}

/* Fil d’Ariane / barre titre type « Accueil » (Divi, Yoast, etc.) */
body.unsa-outils-frontend #main-content .et_pb_breadcrumbs,
body.unsa-outils-frontend #main-content .et_pb_breadcrumb,
body.unsa-outils-frontend .et_pb_breadcrumbs,
body.unsa-outils-frontend .et_pb_breadcrumb,
body.unsa-outils-frontend .yoast-breadcrumbs,
body.unsa-outils-frontend .yoast-breadcrumb,
body.unsa-outils-frontend nav.breadcrumb-trail,
body.unsa-outils-frontend .breadcrumbs {
    display: none !important;
}

/*
 * Centrer la colonne de contenu Outils dans la fenêtre :
 * sidebar fixe 240px → marge gauche = 240px + moitié de l’espace libre restant.
 */
body.unsa-outils-frontend .unsa-outils-sidebar:not(.unsa-outils-sidebar-closed) + .unsa-outils-main {
    max-width: min(1720px, calc(100vw - 240px)) !important;
    width: min(1720px, calc(100vw - 240px)) !important;
    margin-left: calc(240px + max(0px, (100vw - 240px - min(1720px, 100vw - 240px)) / 2)) !important;
    margin-right: auto !important;
    box-sizing: border-box !important;
}

body.unsa-outils-frontend .unsa-outils-sidebar.unsa-outils-sidebar-closed + .unsa-outils-main {
    max-width: min(1720px, 100vw) !important;
    width: min(1720px, 100vw) !important;
    margin-left: calc(max(0px, (100vw - min(1720px, 100vw)) / 2)) !important;
    margin-right: auto !important;
    box-sizing: border-box !important;
}

/* Menu latéral compact (200px) : recentrer la colonne principale comme pour 240px */
body.unsa-outils-frontend #unsa_outils_page_layout.unsa-outils-sidebar-compact-on .unsa-outils-sidebar:not(.unsa-outils-sidebar-closed) + .unsa-outils-main {
    max-width: min(1720px, calc(100vw - 200px)) !important;
    width: min(1720px, calc(100vw - 200px)) !important;
    margin-left: calc(200px + max(0px, (100vw - 200px - min(1720px, 100vw - 200px)) / 2)) !important;
    margin-right: auto !important;
    box-sizing: border-box !important;
}

/* Le hub remplit la colonne déjà centrée (évite double max-width). */
body.unsa-outils-frontend #unsa_outils_page_layout .unsa-outils-shortcode-inner {
    max-width: none !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Hub seul (sans layout plein écran) : bloc centré dans le thème */
@media (min-width: 1500px) {
    body.unsa-outils-frontend .unsa-outils-shortcode-inner {
        max-width: min(1720px, 100%);
        margin-left: auto;
        margin-right: auto;
        box-sizing: border-box;
    }
}

/**
 * Ctrl+P / Imprimer depuis le navigateur : ne pas envoyer sidebar Outils ni barres du thème (Divi, etc.).
 * Les boutons « Imprimer » des outils utilisent surtout unsa-outil-print.js (fenêtre ou iframe) ; ce bloc
 * améliore le cas où l’utilisateur imprime la page entière.
 */
@media print {
    body.unsa-outils-frontend #unsa_outils_sidebar,
    body.unsa-outils-frontend .unsa-outils-sidebar,
    body.unsa-outils-frontend #unsa_outils_sidebar_open,
    body.unsa-outils-frontend .unsa-outils-sidebar-btn-open,
    body.unsa-outils-frontend #unsa_outils_catalogue_wrap .unsa-wcag-toggle-catalogue,
    body.unsa-outils-frontend #main-header,
    body.unsa-outils-frontend #top-header,
    body.unsa-outils-frontend header#main-header,
    body.unsa-outils-frontend .et-l--header,
    body.unsa-outils-frontend #et-top-navigation,
    body.unsa-outils-frontend .et_mobile_menu_bar,
    body.unsa-outils-frontend .mobile_menu_bar,
    body.unsa-outils-frontend #et_mobile_nav_menu,
    body.unsa-outils-frontend #main-footer,
    body.unsa-outils-frontend footer#main-footer {
        display: none !important;
        visibility: hidden !important;
    }
    body.unsa-outils-frontend .unsa-outils-main,
    body.unsa-outils-frontend #unsa_outils_page_layout,
    body.unsa-outils-frontend .unsa-outil-fullscreen-wrap,
    body.unsa-outils-frontend #main-content,
    body.unsa-outils-frontend #et-main-area {
        margin: 0 !important;
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: none !important;
    }
}
