/* Mode sombre global du site public (bouton soleil/lune de la barre du haut, classe « dark » sur <html>).
   Même palette que les blocs « .dark » des pages, appliquée partout, avec le fond de page et les surfaces claires qui restaient blanches. */
html.dark {
    color-scheme: dark;
    --d-parchment: #2b2220;
    --d-parchment-2: #382d29;
    --d-parchment-3: #443732;
    --d-paper: #362a26;
    --d-navy: #f1e4cb;
    --d-text2: #dccbad;
    --d-text3: #b39d7f;
    --d-red-soft: rgba(220, 70, 85, 0.14);
    --d-red-border: rgba(220, 90, 100, 0.4);
    --d-gold-soft: rgba(220, 189, 112, 0.14);
    --d-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --d-shadow-lg: 0 18px 40px -10px rgba(0, 0, 0, 0.65);
}
html.dark body { background: #2a211e; color: #f1e4cb; }
html.dark main, html.dark .page-wrapper, html.dark #app { background-color: transparent; }

/* Surfaces génériques : cartes, panneaux, tableaux, champs */
html.dark :is(.card, .panel, .modal-content, .table, table, .accordion, .box, .section-card) { background-color: var(--d-paper); color: var(--d-navy); border-color: var(--d-red-border); }
html.dark :is(input, textarea, select):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="submit"]):not([type="button"]) {
    background-color: var(--d-parchment-2); color: #f3e6cf; border-color: rgba(220, 189, 112, .35);
}
html.dark :is(input, textarea)::placeholder { color: #a58f70; }
html.dark h1, html.dark h2, html.dark h3, html.dark h4 { color: inherit; }
html.dark a:not([class]) { color: #f3dc92; }
html.dark hr { border-color: rgba(220, 189, 112, .25); }

/* Fond calligraphique décoratif : plus discret sur fond sombre */
html.dark .fond-calligraphies, html.dark [class*="calligraph"] { opacity: .35; filter: invert(1) brightness(1.2); }

/* Les cartes de la page Contact gardent leur bleu nuit ; la barre du haut reste identique dans les deux thèmes */
html.dark .main-header, html.dark .main-header * { color-scheme: dark; }
html.dark .hm-palette { color-scheme: dark; }

/* Transition douce au changement de thème */
html.hm-theme-change, html.hm-theme-change body, html.hm-theme-change body * { transition: background-color .35s ease, color .35s ease, border-color .35s ease !important; }

/* Pages de connexion et d'inscription */
html.dark :is(.login-container, .register-container) { background: rgba(42, 29, 24, .95); color: #f3e6cf; border-color: rgba(220, 189, 112, .45); }
html.dark :is(.login-container, .register-container) :is(h1, h2, h3, p, label, .form-label, small, .auth-subtitle, .form-footer, .login-footer) { color: #f3e6cf; }
html.dark :is(.login-container, .register-container) a { color: #f3dc92; }
html.dark :is(.login-container, .register-container) a.btn-full, html.dark :is(.login-container, .register-container) .btn-full { color: #fff; }
html.dark :is(.login-container, .register-container) { background: #2a1d18; }
html.dark .login-page-wrapper { background-color: #3a2a24; background-blend-mode: multiply; }

/* ═══ Mise au point du mode sombre (audit de contraste page par page) ═══ */

/* Rouge de la charte : plus clair pour rester lisible quand il sert de texte sur fond sombre */
html.dark { --d-red-text: #f0929b; }
html.dark :is(
    .count-number, .stat-value, .hours-day, .tag, .about-eyebrow-text, .about-eyebrow-text em, .section-title em, .results-section-title em,
    .archive-news-link, .news-card-link, .archive-agenda-link, .diversite-card-link, .card-title, .info-label, .form-label, .required-star, .field-error
) { color: var(--d-red-text); }
html.dark :is(.archive-news-link, .news-card-link, .archive-agenda-link, .div-tab, .mf-txt):not(.active) { color: #f1e4cb; }
html.dark .div-tab.active { color: #fff; }
html.dark :is(.archive-news-link, .news-card-link, .archive-agenda-link):hover { color: #f3dc92; }

/* Diversité culturelle : ses propres variables sont ramenées à la palette sombre commune */
html.dark {
    --bg-page: var(--d-parchment); --bg-card: var(--d-paper); --card-bg: var(--d-paper); --input-bg: var(--d-parchment-2);
    --text-primary: #f1e4cb; --text-secondary: #dccbad; --text-muted: #b39d7f; --border-color: rgba(220, 189, 112, .25);
    --shadow-color: rgba(0, 0, 0, .35); --shadow-hover: rgba(0, 0, 0, .5);
    --pagination-bg: var(--d-parchment-2); --pagination-border: rgba(220, 189, 112, .3); --pagination-text: #dccbad;
}
html.dark :is(.diversite-index-page, .diversite-show-page, .diversite-hero, .diversite-filters-wrapper, .diversite-card, .diversite-card-image) { background-color: var(--d-paper); color: #f1e4cb; }
html.dark .diversite-index-page, html.dark .diversite-show-page { background-color: var(--d-parchment); }
html.dark :is(.diversite-card h3, .diversite-hero h1, .diversite-card-title) { color: #f1e4cb; }
html.dark :is(.diversite-hero .highlight, .diversite-card-link, .diversite-eyebrow) { color: #e8cf8a; }
html.dark nav[role="navigation"] :is(a, span) { color: #dccbad; background-color: var(--d-parchment-2); border-color: rgba(220, 189, 112, .3); }

/* Pagination Laravel (Tailwind) */
html.dark nav[role="navigation"] a:hover { color: #f3dc92; }

/* ═══ Contact : la carte de coordonnées reprend le brun commun (plus de bleu) ═══ */
html.dark .contact-index-page .contact-side .contact-card {
    background: radial-gradient(ellipse 90% 55% at 50% 108%, rgba(255, 205, 110, .35), transparent 72%), linear-gradient(160deg, #4a3a32 0%, #3f322c 50%, #52403a 100%);
}
html.dark .cx-actions a { background: linear-gradient(135deg, rgba(40, 28, 24, .75), rgba(30, 20, 18, .8)); }
html.dark .cx-actions a:hover { background: linear-gradient(135deg, rgba(111, 10, 21, .95), rgba(60, 10, 14, .95)); }
html.dark .contact-index-page .contact-side .info-item { box-shadow: 0 12px 24px -16px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255, 255, 255, .18); }


/* ═══ Accueil : pas de mode sombre section par section. Les sections gardent leur aspect d'origine et reçoivent UN SEUL filtre brun très léger, du slider au pied de page ═══ */
html.hm-teinte body::after {
    content: ''; position: fixed; inset: 0; z-index: 9000; pointer-events: none;
    background: rgba(105, 66, 38, .62); mix-blend-mode: multiply;
}
@media print { html.hm-teinte body::after { display: none; } }

/* ═══ Espace usager : brouillons « Mes demandes à terminer » et titres ═══ */
html.dark .drafts-box { background: linear-gradient(135deg, #3f322c, #362a26); border-color: rgba(220, 189, 112, .55); border-inline-start-color: #c8283a; box-shadow: 0 18px 40px -26px rgba(0, 0, 0, .8); }
html.dark .drafts-head h2 { color: #f6df9a; }
html.dark .drafts-head p { color: #dccbad; }
html.dark .draft-item { background: #2f2521; border-color: rgba(220, 189, 112, .5); }
html.dark .draft-info strong { color: #f1e4cb; }
html.dark .draft-info small { color: #b39d7f; }
html.dark .draft-badge { background: rgba(220, 189, 112, .18); color: #f3dc92; }
html.dark .draft-btn:not(.pri) { background: rgba(255, 255, 255, .06); color: #f6ead3; border-color: rgba(220, 189, 112, .6); }
html.dark .draft-btn:not(.pri):hover { background: rgba(243, 220, 146, .22); color: #fff; }
html.dark .draft-btn.danger { color: #f0929b; }
html.dark :is(.hero-card-right h1 em, .page-title em, h1 em) { color: var(--d-red-text); }
html.dark :is(.stat-value, .chip-count, .td-ref, .pct) { color: var(--d-red-text); }
html.dark .status-badge.s-review { color: #9bcbff; }
html.dark .status-badge:is(.s-docs-missing, .s-rejected, .s-refused) { color: #ffa3a3; }
html.dark .status-badge:is(.s-approved, .s-done, .s-completed, .s-validated) { color: #98e6b0; }
html.dark .status-badge:is(.s-pending, .s-draft, .s-new) { color: #f3dc92; }

/* Carte « Ministre » des pages éditées : textes lisibles sur le fond brun */
html.dark .mac-minister small { color: #f3dc92 !important; }
html.dark .mac-minister strong { color: #ffe3e6 !important; }
html.dark .mac-minister .mac-q { color: #e9dcc6 !important; }
html.dark .mac-minister .mac-btn { color: #fff !important; }
html.dark .mac-minister .mac-btn i { color: #fff !important; }

/* Logo du ministère sur les pages de connexion : version à textes clairs en mode sombre, proportions toujours respectées */
.login-header img.login-logo { object-fit: contain; aspect-ratio: auto; }
html.dark .login-header img.login-logo { content: url('../images/logo-connexion-sombre.png'); filter: drop-shadow(0 2px 10px rgba(0, 0, 0, .45)); }
