/*
 * Mode sombre du site public — appliqué uniquement si le système (téléphone, ordinateur) est réglé en sombre.
 * Chargé APRÈS les styles de chaque page : il ne fait que redéfinir des couleurs, jamais la mise en page.
 * Les widgets de chat gardent leur thème clair (ils forcent leurs propres couleurs).
 */
@media screen and (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --dm-page: #0b1120;        /* fond de page */
        --white: #131c2e;          /* cartes, en-têtes (fond de page sur l'accueil : voir body) */
        --bg: #0b1120;             /* fond de page des autres pages */
        --secondary: #1e293b;      /* fonds secondaires, bordures douces */
        --border: #2b3850;
        --text: #e2e8f0;
        --text-light: #94a3b8;
        --dm-surface: #131c2e;     /* cartes */
        --dm-surface-2: #1a2438;   /* cartes au survol, champs */
        --dm-border: #2b3850;
        --dm-indigo-bg: #1e1b4b;
        --dm-orange-bg: #2a1a0e;
    }
    body { background: var(--dm-page); color: var(--text); }

    /* ===== Accueil (index.php) ===== */
    .navbar { background: rgba(11, 17, 32, 0.92); border-bottom-color: rgba(255, 255, 255, 0.06); }
    .hero:has(.hero-content) { background: linear-gradient(180deg, #0f172a 0%, #0b1120 100%); }
    .btn-secondary { background: var(--dm-surface-2); color: var(--text); }
    .btn-secondary:hover { background: var(--dm-border); }

    .service-card { background: var(--dm-surface); border-color: var(--dm-border); }
    .service-card:hover { border-color: #4f46e5; box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4); }
    .voice-teaser { background: var(--dm-indigo-bg); }
    .voice-teaser:hover { background: #272463; }

    .demo-mockup { background: var(--dm-surface); box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5); }
    .demo-content { background: #0f1729; }
    .demo-dot { background: var(--dm-border); }

    .feature-card { background: var(--dm-surface); }
    .feature-card:hover { box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4); }

    .booking-features { background: linear-gradient(180deg, #0c1a2e 0%, #0b1120 100%); }
    .booking-demo { background: var(--dm-surface); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); }
    .booking-chat { background: #0f1729; }
    .booking-message.user { background: var(--dm-surface-2); color: var(--text); box-shadow: none; }

    .sectors { background: #0e1626; }
    .sector-card { background: var(--dm-surface); }
    .sector-icon { background: color-mix(in srgb, var(--sector-color, var(--primary)) 22%, #131c2e) !important; }

    .pricing-card { background: var(--dm-surface); border-color: var(--dm-border); }
    .pricing-tabs { background: var(--dm-indigo-bg); }
    .pricing-choice .pricing-tabs { background: linear-gradient(#1e1b4b, #1e1b4b) padding-box, linear-gradient(135deg, #6366f1, #ec4899) border-box; }
    .pricing-tab { color: var(--text); }
    .pricing-tab[aria-selected="true"] { background: var(--dm-surface); color: #a5b4fc; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35); }
    .pricing-notes li { background: var(--dm-surface); border-color: var(--dm-border); }
    .pricing-summary-box { background: var(--dm-orange-bg); border-color: #9a3412; }
    .pricing-summary-box--month { background: var(--dm-indigo-bg); border-color: #4f46e5; }
    .pricing-summary-step { color: #fdba74; }
    .pricing-summary-box--month .pricing-summary-step { color: #a5b4fc; }
    .pricing-when--once { background: #431407; color: #fdba74; }
    .pricing-when--month { background: #312e81; color: #c7d2fe; }
    .pricing-setup { background: var(--dm-surface); border-color: #9a3412; }
    .pricing-setup th, .pricing-setup td { border-bottom-color: #4a2a12; }
    .pricing-setup thead th { background: var(--dm-orange-bg); color: #fdba74; }
    .pricing-setup td strong { color: #4ade80; }
    .pricing-dots button { background: #475569; }
    .pricing-dots button[aria-current="true"] { background: #818cf8; }
    .pricing-swipe { color: #a5b4fc; }

    .service-pack { background: linear-gradient(#1a1740, #1a1740) padding-box, linear-gradient(135deg, #6366f1, #ec4899) border-box; }
    .service-pack .service-link, .hero-duo a { color: #a5b4fc; }
    .pack-perk { background: var(--dm-surface); border-color: var(--dm-border); }
    .pack-example tfoot th, .pack-example tfoot td { border-top-color: #9a3412; }

    .pack-all { background: var(--dm-surface); border-color: var(--dm-border); }
    .pack-all-title { color: #a5b4fc; }
    .pack-matrix td strong { color: var(--text); }
    .pack-matrix td.pack-matrix-best { background: #052e1f; }
    .pack-matrix td.pack-matrix-best strong { color: #4ade80; }

    .contact-form-card { background: var(--dm-surface); box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5); }
    .contact-form input, .contact-form textarea, .contact-form select {
        background: var(--dm-surface-2); border-color: var(--dm-border); color: var(--text);
    }
    .contact-form input::placeholder, .contact-form textarea::placeholder { color: #64748b; }
    .contact-form-message.success { background: #052e1f; color: #6ee7b7; }
    .contact-form-message.error { background: #3b0d0d; color: #fca5a5; }

    .footer:has(.footer-brand) { background: #020617; }

    /* ===== Secrétaire téléphonique (secretaire-telephonique.php) ===== */
    .hero:not(:has(.hero-content)) {
        background:
            radial-gradient(circle at 15% 20%, rgba(139, 92, 246, 0.22), transparent 45%),
            radial-gradient(circle at 85% 70%, rgba(99, 102, 241, 0.22), transparent 45%),
            var(--dm-page);
    }
    .badge { background: var(--dm-indigo-bg); color: #c7d2fe; }
    .hero p.duo { background: rgba(19, 28, 46, 0.8); border-color: #3730a3; }
    .hero p.duo a { color: #a5b4fc; }
    .phone-screen { background: #0f1729; }
    .bubble.ai { background: var(--dm-surface-2); color: var(--text); }
    .notif { background: #052e1f; border-color: #065f46; color: #6ee7b7; }
    .card:hover { border-color: #4f46e5; box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4); }
    .icon { background: var(--dm-indigo-bg); color: #a5b4fc; }
    .problem { background: #0e1626; }
    .final .btn { background: #fff; color: var(--primary-dark); }

    /* ===== Démo (demo.php) : l'interface passe en sombre, le chat de démonstration reste clair
       comme le vrai widget installé chez les clients ===== */
    .demo-header, .demo-sidebar, .mobile-sector-menu, .mobile-sector-menu-header { border-color: var(--dm-border); }
    .sector-btn { border-color: var(--dm-border); }
    .sector-btn:hover { background: var(--dm-surface-2); }
    .sector-btn.active { background: color-mix(in srgb, var(--sector-color, var(--primary)) 18%, #131c2e); }
    .tips-section { border-top-color: var(--dm-border); }
    .tip-card { background: var(--dm-surface-2); }
    .mobile-sector-menu, .mobile-sector-menu-header { background: var(--dm-surface); }
    .mobile-sector-close, .mobile-sector-item:hover, .mobile-sector-item.active { background: var(--dm-surface-2); }
    .embedded-chat {
        color-scheme: light;
        --white: #ffffff; --bg: #f8fafc; --text: #1e293b; --text-light: #64748b;
        color: var(--text);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    }

    /* ===== Pages légales (cgv, cgu, mentions-legales, dpa) ===== */
    .header, .intro { border-bottom-color: var(--dm-border); }
    .content { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35); }
    th, td { border-color: var(--dm-border); }
    .highlight { background: #052e1f; }
    .warning { background: #2a210a; }
    .downloads a { background: var(--dm-indigo-bg); color: #c7d2fe; }

    /* ===== Page d'erreur (error.php, sans variables) ===== */
    body:has(.error-container) { background: linear-gradient(135deg, #0b1120 0%, #111a2e 100%); }
    .error-title { color: var(--text); }
    .error-message, .redirect-text { color: var(--text-light); }
    .redirect-notice { background: var(--dm-surface); box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35); }
    .spinner { border-color: var(--dm-border); border-top-color: #6366f1; }

    /* Liens et textes en couleur principale : un ton plus clair, plus lisible sur fond sombre */
    .content a, .footer a:hover, .countdown { color: #a5b4fc; }
}
