/* ============================================================
   OMEDYS CARTOGRAPHIE — Design System v2
   Langage : Glassmorphisme BP3
   Typo    : DM Sans (tout)
   ============================================================ */

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

/* ── Tokens ──────────────────────────────────────────────── */
:root {
    --primary:        #009597;
    --primary-glow:   rgba(0, 149, 151, 0.35);
    --primary-dim:    rgba(0, 149, 151, 0.15);

    /* Glass surfaces */
    --glass-bg:       rgba(255, 255, 255, 0.28);
    --glass-bg-deep:  rgba(255, 255, 255, 0.18);
    --glass-border:   rgba(255, 255, 255, 0.18);
    --glass-inset:    rgba(255, 255, 255, 0.08);
    --glass-blur:     blur(24px) saturate(160%);

    /* Shadows */
    --shadow-float:   0 24px 64px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255,255,255,0.12);
    --shadow-sm:      0 8px 24px rgba(0, 0, 0, 0.12);

    /* Text */
    --text-primary:   rgba(0, 0, 0, 0.88);
    --text-secondary: rgba(0, 0, 0, 0.50);
    --text-muted:     rgba(0, 0, 0, 0.35);

    /* Item surfaces */
    --item-bg:        rgba(255, 255, 255, 0.52);
    --item-bg-hover:  rgba(255, 255, 255, 0.72);
    --item-border:    rgba(255, 255, 255, 0.10);

    /* Select */
    --select-bg:      rgba(255, 255, 255, 0.45);
    --select-border:  rgba(255, 255, 255, 0.20);
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body, html {
    margin: 0; padding: 0; height: 100%;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -webkit-touch-callout: none;
    color-scheme: light dark;
}

.leaflet-container a { color: #fff; }
#map { height: 100vh; width: 100vw; z-index: 1; }

/* ============================================================
   BENTO WRAPPER
   ============================================================ */
.bento-wrapper {
    position: fixed; top: 20px; left: 20px; z-index: 1000;
    display: flex; flex-direction: column; gap: 10px;
    width: 400px; pointer-events: none;
    font-family: 'DM Sans', sans-serif;
}

/* Tuile glass de base — partagée par tous les composants */
.bento-tile {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    box-shadow: var(--shadow-float);
    padding: 14px 16px;
    pointer-events: auto;
    position: relative;
    overflow: hidden;
    /* Highlight supérieur façon BP3 */
    background-image: linear-gradient(
        180deg,
        rgba(255,255,255,0.10) 0%,
        transparent 60%
    );
}

/* Lueur d'ambiance dans le coin — comme bp3-header::before */
.bento-tile::before {
    content: '';
    position: absolute; top: -50px; right: -40px;
    width: 140px; height: 140px; border-radius: 50%;
    background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
    pointer-events: none; z-index: 0;
}

.bento-tile > * { position: relative; z-index: 1; }

.bento-row { display: flex; gap: 10px; }

/* ============================================================
   BOUTON HAMBURGER
   ============================================================ */
.bento-action {
    width: 54px; height: 54px; flex-shrink: 0;
    border: none; border-radius: 16px;
    background: var(--primary);
    background-image: linear-gradient(145deg, #00b3b5, #007a7c);
    box-shadow: 0 8px 24px rgba(0,149,151,0.45), inset 0 1px 0 rgba(255,255,255,0.25);
    display: flex; flex-direction: column;
    justify-content: center; align-items: center; gap: 5px;
    cursor: pointer; padding: 0;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    /* pas de ::before hérité */
    overflow: visible;
    background-clip: padding-box;
}
.bento-action::before { display: none; }
.bento-action:hover  { transform: scale(1.04); box-shadow: 0 12px 32px rgba(0,149,151,0.55), inset 0 1px 0 rgba(255,255,255,0.30); }
.bento-action:active { transform: scale(0.95); }

.bar { width: 22px; height: 3px; background: #fff; border-radius: 2px; transition: transform 0.3s ease, opacity 0.3s ease; }

#menu-btn { pointer-events: auto !important; cursor: pointer !important; }
#menu-btn.active .bar:nth-child(1) { transform: translateY(8px) rotate(45deg); }
#menu-btn.active .bar:nth-child(2) { opacity: 0; }
#menu-btn.active .bar:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* ============================================================
   STATS
   ============================================================ */
.bento-stats {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center; gap: 2px;
    padding: 10px 14px;
}

.bento-stats small {
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    text-transform: none;
}

#site-count {
    display: block;
    font-size: 28px; font-weight: 700;
    color: var(--primary);
    line-height: 1.1;
}

/* ============================================================
   BARRE DE RECHERCHE
   ============================================================ */
.bento-search {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px;
}

/* Icône loupe via FA — injectée en JS dans ui.search.js */
.bento-search .fa-magnifying-glass {
    font-size: 15px;
    color: var(--text-secondary);
    flex-shrink: 0;
    position: relative; z-index: 1;
}

.bento-search input {
    flex: 1; border: none; background: transparent; outline: none;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px; font-weight: 600;
    color: var(--text-primary);
    caret-color: var(--primary);
}
.bento-search input::placeholder { color: var(--text-muted); font-weight: 500; }

.inner-search-btn {
    background: rgba(255,255,255,0.35);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    width: 24px; height: 24px;
    font-size: 13px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary);
    transition: background 0.15s;
    flex-shrink: 0;
}
.inner-search-btn:hover { background: rgba(255,255,255,0.55); }

/* ============================================================
   PANNEAU FILTRES
   ============================================================ */
.bento-filters {
    display: none; opacity: 0; transform: translateY(-8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    max-height: 0; overflow: hidden;
    padding: 0;
}
.bento-filters.open {
    display: block !important; opacity: 1 !important;
    transform: translateY(0) !important;
    max-height: 620px !important;
    overflow: hidden;
    padding: 14px 16px;
}

.filter-list-wrapper {
    max-height: 590px; overflow-y: auto; overflow-x: hidden;
    padding-right: 6px;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.3) transparent;
}
.filter-list-wrapper::-webkit-scrollbar { width: 4px; }
.filter-list-wrapper::-webkit-scrollbar-track { background: transparent; }
.filter-list-wrapper::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.35); border-radius: 4px; }

.filter-section { margin-bottom: 18px; }
.filter-section:last-child { margin-bottom: 0; }

/* Titre de section — style bp3-tile-label */
.section-title {
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text-secondary);
    margin: 0 0 10px 2px;
    display: flex; align-items: center; gap: 6px;
}

.section-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 6px;
    background: var(--primary-dim); border-radius: 6px;
    font-size: 11px; font-weight: 600; color: var(--primary);
}

.filters-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
    margin: 14px 0;
}

.filters-grid { display: flex; flex-direction: column; gap: 6px; }

/* ── Item filtre coloré (checkbox) ── */
.filter-item.color-filter {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 12px;
    background: var(--item-bg);
    border: 1px solid var(--item-border);
    border-radius: 12px;
    cursor: pointer; user-select: none;
    transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
.filter-item.color-filter:hover {
    background: var(--item-bg-hover);
    border-color: rgba(255,255,255,0.25);
}
.filter-item.color-filter.active {
    background: rgba(255,255,255,0.65);
    border-color: var(--primary);
}
.filter-item.color-filter:active { transform: scale(0.98); }

/* ── Item filtre toggle (switch) ── */
.filter-item.toggle-filter {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 12px;
    background: var(--item-bg);
    border: 1px solid var(--item-border);
    border-radius: 12px;
    cursor: pointer; user-select: none;
    transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
.filter-item.toggle-filter:hover {
    background: var(--item-bg-hover);
    border-color: rgba(255,255,255,0.25);
}
.filter-item.toggle-filter.active {
    background: rgba(255,255,255,0.65);
    border-color: var(--primary);
}
.filter-item.toggle-filter:active { transform: scale(0.98); }

/* Dot couleur */
.filter-dot {
    width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0;
    transition: transform 0.15s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.filter-item.color-filter:hover .filter-dot { transform: scale(1.2); }

/* Contenu texte */
.filter-content { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.filter-label {
    font-size: 13px; font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.filter-description {
    font-size: 11px; font-weight: 400;
    color: var(--text-secondary);
}
.filter-item.active .filter-label     { color: #0f766e; }
.filter-item.active .filter-description { color: #0d9488; }

/* Checkbox */
.filter-checkbox {
    width: 20px; height: 20px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.45);
    border: 1.5px solid rgba(255,255,255,0.40);
    border-radius: 6px;
    transition: background 0.15s, border-color 0.15s;
}
.filter-item.color-filter.active .filter-checkbox {
    background: var(--primary);
    border-color: var(--primary);
}
.filter-checkbox::after {
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    content: '\f00c';
    color: white; font-size: 10px;
    opacity: 0; transition: opacity 0.15s;
}
.filter-item.color-filter.active .filter-checkbox::after { opacity: 1; }

/* Toggle switch */
.toggle-switch {
    width: 38px; height: 22px; border-radius: 11px;
    background: rgba(255,255,255,0.30);
    border: 1px solid rgba(255,255,255,0.25);
    position: relative; flex-shrink: 0;
    display: flex; align-items: center;
    justify-content: flex-start; padding: 2px;
    transition: background 0.25s, border-color 0.25s;
}
.toggle-switch::after {
    content: ''; width: 18px; height: 18px;
    background: white;
    border-radius: 9px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.18);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.filter-item.toggle-filter.active .toggle-switch {
    background: var(--primary);
    border-color: transparent;
    box-shadow: 0 2px 10px rgba(0,149,151,0.4);
}
.filter-item.toggle-filter.active .toggle-switch::after {
    transform: translateX(16px);
    box-shadow: 0 2px 8px rgba(0,149,151,0.35);
}

/* Select géo */
.filter-section select {
    width: 100%; padding: 10px 12px;
    background: var(--select-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--select-border);
    border-radius: 12px;
    font-family: 'DM Sans', sans-serif;
    font-size: 12px; font-weight: 600;
    color: var(--text-primary);
    cursor: pointer; outline: none;
    -webkit-appearance: none; appearance: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    /* Flèche custom */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23009597' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}
.filter-section select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-dim);
}
.filter-section select option { background: #fff; color: #1e293b; }

/* Bouton reset */
.filter-reset-btn {
    width: 100%; padding: 10px;
    background: rgba(255,255,255,0.20);
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 12px;
    font-family: 'DM Sans', sans-serif;
    font-size: 12px; font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer; margin-top: 4px;
    transition: background 0.15s, color 0.15s;
    letter-spacing: 0.02em;
}
.filter-reset-btn:hover {
    background: rgba(255,255,255,0.38);
    color: var(--text-primary);
}

/* ============================================================
   SUGGESTIONS RECHERCHE
   ============================================================ */
#suggestions {
    position: fixed; top: 72px; left: 20px; width: 400px;
    max-height: 340px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    box-shadow: var(--shadow-float);
    z-index: 2000;
    overflow-y: auto; overflow-x: hidden;
    padding: 6px;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.3) transparent;
}
#suggestions:empty { display: none; }
#suggestions::-webkit-scrollbar { width: 4px; }
#suggestions::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.35); border-radius: 4px; }

.suggestion-item {
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer; user-select: none;
    transition: background 0.12s, transform 0.1s;
    border-bottom: none;
}
.suggestion-item:not(.empty):hover { background: rgba(255,255,255,0.55); }
.suggestion-item:active { background: rgba(255,255,255,0.7); transform: scale(0.99); }
.suggestion-item.empty {
    padding: 20px 16px; text-align: center;
    font-size: 13px; font-weight: 600;
    color: var(--text-muted); cursor: default;
}

.suggestion-header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 3px;
}
.suggestion-city {
    font-family: 'DM Sans', sans-serif;
    font-size: 13px; font-weight: 600;
    color: var(--text-primary);
    flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.suggestion-zip {
    font-size: 11px; font-weight: 600;
    color: var(--primary);
    background: var(--primary-dim);
    padding: 2px 8px; border-radius: 6px;
    flex-shrink: 0; margin-left: 8px;
}
.suggestion-meta { font-size: 11px; color: var(--text-secondary); font-weight: 400; }
.suggestion-province { word-break: break-word; }

/* ============================================================
   MARQUEUR CABINET — divIcon FA + halo pulsé
   ============================================================ */
.cabinet-marker {
    position: relative;
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
}

.cabinet-pulse {
    position: absolute;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--cm-color);
    opacity: 0.35;
    animation: cabinet-pulse 2s ease-out infinite;
}

@keyframes cabinet-pulse {
    0%   { transform: scale(0.7); opacity: 0.45; }
    70%  { transform: scale(1.9); opacity: 0;    }
    100% { transform: scale(1.9); opacity: 0;    }
}

.cabinet-pin {
    position: relative; z-index: 1;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--cm-color);
    border: 2.5px solid rgba(255,255,255,0.9);
    box-shadow: 0 3px 10px rgba(0,0,0,0.25);
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s;
}
.cabinet-pin i {
    font-size: 12px;
    color: #fff;
}
.cabinet-marker:hover .cabinet-pin { transform: scale(1.12); }

/* ============================================================
   POPUP BP3 — Glassmorphisme (inchangé, référence)
   ============================================================ */
.bp3-popup .leaflet-popup-content-wrapper {
    background: transparent !important; border: none !important;
    border-radius: 16px !important; box-shadow: none !important;
    padding: 0 !important; overflow: visible !important;
}
.bp3-popup .leaflet-popup-content { margin: 0 !important; width: 350px !important; }
.bp3-popup .leaflet-popup-tip-container { display: none; }
.bp3-popup .leaflet-popup-close-button {
    top: 10px !important; right: 10px !important;
    width: 24px !important; height: 24px !important;
    font-size: 16px !important; line-height: 24px !important;
    text-align: center;
    color: rgba(0,0,0,0.40) !important;
    background: rgba(255,255,255,0.40) !important;
    border: 1px solid rgba(255,255,255,0.15) !important;
    border-radius: 50% !important; z-index: 10;
}

.bp3 {
    font-family: 'DM Sans', system-ui, sans-serif;
    width: 350px; border-radius: 16px; overflow: hidden;
    background: rgba(255,255,255,0.36);
    backdrop-filter: blur(22px) saturate(160%);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    border: 1px solid rgba(255,255,255,0.09);
    box-shadow: 0 24px 64px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.07);
    animation: bp3In 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes bp3In {
    from { opacity: 0; transform: scale(0.92) translateY(8px); }
    to   { opacity: 1; transform: scale(1)    translateY(0);   }
}
.bp3-header {
    padding: 14px 16px 12px; position: relative; overflow: hidden;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}
.bp3-header::before {
    content: ''; position: absolute; top: -40px; right: -60px;
    width: 140px; height: 140px; border-radius: 50%;
    background: radial-gradient(circle, var(--bp3-accent-glow, rgba(0,149,151,0.3)) 0%, transparent 70%);
    pointer-events: none;
}
.bp3-hd-top { display: inline-grid; align-items: center; gap: 7px; margin-bottom: 8px; flex-wrap: wrap; }
.bp3-badge {
    font-size: 11px; font-weight: 500;
    color: rgba(0,0,0,0.55); background: rgba(255,255,255,0.39);
    border: 1px solid rgba(255,255,255,0.12); padding: 3px 8px; border-radius: 20px;
}
.bp3-statut-pill {
    font-size: 11px; font-weight: 600;
    padding: 3px 8px; border-radius: 20px; display: flex; align-items: center; gap: 4px;
}
.bp3-pill-ouvert  { background: rgba(0,172,200,0.15); color: #0050c8; }
.bp3-pill-encours { background: rgba(255,202,111,0.25); color: #f59e0b; }
.bp3-pill-tele    { background: rgba(153,127,209,0.37); color: #6636db; }
.bp3-pill-default { background: rgba(255,255,255,0.08); color: rgba(0,0,0,0.45); }
.bp3-sdot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.bp3-pill-ouvert  .bp3-sdot { background: #0050c8; box-shadow: 0 0 5px #0050c8; }
.bp3-pill-encours .bp3-sdot { background: #f59e0b; }
.bp3-pill-tele    .bp3-sdot { background: #8956FB; box-shadow: 0 0 5px #8956FB; }
.bp3-pill-default .bp3-sdot { background: rgba(0,0,0,0.3); }
.bp3-title {
    font-size: 15px; font-weight: 700;
    color: rgba(0,0,0,0.88); line-height: 1.3;
}
.bp3-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 8px; }
.bp3-tile {
    background: rgba(255,255,255,0.6); border: 1px solid rgba(255,255,255,0.07);
    border-radius: 10px; padding: 9px 10px; display: block;
    transition: background 0.14s; cursor: default; min-width: 0;
}
.bp3-tile:hover { background: rgba(255,255,255,0.75); }
.bp3-tile.bp3-wide { grid-column: 1 / -1; }
.bp3-tile-label {
    font-size: 10px; font-weight: 500;
    color: rgba(0,0,0,0.50); margin-bottom: 3px;
}
.bp3-tile-value {
    font-size: 12px; font-weight: 600; color: rgba(0,0,0,0.82);
    white-space: pre-line; overflow: hidden; text-overflow: ellipsis;
    max-width: 100%; display: block;
}
.bp3-tile.bp3-wide .bp3-tile-value { white-space: normal; font-size: 12px; }
.bp3-link { color: #009597 !important; text-decoration: none; font-size: 13px !important; font-weight: 600 !important; }
.bp3-link:hover { color: #006365 !important; }
.bp3-mss { font-size: 11px !important; color: rgba(0,0,0,0.7) !important; }
.bp3-footer { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 0 8px 8px; }
.bp3-btn {
    display: flex; align-items: center; justify-content: center; gap: 5px;
    padding: 9px; border-radius: 9px; font-family: 'DM Sans', sans-serif;
    font-size: 12px; font-weight: 600; cursor: pointer;
    text-decoration: none; border: none; transition: all 0.14s;
}
.bp3-btn--copy { background: rgba(0,149,151,0.14); border: 1px solid rgba(255,255,255,0.12); color: rgba(0,0,0,0.65); }
.bp3-btn--copy:hover { background: rgba(0,149,151,0.25); }
.bp3-btn--maps { background: var(--primary); color: #fff !important; }
.bp3-btn--maps:hover { background: #007a7c; color: #fff !important; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
#filter-list { animation: slideDown 0.25s ease-out; }

/* ============================================================
   DARK MODE — déclenché par data-theme="dark" sur <html>
   Fallback : @media prefers-color-scheme pour le mode "system"
   ============================================================ */

/* Tokens dark partagés en mixin via un sélecteur commun */
:root[data-theme="dark"],
:root[data-theme="system"]:not([data-theme]) /* jamais utilisé, sécurité */
{ /* vide — les règles sont ci-dessous */ }

/* Sélecteur unique pour dark forcé ET fallback system */
[data-theme="dark"],
@media (prefers-color-scheme: dark) { /* overridé si data-theme="light" */ }

/* ── Variables dark ────────────────────────────────────── */
[data-theme="dark"] {
    --glass-bg:       rgba(10, 18, 35, 0.52);
    --glass-bg-deep:  rgba(10, 18, 35, 0.68);
    --glass-border:   rgba(255, 255, 255, 0.10);
    --glass-inset:    rgba(255, 255, 255, 0.05);
    --shadow-float:   0 24px 64px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.06);
    --text-primary:   rgba(255, 255, 255, 0.92);
    --text-secondary: rgba(255, 255, 255, 0.48);
    --text-muted:     rgba(255, 255, 255, 0.28);
    --item-bg:        rgba(255, 255, 255, 0.07);
    --item-bg-hover:  rgba(255, 255, 255, 0.12);
    --item-border:    rgba(255, 255, 255, 0.09);
    --select-bg:      rgba(255, 255, 255, 0.07);
    --select-border:  rgba(255, 255, 255, 0.12);
    --primary-glow:   rgba(0, 149, 151, 0.25);
    --primary-dim:    rgba(0, 149, 151, 0.18);
}

/* Fallback système (quand data-theme="system", JS pose dark ou light — mais
   au premier rendu avant JS, le CSS media query prend le relais) */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --glass-bg:       rgba(10, 18, 35, 0.52);
        --glass-bg-deep:  rgba(10, 18, 35, 0.68);
        --glass-border:   rgba(255, 255, 255, 0.10);
        --glass-inset:    rgba(255, 255, 255, 0.05);
        --shadow-float:   0 24px 64px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.06);
        --text-primary:   rgba(255, 255, 255, 0.92);
        --text-secondary: rgba(255, 255, 255, 0.48);
        --text-muted:     rgba(255, 255, 255, 0.28);
        --item-bg:        rgba(255, 255, 255, 0.07);
        --item-bg-hover:  rgba(255, 255, 255, 0.12);
        --item-border:    rgba(255, 255, 255, 0.09);
        --select-bg:      rgba(255, 255, 255, 0.07);
        --select-border:  rgba(255, 255, 255, 0.12);
        --primary-glow:   rgba(0, 149, 151, 0.25);
        --primary-dim:    rgba(0, 149, 151, 0.18);
    }
}

/* ── Règles dark (sélecteur réutilisable) ─────────────────── */
[data-theme="dark"] .bento-tile,
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bento-tile { } }

/* On utilise une classe utilitaire .is-dark injectée par theme.js sur <html>
   pour éviter les sélecteurs @media imbriqués non valides en CSS pur.
   → Voir ci-dessous : JS ajoute/retire .is-dark sur <html> */

html.is-dark .bento-tile {
    background-image: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, transparent 50%);
}
html.is-dark .filter-item.color-filter.active,
html.is-dark .filter-item.toggle-filter.active {
    background: rgba(0, 0, 0, 0.12); border-color: var(--primary);
}
html.is-dark .filter-item.active .filter-label      { color: #5eead4; }
html.is-dark .filter-item.active .filter-description { color: #2dd4bf; }
html.is-dark .filter-checkbox   { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.15); }
html.is-dark .toggle-switch     { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.10); }
html.is-dark .toggle-switch::after { background: rgba(255,255,255,0.80); }
html.is-dark .filter-item.toggle-filter.active .toggle-switch { background: var(--primary); }
html.is-dark .filters-divider   { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent); }
html.is-dark .filter-section select { background-color: rgba(255,255,255,0.06); color: rgba(255,255,255,0.9); }
html.is-dark .filter-section select option { background: #1e293b; color: #f1f5f9; }
html.is-dark .filter-reset-btn  { color: rgba(255,255,255,0.45); }
html.is-dark .filter-reset-btn:hover { background: rgba(255,255,255,0.10); color: rgba(255,255,255,0.85); }
html.is-dark .suggestion-city   { color: rgba(255,255,255,0.92); }
html.is-dark .suggestion-zip    { background: rgba(0,149,151,0.20); color: #5eead4; }
html.is-dark .suggestion-item:not(.empty):hover { background: rgba(255,255,255,0.08); }
html.is-dark .bento-search input { color: rgba(255,255,255,0.92); }
html.is-dark .bento-search input::placeholder { color: rgba(255,255,255,0.30); }
html.is-dark .bento-search::before { color: rgba(255,255,255,0.40); }

/* Popup BP3 en dark */
html.is-dark .bp3-badge   { color: rgba(255,255,255,0.70); background: rgba(255,255,255,0.10); border-color: rgba(255,255,255,0.08); }
html.is-dark .bp3-title   { color: rgba(255,255,255,0.92); }
html.is-dark .bp3         { background: rgba(10,18,35,0.55); border-color: rgba(255,255,255,0.08); }
html.is-dark .bp3-header  { border-bottom-color: rgba(255,255,255,0.06); }
html.is-dark .bp3-tile    { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.06); }
html.is-dark .bp3-tile:hover { background: rgba(255,255,255,0.13); }
html.is-dark .bp3-tile-label { color: rgba(255,255,255,0.48); }
html.is-dark .bp3-tile-value { color: rgba(255,255,255,0.88); }
html.is-dark .bp3-link    { color: #5eead4 !important; }
html.is-dark .bp3-link:hover { color: #99f6e4 !important; }
html.is-dark .bp3-btn--copy  { background: rgba(0,149,151,0.18); color: rgba(255,255,255,0.72); }
html.is-dark .bp3-btn--copy:hover { background: rgba(0,149,151,0.30); }
html.is-dark .bp3-mss     { color: rgba(255,255,255,0.65) !important; }
html.is-dark .bp3-pill-ouvert  { background: rgba(0,172,200,0.20); color: #7dd3fc; }
html.is-dark .bp3-pill-encours { background: rgba(255,202,111,0.25); color: #f59e0b; }
html.is-dark .bp3-pill-tele    { background: rgba(153,127,209,0.25); color: #c4b5fd; }
html.is-dark .bp3-pill-default { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.55); }
html.is-dark .bp3-pill-default .bp3-sdot { background: rgba(255,255,255,0.4); }

/* ============================================================
   THEME SWITCHER
   ============================================================ */
.theme-switcher {
    padding: 12px 14px;
}
.theme-switcher::before { display: none; } /* pas de glow sur cette tile */

.theme-switcher-inner {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}

.theme-switcher-title {
    font-size: 13px; font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.theme-switcher-btns {
    display: flex; gap: 6px;
}

.theme-btn {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 10px; border-radius: 10px;
    background: var(--item-bg);
    border: 1px solid var(--item-border);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    font-family: 'DM Sans', sans-serif;
}
.theme-btn:hover  { background: var(--item-bg-hover); }
.theme-btn:active { transform: scale(0.96); }
.theme-btn.active {
    background: var(--primary-dim);
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0,149,151,0.15);
}

.theme-btn-icon  { font-size: 13px; line-height: 1; color: var(--text-secondary); }
.theme-btn.active .theme-btn-icon { color: var(--primary); }
.theme-btn-label {
    font-size: 10px; font-weight: 500;
    color: var(--text-secondary);
}
.theme-btn.active .theme-btn-label { color: var(--primary); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .bento-wrapper { width: calc(100% - 24px); left: 12px; top: 12px; }
    .bento-tile { border-radius: 16px; padding: 12px 14px; }
    .bento-action { width: 48px; height: 48px; }
    #site-count { font-size: 26px; }
    .bento-filters.open { max-height: 85vh !important; }
    #suggestions { top: 72px; left: 12px; width: calc(100% - 24px); }
    .bp3-popup .leaflet-popup-content { width: 320px !important; }
    .bp3 { width: 320px; }
}

@media (max-width: 480px) {
    .bento-wrapper { width: calc(100% - 20px); left: 10px; top: 10px; gap: 8px; }
    .bento-tile { border-radius: 14px; padding: 10px 12px; }
    .bento-action { width: 44px; height: 44px; }
    #site-count { font-size: 22px; }
    .bento-search input { font-size: 13px; }
    .filter-item.color-filter, .filter-item.toggle-filter { padding: 10px; gap: 8px; }
    .filter-label { font-size: 11px; }
    .filter-description { font-size: 10px; }
    .toggle-switch { width: 34px; height: 20px; }
    .toggle-switch::after { width: 16px; height: 16px; }
    .filter-item.toggle-filter.active .toggle-switch::after { transform: translateX(14px); }
    .bar { width: 18px; height: 2.5px; }
    .bp3-popup .leaflet-popup-content { width: 300px !important; }
    .bp3 { width: 300px; }
    #suggestions { top: 66px; left: 10px; width: calc(100% - 20px); }
}

@media (max-width: 360px) {
    .bento-wrapper { width: calc(100% - 16px); left: 8px; gap: 6px; }
    .bento-tile { border-radius: 12px; padding: 9px 11px; }
    #site-count { font-size: 20px; }
    .bp3 { width: 280px; }
    .bp3-popup .leaflet-popup-content { width: 280px !important; }
}
