/* ==========================================================================
   Ministère de l'Intégration — design system
   Construit sur les variables CSS de Bootstrap 5.3 (thème clair/sombre).
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800;900&display=swap');

:root {
    --bs-font-sans-serif: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    /* Charte graphique Vases d'Honneur : teal (texte), or (symbole), rouge (accent).
       Ces variables pilotent directement les utilitaires Bootstrap (bg-primary,
       text-primary, border-primary...). Les composants (.btn-primary, liens)
       sont repointés explicitement plus bas, Bootstrap les figeant sinon sur sa
       propre palette par défaut. */
    --bs-primary: #006c67;
    --bs-primary-rgb: 0, 108, 103;
    --bs-primary-text-emphasis: #004b47;
    --bs-success: #16a34a;
    --bs-success-rgb: 22, 163, 74;
    --bs-info: #0ea5e9;
    --bs-info-rgb: 14, 165, 233;
    --bs-warning: #d2af1f;
    --bs-warning-rgb: 210, 175, 31;
    --bs-danger: #b21e28;
    --bs-danger-rgb: 178, 30, 40;
    --bs-link-color: var(--bs-primary);
    --bs-link-color-rgb: var(--bs-primary-rgb);
    --bs-link-hover-color: var(--bs-primary-text-emphasis);
    --bs-link-hover-color-rgb: 0, 75, 71;
    --bs-focus-ring-color: rgba(var(--bs-primary-rgb), .25);
    --bs-body-bg: #f6f5f1;
    --bs-body-color: #211f1a;
    --bs-border-color: #e7e3d9;
    --bs-border-radius: .65rem;
    --bs-border-radius-lg: 1rem;
    --bs-border-radius-sm: .5rem;

    /* Jetons propres à l'application */
    --brand-gold: #d2af1f;
    --brand-red: #b21e28;
    --surface: #ffffff;
    --surface-alt: #f2efe6;
    --text-muted-soft: #6f6a5e;
    --sidebar-bg: #0a1f1c;
    --sidebar-bg-alt: #0f2e29;
    --sidebar-text: #a9c4c0;
    --sidebar-text-active: #ffffff;
    --sidebar-width: 264px;
    --topbar-height: 68px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-md: 0 4px 10px -2px rgba(16, 24, 40, .08), 0 2px 4px -2px rgba(16, 24, 40, .04);
    --shadow-lg: 0 12px 24px -8px rgba(16, 24, 40, .14);
    --transition-fast: .15s ease;
    --transition-base: .25s ease;
}

/* Mode sombre : appliqué dès que l'utilisateur choisit "sombre" (attribut posé par main.js) */
[data-theme="dark"] {
    --bs-body-bg: #0b1512;
    --bs-body-color: #e6e4db;
    --bs-border-color: #223330;
    --surface: #11201d;
    --surface-alt: #162925;
    --text-muted-soft: #93a19d;
    --sidebar-bg: #060f0d;
    --sidebar-bg-alt: #0a1815;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 4px 10px -2px rgba(0, 0, 0, .45), 0 2px 4px -2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 12px 24px -8px rgba(0, 0, 0, .55);
}

/* ---------- Base ---------- */
html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* Le CSS compilé de Bootstrap fige --bs-btn-bg etc. sur sa propre palette par
   défaut au lieu de suivre --bs-primary : on repointe explicitement ces
   variables de composant sur notre charte graphique. */
.btn-primary {
    --bs-btn-bg: var(--bs-primary);
    --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-bg: var(--bs-primary-text-emphasis);
    --bs-btn-hover-border-color: var(--bs-primary-text-emphasis);
    --bs-btn-active-bg: var(--bs-primary-text-emphasis);
    --bs-btn-active-border-color: var(--bs-primary-text-emphasis);
    --bs-btn-disabled-bg: var(--bs-primary);
    --bs-btn-disabled-border-color: var(--bs-primary);
    --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}

.btn-outline-primary {
    --bs-btn-color: var(--bs-primary);
    --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-bg: var(--bs-primary);
    --bs-btn-hover-border-color: var(--bs-primary);
    --bs-btn-active-bg: var(--bs-primary);
    --bs-btn-active-border-color: var(--bs-primary);
    --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}

.btn-warning {
    --bs-btn-color: #211f1a;
    --bs-btn-bg: var(--bs-warning);
    --bs-btn-border-color: var(--bs-warning);
    --bs-btn-hover-color: #211f1a;
}

.pagination {
    --bs-pagination-color: var(--bs-primary);
    --bs-pagination-hover-color: var(--bs-primary-text-emphasis);
    --bs-pagination-focus-color: var(--bs-primary-text-emphasis);
    --bs-pagination-active-bg: var(--bs-primary);
    --bs-pagination-active-border-color: var(--bs-primary);
}

/* Un élément .fade-in plus bas dans le flux (ex. une carte de filtre) garde un `transform` actif
   après son animation (animation-fill-mode: both), ce qui lui crée son propre contexte
   d'empilement et peut alors recouvrir un menu déroulant ouvert depuis un élément précédent,
   même si celui-ci a un z-index supérieur défini ailleurs dans sa propre pile. On force ici le
   conteneur du menu déroulant à former un contexte d'empilement explicite, garanti au-dessus. */
.dropdown {
    z-index: 5;
}

.dropdown-menu {
    --bs-dropdown-bg: var(--surface);
    --bs-dropdown-color: var(--bs-body-color);
    --bs-dropdown-border-color: var(--bs-border-color);
    --bs-dropdown-divider-bg: var(--bs-border-color);
    --bs-dropdown-link-color: var(--bs-body-color);
    --bs-dropdown-link-hover-color: var(--bs-body-color);
    --bs-dropdown-link-hover-bg: var(--surface-alt);
    --bs-dropdown-link-active-color: #ffffff;
    --bs-dropdown-link-active-bg: var(--bs-primary);
    box-shadow: var(--shadow-lg);
}

a {
    transition: color var(--transition-fast);
}

/* ---------- Layout : sidebar + topbar ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-alt) 100%);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    transition: transform var(--transition-base);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.4rem 1.25rem;
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand-icon {
    height: 40px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

/* Le logo VDH est teal/or sur fond transparent : sur les fonds toujours sombres
   (sidebar, panneau de connexion), on le passe en blanc pour rester lisible. */
.brand-icon--on-dark {
    filter: brightness(0) invert(1);
}

/* La navbar et le footer publics suivent le thème clair/sombre : on inverse
   le logo uniquement quand le thème sombre est actif. */
[data-theme="dark"] .public-navbar .brand-icon,
[data-theme="dark"] .public-footer .brand-icon {
    filter: brightness(0) invert(1);
}

.sidebar-brand .brand-text {
    line-height: 1.2;
}

.sidebar-brand .brand-text strong {
    display: block;
    font-size: .95rem;
    font-weight: 700;
    color: var(--brand-gold);
}

.sidebar-brand .brand-text small {
    color: var(--sidebar-text);
    font-size: .72rem;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1.1rem .85rem;
}

.sidebar-section {
    margin-top: .3rem;
}

.sidebar-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 700;
    color: rgba(174, 180, 214, .65);
    padding: .7rem .6rem .5rem;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.sidebar-section-toggle:hover {
    color: #fff;
}

.sidebar-section-caret {
    font-size: .85rem;
    transition: transform var(--transition-fast);
}

.sidebar-section-toggle.collapsed .sidebar-section-caret {
    transform: rotate(-90deg);
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: .9rem;
    padding: .65rem .75rem;
    border-radius: .6rem;
    margin-bottom: .15rem;
    border-left: 3px solid transparent;
    transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.sidebar-nav .nav-link i {
    font-size: 1.05rem;
    width: 1.3rem;
    text-align: center;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: rgba(210, 175, 31, .14);
    color: var(--sidebar-text-active);
    border-left-color: var(--brand-gold);
}

.sidebar-nav .nav-link.active i {
    color: var(--brand-gold);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-footer form button {
    color: #fca5a5;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--bs-border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.topbar-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    flex: 1;
}

.sidebar-toggle {
    display: none;
    border: none;
    background: transparent;
    font-size: 1.3rem;
    color: var(--bs-body-color);
}

.icon-btn {
    border: 1px solid var(--bs-border-color);
    background: var(--surface-alt);
    color: var(--bs-body-color);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.icon-btn:hover {
    transform: rotate(15deg);
}

.app-content {
    padding: 1.75rem;
    flex: 1;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6, 9, 24, .5);
    z-index: 1035;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .app-shell.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .app-shell.sidebar-open .sidebar-backdrop {
        display: block;
    }

    .app-main {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* ---------- Cartes ---------- */
.card {
    background-color: var(--surface);
    border: 1px solid var(--bs-border-color);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.card-header {
    background-color: var(--surface) !important;
    border-bottom-color: var(--bs-border-color) !important;
}

.card-footer {
    border-top-color: var(--bs-border-color) !important;
}

.card-stat {
    animation: fade-in-up .4s ease both;
}

.card-stat:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* Accueil : tuiles des modules */
.tuile-module {
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.tuile-module:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-label {
    font-size: .72rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted-soft);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
}

.icon-shape {
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    font-size: 1.75rem;
    flex-shrink: 0;
}

/* ---------- Boutons ---------- */
.btn {
    font-weight: 500;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

.btn:active {
    transform: translateY(1px);
}

/* ---------- Tableaux ---------- */
.table {
    color: var(--bs-body-color);
}

.table > :not(caption) > * > * {
    padding: 1rem;
    vertical-align: middle;
    border-bottom-color: var(--bs-border-color);
    background-color: transparent;
}

.table thead {
    background-color: var(--surface-alt) !important;
}

.table th {
    font-weight: 600;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted-soft);
    border-bottom: 2px solid var(--bs-border-color);
}

.table-hover tbody tr {
    transition: background-color var(--transition-fast);
}

.table-hover tbody tr:hover {
    background-color: var(--surface-alt) !important;
}

.row-link {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.row-link:hover {
    color: var(--bs-primary);
}

/* ---------- Alertes ---------- */
.alert {
    border: 1px solid transparent;
    box-shadow: var(--shadow-sm);
}

/* ---------- Barres de progression maison (mini graphique CSS) ---------- */
.bar-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .6rem 0;
}

.bar-row .bar-label {
    width: 200px;
    flex-shrink: 0;
    font-weight: 500;
    font-size: .88rem;
}

.bar-track {
    flex: 1;
    height: 10px;
    border-radius: 999px;
    background-color: var(--surface-alt);
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--bs-primary), #33a39d);
    animation: grow-bar .6s ease both;
}

.bar-value {
    width: 2.5rem;
    text-align: right;
    font-weight: 700;
    font-size: .88rem;
}

/* ---------- Écran d'authentification (split screen) ---------- */
.auth-shell {
    min-height: 100vh;
    display: flex;
}

.auth-branding {
    flex: 1.1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3rem;
    color: #fff;
    background:
        linear-gradient(180deg, rgba(10, 77, 73, .80) 0%, rgba(8, 21, 19, .90) 100%),
        url('../img/bg2.jpg') center / cover no-repeat;
    position: relative;
    overflow: hidden;
}

.auth-branding::before,
.auth-branding::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, .06);
}

.auth-branding::before {
    width: 340px;
    height: 340px;
    top: -120px;
    right: -80px;
    background: rgba(210, 175, 31, .16);
}

.auth-branding::after {
    width: 220px;
    height: 220px;
    bottom: -80px;
    left: -60px;
}

.auth-branding-content {
    position: relative;
    z-index: 1;
}

.auth-branding-content strong {
    color: var(--brand-gold);
}

.auth-branding-content h2::after {
    content: "";
    display: block;
    width: 56px;
    height: 3px;
    margin-top: 1rem;
    background: var(--brand-gold);
    border-radius: 2px;
}

.auth-form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background-color: var(--bs-body-bg);
}

.auth-card {
    width: 100%;
    max-width: 420px;
}

@media (max-width: 991.98px) {
    .auth-branding {
        display: none;
    }
}

/* ---------- Page vitrine (visiteurs non connectés) ---------- */
.public-container {
    width: 100%;
    max-width: 1140px;
    margin: 0 auto;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

.public-navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--bs-border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.public-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    text-decoration: none;
    color: var(--bs-body-color);
}

.public-brand .brand-icon {
    height: 44px;
}

.public-brand .brand-text {
    line-height: 1.2;
}

.public-brand .brand-text strong {
    display: block;
    font-size: .95rem;
}

.public-brand .brand-text small {
    color: var(--text-muted-soft);
    font-size: .72rem;
}

.hero-section {
    padding: 4.5rem 0 3.5rem;
    overflow: hidden;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 3rem;
    align-items: center;
}

.badge-pill {
    display: inline-flex;
    align-items: center;
    background: rgba(var(--bs-primary-rgb), .1);
    color: var(--bs-primary);
    font-weight: 600;
    font-size: .78rem;
    padding: .4rem .9rem;
    border-radius: 999px;
}

.hero-title {
    font-size: clamp(1.8rem, 3.2vw, 2.75rem);
    font-weight: 800;
    line-height: 1.15;
    margin: 1rem 0 1rem;
}

.hero-subtitle {
    font-size: 1.05rem;
    color: var(--text-muted-soft);
    max-width: 46ch;
}

.hero-art svg {
    width: 100%;
    height: auto;
}

.steps-section {
    padding: 1rem 0 3.5rem;
}

.steps-row {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.step-card {
    flex: 1;
    position: relative;
    background: var(--surface);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-lg);
    padding: 2rem 1.5rem;
    text-align: center;
}

.step-number {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bs-primary);
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    color: var(--bs-primary);
}

.step-icon svg {
    width: 100%;
    height: 100%;
}

.step-connector {
    flex: 0 0 auto;
    width: 3rem;
    height: 2px;
    background: repeating-linear-gradient(90deg, var(--bs-border-color) 0 6px, transparent 6px 12px);
    margin-top: 44px;
}

.section-pattern {
    position: relative;
    border-radius: var(--bs-border-radius-lg);
    background-image: radial-gradient(rgba(var(--bs-primary-rgb), .18) 1.5px, transparent 1.5px);
    background-size: 24px 24px;
}

.gallery-img {
    width: 100%;
    height: 320px;
    object-fit: cover;
    object-position: center 70%;
    transition: transform var(--transition-base);
}

.gallery-img:hover {
    transform: scale(1.02);
}

.feature-card {
    background: var(--surface);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.cta-banner {
    background: linear-gradient(120deg, #00847e, #0a2e2a);
    border-radius: var(--bs-border-radius-lg);
    padding: 3rem;
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-lg);
}

.public-footer {
    border-top: 1px solid var(--bs-border-color);
    padding: 2rem 0;
    margin-top: 2rem;
}

@media (max-width: 767.98px) {
    .steps-row {
        flex-direction: column;
        gap: 2rem;
    }
}

@media (max-width: 991.98px) {
    .hero-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .hero-subtitle {
        max-width: none;
    }

    .hero-copy .d-flex {
        justify-content: center;
    }

    .cta-banner {
        justify-content: center;
        text-align: center;
    }
}

/* ---------- Animations ---------- */
@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes grow-bar {
    from {
        width: 0;
    }
}

.fade-in {
    animation: fade-in-up .35s ease both;
}

/* ---------- Impression (synthèse mensuelle) ---------- */
@media print {

    .sidebar,
    .topbar,
    .no-print {
        display: none !important;
    }

    .app-main {
        margin-left: 0 !important;
    }

    .app-content {
        padding: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: none !important;
    }
}
