/* =========================================================================
   Teranga Student Docs — Thème clair, épuré et professionnel
   Surcharge le mode clair de Bootstrap (data-bs-theme="light").
   ========================================================================= */
:root {
    /* Accent institutionnel : vert profond (sérieux/officiel), pas l'emerald générique */
    --vert: #0b5d3b;
    --vert-clair: #0f7a4d;
    --vert-fonce: #08402a;
    --vert-tres-clair: #edf3ef;
    --degrade-vert: linear-gradient(135deg, #0f7a4d 0%, #0b5d3b 100%);

    /* Blanc cassé chaud (effet papier officiel) */
    --fond: #f7f6f2;
    --surface: #ffffff;
    --surface-2: #f3f2ec;
    --bordure: #e6e3da;
    --bordure-forte: #d6d2c6;
    --bordure-vert: rgba(11, 93, 59, 0.35);
    --texte: #16201b;
    --texte-2: #3a423d;
    --muet: #6f756e;

    /* Angles nets, ombres discrètes (rigueur administrative) */
    --rayon: 0.55rem;
    --rayon-sm: 0.4rem;
    --ombre: 0 1px 2px rgba(20, 30, 24, 0.04), 0 2px 8px rgba(20, 30, 24, 0.05);
    --ombre-forte: 0 10px 28px rgba(20, 30, 24, 0.10);
    --ombre-vert: 0 4px 14px rgba(11, 93, 59, 0.20);

    --police-titres: "Spectral", Georgia, "Times New Roman", serif;

    /* Variables Bootstrap (mode clair) */
    --bs-body-bg: #f7f6f2;
    --bs-body-color: #16201b;
    --bs-emphasis-color: #0c140f;
    --bs-secondary-color: #6f756e;
    --bs-tertiary-color: #9aa09a;
    --bs-border-color: #e6e3da;
    --bs-primary: #0b5d3b;
    --bs-primary-rgb: 11, 93, 59;
    --bs-link-color: #0b5d3b;
    --bs-link-color-rgb: 11, 93, 59;
    --bs-link-hover-color: #08402a;
    --bs-link-hover-color-rgb: 8, 64, 42;
    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --bs-border-radius: 0.55rem;
    --bs-border-radius-sm: 0.4rem;
    --bs-border-radius-lg: 0.75rem;
    --bs-card-bg: #ffffff;
    --bs-card-border-color: #e6e3da;
    --bs-secondary-bg: #eef0ea;
    --bs-tertiary-bg: #f3f2ec;
}

body {
    font-family: var(--bs-body-font-family);
    color: var(--texte);
    background-color: var(--fond);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

.footer-teranga {
    border-top: 1px solid var(--bordure);
    background-color: #ffffff;
}
.footer-teranga a { color: var(--muet) !important; }
.footer-teranga a:hover { color: var(--texte) !important; text-decoration: none; }

/* Sélecteur de langue dans la barre de navigation */
.langues-nav { display: inline-flex; gap: 2px; align-items: center; font-size: 0.8rem; }
.langues-nav a { color: var(--muet); padding: 3px 7px; border-radius: 7px; text-decoration: none; line-height: 1; }
.langues-nav a:hover { color: var(--texte); text-decoration: none; }
.langues-nav a.actif { color: #ffffff; background: var(--vert); font-weight: 700; }
.langues-nav .nav-link { display: inline; }
.langues-nav .lang-actif { color: var(--vert) !important; font-weight: 700; }

h1, h2, h3, h4, h5, h6 { color: var(--texte); letter-spacing: -0.01em; }
/* Titres majeurs en serif institutionnel (caractère « officiel », pas Bootstrap par défaut) */
h1, h2, h3, .h1, .h2, .h3 { font-family: var(--police-titres); font-weight: 600; letter-spacing: -0.005em; }
a { text-decoration: none; color: var(--vert-fonce); }
a:hover { text-decoration: underline; }
.text-muted { color: var(--muet) !important; }
.fw-bold, .fw-semibold { color: #0b1220; }
hr { border-color: var(--bordure); opacity: 1; }

/* -------------------------------------------------------------- Navbars */
.navbar { position: sticky; top: 0; z-index: 1030; padding-top: 0.6rem; padding-bottom: 0.6rem; }

.navbar-teranga {
    background-color: rgba(255, 255, 255, 0.9);
    -webkit-backdrop-filter: saturate(160%) blur(10px);
    backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid var(--bordure);
}
.navbar-teranga .navbar-brand { font-family: var(--police-titres); font-weight: 600; letter-spacing: -0.005em; font-size: 1.2rem; color: var(--vert-fonce); }
.navbar-teranga .nav-link {
    color: var(--texte-2); font-weight: 500; border-radius: 0.55rem; padding: 0.35rem 0.7rem;
    transition: color 0.15s ease, background-color 0.15s ease;
}
.navbar-teranga .nav-link:hover { color: var(--vert-fonce); background-color: var(--vert-tres-clair); }

/* Barre admin : bande foncée sobre pour distinguer l'espace interne */
.navbar-admin {
    background-color: #0f172a;
    border-bottom: 1px solid #0b1220;
}
.navbar-admin .navbar-brand { font-family: var(--police-titres); color: #ffffff; font-weight: 600; letter-spacing: -0.005em; font-size: 1.2rem; }
.navbar-admin .nav-link { color: #cbd5e1; font-weight: 500; border-radius: 0.55rem; padding: 0.35rem 0.7rem; }
.navbar-admin .nav-link:hover, .navbar-admin .nav-link.active { color: #ffffff; background-color: rgba(255, 255, 255, 0.12); }
.navbar-admin .dropdown-menu { --bs-dropdown-bg: #ffffff; }

.navbar-toggler { border-color: var(--bordure); }

/* --------------------------------------------------------------- Cartes */
.card {
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    box-shadow: var(--ombre);
}
.card .card-body { padding: 1.35rem; }
a.card, .list-group-item-action { transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease; }
a.card:hover { transform: translateY(-2px); border-color: var(--bordure-vert); box-shadow: var(--ombre-forte); text-decoration: none; }
.list-group-item-action:hover { background-color: var(--vert-tres-clair); }
.shadow-sm { box-shadow: var(--ombre) !important; }

.bg-light { background-color: var(--surface-2) !important; }

/* -------------------------------------------------------------- Boutons */
.btn { border-radius: 0.6rem; font-weight: 600; letter-spacing: 0.01em;
       transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease; }
.btn-sm { border-radius: 0.5rem; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--vert); border-color: var(--vert); color: #ffffff; box-shadow: var(--ombre-vert); }
.btn-primary:hover, .btn-primary:focus { background: var(--vert-fonce); border-color: var(--vert-fonce); color: #ffffff; }

/* CTA fort : bouton sombre lisible sur fond clair */
.btn-dark { background: #111827; border-color: #111827; color: #ffffff; }
.btn-dark:hover { background: #0b1220; border-color: #0b1220; color: #ffffff; }

.btn-outline-primary { color: var(--vert-fonce); border-color: var(--bordure-vert); }
.btn-outline-primary:hover { background: var(--vert); border-color: var(--vert); color: #ffffff; }
.btn-outline-secondary { border-color: var(--bordure-forte); color: var(--texte-2); }
.btn-outline-secondary:hover { background: var(--surface-2); color: var(--texte); border-color: var(--bordure-forte); }
.btn-outline-dark { color: var(--texte-2); border-color: var(--bordure-forte); }
.btn-outline-dark:hover { background: #111827; color: #ffffff; border-color: #111827; }
/* « outline-light » est utilisé sur fond clair (cartes du portail) -> style neutre lisible */
.btn-outline-light { color: var(--texte-2); border-color: var(--bordure-forte); background: #ffffff; }
.btn-outline-light:hover { background: var(--surface-2); color: var(--texte); border-color: var(--bordure-forte); }
.btn-outline-danger { color: #dc2626; border-color: rgba(220, 38, 38, 0.4); }
.btn-outline-danger:hover { background: #dc2626; border-color: #dc2626; color: #ffffff; }
.btn-link { color: var(--vert-fonce); }

/* -------------------------------------------------------- Badges / pills */
.badge { border-radius: 999px; font-weight: 600; padding: 0.4em 0.75em; letter-spacing: 0.01em; }

/* -------------------------------------------------------- Formulaires */
.form-control, .form-select {
    background-color: #ffffff;
    border-radius: var(--rayon-sm);
    border-color: var(--bordure-forte);
    color: var(--texte);
    padding: 0.55rem 0.85rem;
}
.form-control::placeholder { color: #9ca3af; }
.form-control:focus, .form-select:focus {
    background-color: #ffffff;
    border-color: var(--vert);
    box-shadow: 0 0 0 0.2rem rgba(5, 150, 105, 0.15);
    color: var(--texte);
}
.form-label { color: var(--texte-2); font-weight: 500; }
.form-check-input:checked { background-color: var(--vert); border-color: var(--vert); }
.form-check-input:focus { border-color: var(--vert); box-shadow: 0 0 0 0.2rem rgba(5, 150, 105, 0.15); }

/* ------------------------------------------------------------- Tableaux */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--texte);
    --bs-table-hover-bg: var(--vert-tres-clair);
    --bs-table-hover-color: var(--texte);
    --bs-table-border-color: var(--bordure);
}
.table > thead th {
    text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.04em;
    color: var(--muet); font-weight: 600; border-bottom: 1px solid var(--bordure);
    background-color: transparent;
}
.table-light, .table > thead.table-light th { background-color: var(--surface-2) !important; color: var(--muet) !important; }
.table > tbody td { border-color: var(--bordure); vertical-align: middle; }

/* --------------------------------------------------------- List groups */
.list-group { --bs-list-group-bg: transparent; }
.list-group-item { background-color: transparent; border-color: var(--bordure); color: var(--texte); }

/* ------------------------------------------------------------- Alertes */
.alert { border: 1px solid transparent; border-radius: var(--rayon-sm); border-left-width: 4px; }
.alert-primary { background: var(--vert-tres-clair); color: var(--vert-fonce); border-color: rgba(11,93,59,0.22); border-left-color: var(--vert); }
.alert-success { background: var(--vert-tres-clair); color: var(--vert-fonce); border-color: rgba(11,93,59,0.22); border-left-color: var(--vert); }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; border-left-color: #f59e0b; }
.alert-danger { background: #fef2f2; color: #991b1b; border-color: #fecaca; border-left-color: #ef4444; }
.alert-info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; border-left-color: #3b82f6; }
.alert-secondary { background: var(--surface-2); color: var(--texte-2); border-color: var(--bordure); border-left-color: var(--muet); }

/* --------------------------------------------------------- Progression */
.progress { background-color: var(--surface-2); border-radius: 999px; }
.progress-bar { background: var(--degrade-vert); border-radius: 999px; }

/* ---------------------------------------------------------- Pagination */
.pagination { --bs-pagination-bg: #ffffff; --bs-pagination-color: var(--texte-2); --bs-pagination-border-color: var(--bordure);
              --bs-pagination-hover-bg: var(--surface-2); --bs-pagination-hover-color: var(--texte); --bs-pagination-hover-border-color: var(--bordure);
              --bs-pagination-active-bg: var(--vert); --bs-pagination-active-border-color: var(--vert); --bs-pagination-active-color: #ffffff;
              --bs-pagination-disabled-bg: #ffffff; --bs-pagination-disabled-color: #9ca3af; }
.page-link { border-radius: 0.5rem; margin: 0 2px; }

/* ------------------------------------------------------------ Modales */
.modal-content { background: #ffffff; border: 1px solid var(--bordure); border-radius: 1.1rem; box-shadow: var(--ombre-forte); overflow: hidden; }
.modal-header, .modal-footer { border-color: var(--bordure); }

/* ---------------------------------------------------------- Dropdown */
.dropdown-menu { --bs-dropdown-bg: #ffffff; --bs-dropdown-border-color: var(--bordure); --bs-dropdown-link-color: var(--texte);
                 --bs-dropdown-link-hover-bg: var(--vert-tres-clair); --bs-dropdown-link-hover-color: var(--vert-fonce);
                 box-shadow: var(--ombre-forte); border-radius: 0.8rem; }

/* ------------------------------------------------ Utilitaires de largeur */
.carte-etroite { max-width: 24rem; width: 100%; }
.carte-moyenne { max-width: 32rem; }
.champ-recherche { max-width: 18rem; }
.champ-filtre { max-width: 12rem; }
.champ-20 { max-width: 20rem; }
.champ-16 { max-width: 16rem; }
.champ-14 { max-width: 14rem; }
.champ-6 { max-width: 6rem; }
.champ-ordre { width: 5rem; }
.barre-progression { height: 0.75rem; }
.menu-notifications { min-width: 20rem; max-width: 24rem; }
.form-contents { display: contents; }
.robot-cache { display: none; }
.texte-pre { white-space: pre-line; }
.ico-inline { vertical-align: -2px; }

/* --------------------------------------------- Icônes de cartes de stats */
.stat-ico { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; flex: none; }
.stat-ico svg { width: 22px; height: 22px; stroke-width: 2; }
.stat-ico.vert { background: #d1fae5; color: #047857; }
.stat-ico.bleu { background: #dbeafe; color: #1d4ed8; }
.stat-ico.ambre { background: #fef3c7; color: #b45309; }
.stat-ico.rouge { background: #fee2e2; color: #b91c1c; }

/* ------------------------------------------- Carte des services (Leaflet) */
#carte-services {
    height: 460px; border-radius: 16px; overflow: hidden; z-index: 1;
    border: 1px solid var(--bordure);
    box-shadow: var(--ombre);
}
.leaflet-control-zoom a { background: #ffffff !important; color: #333 !important; border-color: #dcdfe4 !important; }
.leaflet-control-zoom a:hover { background: #f3f4f6 !important; }
.leaflet-control-attribution { background: rgba(255,255,255,0.85) !important; color: #555 !important; }
.leaflet-control-attribution a { color: #2563eb !important; }

.legende { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.legende label {
    display: inline-flex; align-items: center; gap: 7px; font-size: 0.8rem; color: var(--texte-2);
    cursor: pointer; -webkit-user-select: none; user-select: none;
    background: #ffffff; border: 1px solid var(--bordure);
    padding: 5px 11px; border-radius: 999px; transition: border-color .15s, background .15s;
}
.legende label:hover { border-color: var(--bordure-vert); background: var(--vert-tres-clair); }
.legende .pastille { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.pastille.c-supermarche { background: #3b82f6; }
.pastille.c-hopital { background: #ef4444; }
.pastille.c-universite { background: #a855f7; }
.pastille.c-eglise { background: #f59e0b; }
.pastille.c-marche { background: #10b981; }
.pastille.c-arret_bus { background: #06b6d4; }
.pastille.c-brt { background: #ec4899; }
.pastille.c-police { background: #1e3a8a; }

/* Panneau itinéraire */
.itineraire {
    background: #ffffff; border: 1px solid var(--bordure);
    border-radius: 14px; padding: 12px 14px;
}
.itineraire-champs { display: flex; flex-direction: column; gap: 10px; }
.itin-point { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.itin-libelle {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muet); min-width: 74px;
}
.itin-valeur { font-size: 0.85rem; color: var(--texte); flex: 1 1 160px; min-width: 120px; }
.itin-saisie { position: relative; flex: 1 1 220px; min-width: 160px; }
.itin-saisie input { width: 100%; }
.itin-suggestions {
    display: none; position: absolute; z-index: 1200; left: 0; right: 0; top: calc(100% + 2px);
    background: #ffffff; border: 1px solid var(--bordure); border-radius: 10px;
    overflow: hidden; box-shadow: var(--ombre-forte); max-height: 240px; overflow-y: auto;
}
.itin-sugg {
    padding: 7px 11px; font-size: 0.8rem; color: var(--texte-2); cursor: pointer;
    border-bottom: 1px solid var(--bordure);
}
.itin-sugg:last-child { border-bottom: none; }
.itin-sugg:hover { background: var(--vert-tres-clair); color: var(--vert-fonce); }
.itin-boutons { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.itin-select { max-width: 260px; flex: 1 1 200px; }
#carte-services.choix-actif { cursor: crosshair; }
#carte-services.choix-actif .leaflet-interactive { cursor: crosshair; }

/* Épingles départ / arrivée (lettre D / A) */
.itin-pin {
    display: flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 50%; color: #fff;
    font-size: 0.8rem; font-weight: 700; border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* Boutons dans les popups Leaflet */
.pop-itin .pop-cat { color: #6b7280; font-size: 0.78rem; }
.pop-actions { display: flex; gap: 6px; margin-top: 8px; }
.pop-actions button {
    flex: 1; font-size: 0.75rem; padding: 4px 8px; border-radius: 8px;
    border: 1px solid #cbd5e1; background: #f8fafc; color: #1f2937; cursor: pointer;
}
.pop-actions button:hover { background: #10b981; border-color: #10b981; color: #fff; }

/* Note « configurez une clé » */
.note-cle code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; color: var(--vert-fonce); }

/* Badge température / qualité de l'air (contrôle Leaflet) */
.carte-meteo {
    background: rgba(255,255,255,0.94); color: #1f2937; border-radius: 10px;
    padding: 6px 10px; font-size: 0.78rem; font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18); display: flex; align-items: center; gap: 8px;
}
.carte-meteo .m-temp { font-size: 0.95rem; }
.carte-meteo .m-desc { color: #6b7280; font-weight: 500; text-transform: capitalize; }
.carte-meteo .m-aqi { font-weight: 700; }

/* Marqueurs "épingle" (pin) avec icône — construits en SVG côté JS */
.leaflet-div-icon { background: transparent; border: none; }
.pin-svg { filter: drop-shadow(0 3px 3px rgba(0,0,0,0.35)); }

/* Marqueur "vous êtes ici" (radar) */
.moi { position: relative; display: block; width: 18px; height: 18px; }
.moi .point { position: absolute; inset: 0; margin: auto; width: 14px; height: 14px; border-radius: 50%;
              background: #10b981; border: 2px solid #ffffff; box-shadow: 0 2px 8px rgba(16,185,129,0.7); }
.moi .onde { position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(16,185,129,0.7); animation: radar 2s ease-out infinite; }
@keyframes radar { 0% { transform: scale(0.4); opacity: 0.9; } 100% { transform: scale(3.4); opacity: 0; } }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #ffffff; color: #1f2937; }
.leaflet-popup-content-wrapper { border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.25); }
.leaflet-container { background: #eef1f5; font-family: var(--bs-body-font-family); }

/* ------------------------------------------------- Widget de chat flottant */
#chatbot-toggle {
    position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 1050;
    width: 4rem; height: 4rem; border-radius: 50%; border: none; padding: 0;
    background: var(--degrade-vert);
    box-shadow: 0 10px 26px rgba(5, 150, 105, 0.4);
    animation: robot-float 2.4s ease-in-out infinite;
}
#chatbot-panel {
    position: fixed; bottom: 6.5rem; right: 1.5rem; z-index: 1050;
    width: calc(100vw - 3rem); max-width: 22rem; max-height: 28rem;
    border-radius: 1.1rem; box-shadow: var(--ombre-forte);
}
#chatbot-messages { max-height: 16rem; overflow-y: auto; }
.chat-bubble-bot { background-color: var(--surface-2); color: var(--texte); border-radius: 0.9rem 0.9rem 0.9rem 0.25rem; max-width: 85%; align-self: flex-start; }
.chat-bubble-user { background: var(--vert); color: #ffffff; border-radius: 0.9rem 0.9rem 0.25rem 0.9rem; max-width: 85%; align-self: flex-end; font-weight: 500; }

@keyframes robot-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes antenna-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@keyframes thinking-dot-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.5; } 40% { transform: translateY(-3px); opacity: 1; } }
#robot-antenna-light { animation: antenna-blink 1.6s ease-in-out infinite; }
.thinking-dot { animation: thinking-dot-bounce 1s ease-in-out infinite; }
.thinking-dot:nth-child(2) { animation-delay: 0.15s; }
.thinking-dot:nth-child(3) { animation-delay: 0.3s; }

/* Messagerie ticket (dossier <-> police) */
.fil-messages { max-height: 320px; overflow-y: auto; }
.bulle-message { max-width: 80%; }
.opacite-70 { opacity: 0.7; }

/* Cockpit statistiques police */
.barres-volume { height: 130px; }
.etiquette-jour { font-size: 0.6rem; }
.barre-fine { height: 8px; }

/* Frise de suivi du dossier (timeline verticale, sans emoji) */
.fil-suivi { list-style: none; margin: 0; padding: 0 0 0 1.25rem; position: relative; }
.fil-suivi::before {
    content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px;
    width: 2px; background: var(--bordure);
}
.fil-suivi li { position: relative; margin-bottom: 0.65rem; }
.fil-suivi li:last-child { margin-bottom: 0; }
.fil-suivi li::before {
    content: ""; position: absolute; left: -1.25rem; top: 4px;
    width: 12px; height: 12px; border-radius: 50%;
    background: #ffffff; border: 2px solid var(--muet);
}
.fil-suivi li.fait::before {
    background: var(--vert); border-color: var(--vert);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}
.fil-suivi li.attente::before { border-style: dashed; }
