/* =========================================================================
   Plateforme nationale MRV — République Islamique de Mauritanie
   Ministère de l'Environnement et du Développement Durable
   Charte : vert national, or du croissant, rouge du drapeau (accents)
   ========================================================================= */

/* ===== VARIABLES ===== */
:root {
    --vert-fonce: #0B3D2A;      /* vert institutionnel profond */
    --vert: #0A6B3D;            /* vert du drapeau (lisible) */
    --vert-clair: #12894F;
    --vert-pale: #EEF5F0;
    --or: #C99A1E;              /* or du croissant (lisible sur blanc) */
    --or-vif: #F2C230;          /* or sur fond sombre */
    --rouge: #B3121B;           /* rouge des bandes du drapeau */
    --line: #E3E9E5;

    --primary-color: var(--vert-fonce);
    --secondary-color: var(--or-vif);
    --jaune: var(--or-vif);
    --text-color: #1F2A24;
    --bg-light: #ffffff;
    --bg-dropdown: #F3F7F4;
    --gris-clair: #F4F6F4;
    --max-width: 1280px;
    --gutter: clamp(16px, 4vw, 40px);
    --transition: 0.25s ease;
    --font: 'Poppins', 'Segoe UI', Arial, sans-serif;
    --header-h: 88px;
}

/* ===== RESET ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: var(--font);
    background: var(--gris-clair);
    color: var(--text-color);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { text-decoration: none; color: inherit; }
:focus-visible { outline: 3px solid var(--or); outline-offset: 2px; }

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

/* ===== BANDE AUX COULEURS NATIONALES ===== */
.flag-stripe {
    height: 5px;
    background: linear-gradient(to bottom, var(--rouge) 0 30%, var(--vert) 30% 70%, var(--rouge) 70% 100%);
}

/* ===== BANDEAU GOUVERNEMENTAL ===== */
.gov-bar {
    background: var(--vert-fonce);
    color: #DCE8E0;
    font-size: 0.75rem;
}
.gov-bar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 38px;
}
.gov-bar .gov-id { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.gov-bar .gov-id strong { color: #fff; font-weight: 600; letter-spacing: 0.3px; }
.gov-bar .gov-motto { color: var(--or-vif); font-style: italic; }
.gov-bar .gov-sep { opacity: 0.35; }
.gov-bar .gov-tools { display: flex; align-items: center; gap: 1rem; }
.gov-bar .gov-tools a { color: #DCE8E0; transition: var(--transition); }
.gov-bar .gov-tools a:hover { color: #fff; }

/* ===== LANGUE ===== */
.lang-switch {
    display: flex;
    gap: 2px;
    background: rgba(255, 255, 255, 0.08);
    padding: 2px;
    border-radius: 4px;
}
.lang-btn {
    padding: 2px 10px;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 3px;
    color: #DCE8E0 !important;
    transition: var(--transition);
}
.lang-btn.active { background: var(--or-vif); color: var(--vert-fonce) !important; }
.lang-btn:hover:not(.active) { background: rgba(255, 255, 255, 0.12); }

/* ===== EN-TÊTE (identité du ministère) ===== */
.site-head {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #fff;
    box-shadow: 0 2px 12px rgba(11, 61, 42, 0.08);
}
.brand-row .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-h);
    gap: 1rem;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}
.nav-brand .flag-svg {
    width: 58px;
    height: auto;
    flex-shrink: 0;
    border-radius: 2px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}
.brand-divider {
    width: 1px;
    align-self: stretch;
    margin: 18px 0;
    background: var(--line);
}
.brand-info { line-height: 1.25; min-width: 0; }
.brand-ministry {
    display: block;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--vert);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.brand-text {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--vert-fonce);
    letter-spacing: -0.2px;
}
.brand-text span { color: var(--or); }
.brand-sub {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: #6A7870;
    letter-spacing: 0.3px;
}
.head-actions { display: flex; align-items: center; gap: 0.6rem; }
.btn-head {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.5rem 0.95rem;
    border-radius: 4px;
    border: 1px solid var(--vert);
    color: var(--vert);
    transition: var(--transition);
    white-space: nowrap;
}
.btn-head:hover { background: var(--vert); color: #fff; }
.btn-head.solid { background: var(--vert); color: #fff; }
.btn-head.solid:hover { background: var(--vert-fonce); border-color: var(--vert-fonce); }

/* ===== BARRE DE NAVIGATION ===== */
.navbar {
    background: var(--vert);
    border-bottom: 3px solid var(--or-vif);
}
.navbar .container { display: flex; align-items: center; }
.nav-right { width: 100%; }
.nav-menu {
    display: flex;
    list-style: none;
    flex-wrap: wrap;
}
.nav-menu > li { position: relative; }
.nav-menu > li > a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 18px;
    height: 50px;
    color: #fff;
    font-weight: 600;
    font-size: 0.86rem;
    transition: var(--transition);
}
.nav-menu > li:first-child > a { padding-inline-start: 0; }
.nav-menu > li > a:hover,
.nav-menu > li:hover > a { background: rgba(0, 0, 0, 0.15); }
.nav-menu > li:first-child > a:hover { background: transparent; color: var(--or-vif); }
.nav-menu > li > a.current { box-shadow: inset 0 -3px 0 var(--or-vif); }
.nav-menu > li > a i.fa-chevron-down { font-size: 0.55rem; opacity: 0.75; }
.nav-menu > li > a .fa-home { font-size: 0.95rem; }

/* ===== MENUS DÉROULANTS ===== */
.dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    box-shadow: 0 14px 40px rgba(11, 61, 42, 0.14);
    list-style: none;
    min-width: 280px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: var(--transition);
    border-top: 3px solid var(--or-vif);
    padding: 0.4rem 0;
    z-index: 200;
}
.has-dropdown:hover > .dropdown,
.has-dropdown:focus-within > .dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.dropdown li { position: relative; }
.dropdown li a {
    display: block;
    padding: 9px 20px;
    color: var(--text-color);
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
}
.dropdown li a:hover {
    background: var(--vert-pale);
    color: var(--vert);
    border-left-color: var(--vert);
}
.dropdown li a i { font-size: 0.55rem; opacity: 0.5; float: right; margin-top: 6px; }

.submenu {
    position: absolute;
    top: 0;
    left: 100%;
    background: #fff;
    box-shadow: 0 14px 40px rgba(11, 61, 42, 0.14);
    list-style: none;
    min-width: 250px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(6px);
    transition: var(--transition);
    padding: 0.4rem 0;
    border-left: 3px solid var(--or-vif);
}
.has-submenu:hover > .submenu,
.has-submenu:focus-within > .submenu { opacity: 1; visibility: visible; transform: translateX(0); }

/* ===== HAMBURGER ===== */
.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: 1px solid var(--line);
    border-radius: 4px;
    cursor: pointer;
    padding: 9px 8px;
}
.menu-toggle .bar {
    width: 22px;
    height: 2px;
    background: var(--vert-fonce);
    border-radius: 2px;
    transition: var(--transition);
}

/* ===== RESPONSIVE EN-TÊTE ===== */
@media (max-width: 1100px) {
    .head-actions .btn-head:not(.solid) { display: none; }
}
@media (max-width: 1024px) {
    :root { --header-h: 74px; }
    .menu-toggle { display: flex; }
    .head-actions .btn-head { display: none; }
    .navbar { border-bottom: 0; height: 0; }
    .navbar .container { position: static; }
    .nav-right {
        position: absolute;   /* ancré sous l'en-tête collant (.site-head) */
        top: 100%;
        left: -100%;
        width: 100%;
        height: calc(100vh - var(--header-h));
        background: #fff;
        padding: 12px 20px 40px;
        overflow-y: auto;
        transition: left 0.3s ease;
        z-index: 999;
        border-top: 3px solid var(--or-vif);
    }
    .nav-right.active { left: 0; }
    .nav-menu { flex-direction: column; flex-wrap: nowrap; }
    .nav-menu > li > a,
    .nav-menu > li:first-child > a {
        color: var(--vert-fonce);
        height: auto;
        padding: 14px 0;
        justify-content: space-between;
        border-bottom: 1px solid var(--line);
    }
    .nav-menu > li > a:hover,
    .nav-menu > li:hover > a { background: transparent; color: var(--vert); }
    .nav-menu > li > a.current { box-shadow: none; color: var(--vert); }

    .dropdown, .submenu {
        position: static;
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        transform: none;
        max-height: 0;
        overflow: hidden;
        border: 0;
        background: var(--bg-dropdown);
        transition: max-height 0.3s ease-out;
        padding: 0;
        min-width: 0;
    }
    .has-dropdown.open > .dropdown,
    .has-submenu.open > .submenu { max-height: 1200px; padding: 0.3rem 0; }
    .dropdown li a { border-left: 0; }
    .dropdown li a:hover { border-left: 0; }
    .submenu li a { padding-left: 36px; }
    .dropdown li a i { display: none; }

    .menu-toggle.active .bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    .menu-toggle.active .bar:nth-child(2) { opacity: 0; }
    .menu-toggle.active .bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
}
@media (max-width: 640px) {
    .gov-bar .gov-motto, .gov-bar .gov-sep, .gov-bar .gov-mail { display: none; }
    .brand-divider, .brand-sub { display: none; }
    .nav-brand .flag-svg { width: 44px; }
    .brand-text { font-size: 1.1rem; }
    .brand-ministry { font-size: 0.58rem; letter-spacing: 0.3px; }
}

/* ===== PIED DE PAGE ===== */
.footer {
    background: var(--vert-fonce);
    color: #C9DACF;
    margin-top: auto;
    font-size: 0.84rem;
}
.footer .flag-stripe { height: 4px; }
.footer-top {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr 1fr;
    gap: 2.2rem;
    padding: 2.8rem 0 2.2rem;
}
.footer-ministry { display: flex; gap: 14px; align-items: flex-start; }
.footer-ministry .flag-svg { width: 54px; flex-shrink: 0; border-radius: 2px; }
.footer-ministry strong { display: block; color: #fff; font-size: 0.95rem; line-height: 1.4; }
.footer-ministry span { display: block; font-size: 0.78rem; opacity: 0.8; margin-top: 0.25rem; }
.footer-contact { margin-top: 1.2rem; display: grid; gap: 0.35rem; font-size: 0.8rem; }
.footer-contact i { color: var(--or-vif); width: 16px; margin-inline-end: 0.4rem; }

.footer-col h4 {
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--or-vif);
    display: inline-block;
}
.footer-col a {
    display: block;
    color: #C9DACF;
    line-height: 2;
    transition: var(--transition);
}
.footer-col a:hover { color: #fff; padding-inline-start: 4px; }

.footer-partners-row {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 1.4rem 0;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.footer-partners-row .label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--or-vif);
    font-weight: 700;
}
.footer-partner {
    font-size: 0.72rem;
    padding: 0.3rem 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 3px;
    color: #DCE8E0;
}
.footer-bottom {
    background: #072619;
    font-size: 0.75rem;
    color: #9DBBA9;
}
.footer-bottom .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding-top: 0.9rem;
    padding-bottom: 0.9rem;
}
.footer-social { display: flex; gap: 0.4rem; }
.footer-social a {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.07);
    color: #DCE8E0;
    font-size: 0.8rem;
    transition: var(--transition);
}
.footer-social a:hover { background: var(--or-vif); color: var(--vert-fonce); }

@media (max-width: 992px) { .footer-top { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .footer-top { grid-template-columns: 1fr; gap: 1.6rem; } }

/* ===== ARABE (RTL) ===== */
html[dir="rtl"] { --font: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif; }
html[dir="rtl"] body * { letter-spacing: 0 !important; text-transform: none !important; }
html[dir="rtl"] .dropdown { left: auto; right: 0; }
html[dir="rtl"] .dropdown li a { border-left: 0; border-right: 3px solid transparent; }
html[dir="rtl"] .dropdown li a:hover { border-right-color: var(--vert); }
html[dir="rtl"] .dropdown li a i { float: left; }
html[dir="rtl"] .submenu { left: auto; right: 100%; border-left: 0; border-right: 3px solid var(--or-vif); transform: translateX(-6px); }
html[dir="rtl"] .has-submenu:hover > .submenu { transform: translateX(0); }
html[dir="rtl"] .nav-right { left: auto; }
html[dir="rtl"] .fa-arrow-right,
html[dir="rtl"] .fa-chevron-right { transform: scaleX(-1); }
html[dir="rtl"] a:hover > .fa-arrow-right { transform: translateX(-4px) scaleX(-1); }
@media (max-width: 1024px) {
    html[dir="rtl"] .nav-right { right: -100%; left: auto; transition: right 0.3s ease; }
    html[dir="rtl"] .nav-right.active { right: 0; }
    html[dir="rtl"] .dropdown li a { border-right: 0; }
    html[dir="rtl"] .submenu li a { padding-left: 20px; padding-right: 36px; }
}

/* ===== EN-TÊTE DES PAGES INTÉRIEURES ===== */
.page-hero { border-bottom: 4px solid var(--or-vif); }
.breadcrumb { background: #fff !important; }

/* ===== GRAPHIQUES AUTOMATIQUES (graphs.js) ===== */
.graph-frame .graph-image.has-chart,
.graph-frame .graph-image:has(.chart-loading) {
    background: #fff;
    padding: 0.8rem;
    height: auto;
    min-height: 0;
}
.chart-loading {
    height: 300px;
    border-radius: 6px;
    background: linear-gradient(90deg, #F1F4F2 25%, #E6EFE9 37%, #F1F4F2 63%);
    background-size: 400% 100%;
    animation: chartShimmer 1.4s ease infinite;
}
@keyframes chartShimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.chart-holder { position: relative; width: 100%; height: 340px; }
.chart-holder.is-doughnut { height: 300px; }
@media (max-width: 640px) {
    .chart-holder { height: 270px; }
    .chart-holder.is-doughnut { height: 340px; }
    .chart-loading { height: 240px; }
}
.chart-holder.is-doughnut.legend-bottom { height: 400px; }

/* ===== MISE EN PAGE RESPONSIVE DES PAGES INTÉRIEURES ===== */
/* Le contenu ne doit jamais dépasser la largeur de l'écran : les tableaux
   défilent dans leur propre cadre (.table-wrapper / .data-table-wrap). */
body .page-content .container > .content-main { min-width: 0; max-width: 100%; }
body .table-wrapper, body .data-table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
body .content-main img, body .content-main canvas, body .content-main iframe { max-width: 100%; }
body .content-main { overflow-wrap: anywhere; }
body .content-main table { overflow-wrap: normal; }
@media (max-width: 992px) {
    body .page-content .container { flex-direction: column; align-items: stretch; gap: 0; }
    body .page-content .container > .content-main { width: 100%; }
}

/* ===== SOUS-MENUS ÉMISSIONS (niveau 3) ===== */
.submenu-overview { display: none; }          /* bureau : le titre est déjà cliquable */
.has-submenu:hover > a { background: var(--vert-pale); color: var(--vert); }
@media (max-width: 1024px) {
    .submenu-overview { display: block; }      /* mobile : toucher le titre ouvre le sous-menu */
    .submenu-overview a { font-weight: 600; }
    .has-submenu > a { display: flex !important; justify-content: space-between; align-items: center; }
    .dropdown .has-submenu > a i { display: inline-block !important; float: none; margin: 0; transform: rotate(90deg); transition: transform 0.25s ease; }
    .dropdown .has-submenu.open > a i { transform: rotate(-90deg); }
    html[dir="rtl"] .dropdown .has-submenu > a i { transform: rotate(90deg); }
}

/* ===== DISPOSITION COMMUNE : MENU LATÉRAL + CONTENU ===== */
/* Garantit la même mise en page sur toutes les pages intérieures, quelle que
   soit la feuille de style propre à la page. */
@media (min-width: 993px) {
    body .page-content .container { display: flex; flex-direction: row; align-items: flex-start; gap: 3rem; }
    body .page-content .container > .aside-nav { flex: 0 0 250px; position: sticky; top: calc(var(--header-h) + 66px); }
    body .page-content .container > .content-main { flex: 1 1 auto; }
}

/* ===== ACCÈS « ESPACE AGENTS » (back-office MRV) ===== */
.btn-head.agents { border-color: var(--or); color: var(--vert-fonce); background: #FBF5E3; }
.btn-head.agents i { color: var(--or); }
.btn-head.agents:hover { background: var(--or); border-color: var(--or); color: #fff; }
.btn-head.agents:hover i { color: #fff; }
.head-actions .btn-head.agents { display: inline-flex; }
@media (max-width: 1024px) { .head-actions .btn-head.agents { display: none; } }
.nav-menu .nav-agents { display: none; }
@media (max-width: 1024px) { .nav-menu .nav-agents { display: block; } }

/* ===== DONNÉES EN DIRECT DE LA PLATEFORME ===== */
.live-section { padding: 56px 0; background: var(--gris-clair); border-top: 1px solid var(--line); }
.live-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 22px; }
.live-head h2 { margin: 6px 0 0; font-size: clamp(1.3rem, 2.4vw, 1.7rem); color: var(--vert-fonce); }
.live-badge { display: inline-flex; align-items: center; gap: 8px; font-size: .75rem; font-weight: 600; color: var(--vert); background: var(--vert-pale); border: 1px solid #CFE3D6; padding: .3rem .7rem; border-radius: 999px; }
.live-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--vert-clair); box-shadow: 0 0 0 3px rgba(18,137,79,.18); }
.live-badge.off { color: #6A7870; background: #fff; border-color: var(--line); }
.live-badge.off .dot { background: #A8B3AD; box-shadow: none; }
.live-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .live-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .live-grid { grid-template-columns: 1fr; } }
.live-card { background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--vert); border-radius: 6px; padding: 18px; }
.live-card.or { border-top-color: var(--or); }
.live-card .lbl { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; color: #6A7870; }
.live-card .val { font-size: 1.9rem; font-weight: 800; color: var(--vert-fonce); margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.live-card .sub { font-size: .8rem; color: #6A7870; }
.live-note { font-size: .8rem; color: #6A7870; margin-top: 14px; }
.live-table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.live-table { width: 100%; border-collapse: collapse; font-size: .85rem; min-width: 560px; }
.live-table th { text-align: start; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: #6A7870; background: #F7F9F8; padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
.live-table td { padding: .75rem .9rem; border-bottom: 1px solid #EEF2EF; vertical-align: top; }
.live-table tr:last-child td { border-bottom: 0; }
.live-empty { background: #fff; border: 1px dashed #CBD6CF; border-radius: 6px; padding: 22px; text-align: center; color: #6A7870; font-size: .9rem; }
