/* ═══════════════════════════════════════════════════════════════════════════
   Thème « verre » commun à toutes les pages.
   Chargé APRÈS les styles propres à chaque page : il redéfinit les variables
   et la surface des composants (cartes, onglets, boutons, modales) sans toucher
   à leur mise en page.
   ═══════════════════════════════════════════════════════════════════════════ */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  color-scheme: light;
  --blue:    #34539e;
  --blue-lt: #4a6bb8;
  --bg:      rgba(255, 255, 255, .45);
  --card:    rgba(255, 255, 255, .55);
  --border:  rgba(255, 255, 255, .7);
  --line:    rgba(100, 116, 139, .16);
  --text:    #0f172a;
  --text-lt: #4f5869;

  --glass-blur:   blur(20px) saturate(170%);
  --glass-shadow: 0 1px 0 rgba(255,255,255,.75) inset,
                  0 10px 30px -12px rgba(30, 41, 99, .18),
                  0 2px 6px -2px rgba(30, 41, 99, .06);
  --radius: 20px;
}

/* ── Fond : dégradé « mesh » fixe derrière le verre ─────────────────────── */
html { background: #f3f4f7; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: transparent;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  position: relative;
}
body::before {
  content: ""; position: fixed; inset: -10vmax; z-index: -1; pointer-events: none;
  background:
    radial-gradient(38vmax 38vmax at 12% 8%,  rgba(110, 135, 210, .24), transparent 60%),
    radial-gradient(34vmax 34vmax at 88% 12%, rgba(160, 130, 210, .18), transparent 60%),
    radial-gradient(40vmax 40vmax at 78% 88%, rgba(100, 180, 170, .17), transparent 60%),
    radial-gradient(36vmax 36vmax at 8% 92%,  rgba(210, 160, 135, .14), transparent 60%),
    linear-gradient(160deg, #f5f6f9 0%, #f2f4f7 50%, #f5f4f7 100%);
  animation: mesh-drift 40s ease-in-out infinite alternate;
}
@keyframes mesh-drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(-3vmax, 2vmax, 0) scale(1.06); }
}
@media (prefers-reduced-motion: reduce) { body::before { animation: none; } }

/* Surface vitrée réutilisée */
.topbar, .filters, .period-banner,
.card, .kpi, .kpi-card, .chart-card, .alert-banner {
  background: var(--card);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  box-shadow: var(--glass-shadow);
}

/* ── En-tête + onglets : barre flottante collante ───────────────────────── */
.topbar {
  position: sticky; top: .75rem; z-index: 200;
  margin: .75rem auto 0; max-width: calc(1400px - 3rem); width: calc(100% - 3rem);
  border-radius: var(--radius);
}
header, .tabs { background: transparent; border: none; }
header {
  color: var(--text);
  padding: .85rem 1.25rem .45rem;
}
header .logo { font-weight: 800; letter-spacing: -.03em; }
header .logo span {
  color: var(--blue);
}
header .subtitle { opacity: 1; color: var(--text-lt); font-weight: 500; }

.tabs {
  padding: .2rem .75rem .7rem;
  gap: .3rem; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 1px solid transparent; border-bottom: 1px solid transparent;
  border-radius: 999px;
  padding: .5rem 1rem;
  color: var(--text-lt); font-weight: 500;
}
.tab:hover { background: rgba(255,255,255,.55); color: var(--text); }
.tab.active {
  background: rgba(255,255,255,.92);
  border-color: rgba(255,255,255,.95);
  border-bottom-color: rgba(255,255,255,.95);
  color: var(--blue); font-weight: 600;
  box-shadow: 0 2px 8px -4px rgba(30, 41, 70, .2), 0 1px 0 #fff inset;
}

/* ── Contenu ─────────────────────────────────────────────────────────────── */
main { padding-top: 1.25rem; }

.filters {
  max-width: calc(1400px - 3rem); width: calc(100% - 3rem);
  margin: 1rem auto 0; border-radius: var(--radius);
}

.card, .kpi, .chart-card { border-radius: var(--radius); }
.card h3, .chart-card h3, .kpi .kpi-label { color: var(--text-lt); letter-spacing: .06em; }

.kpi .kpi-value { letter-spacing: -.02em; }

/* Cartes par catégorie : halo teinté de la couleur de la catégorie */
.kpi-card {
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  border-top: 1px solid var(--border);
  background:
    radial-gradient(120% 80% at 0% 0%,
      color-mix(in srgb, var(--cat-color, var(--blue)) 11%, transparent), transparent 60%),
    var(--card);
}
.kpi-card::before {
  content: ""; position: absolute; left: 1.25rem; right: 1.25rem; top: 0; height: 3px;
  border-radius: 0 0 4px 4px;
  background: var(--cat-color, var(--blue));
}
.kpi-icon {
  display: inline-grid; place-items: center;
  width: 2.1rem; height: 2.1rem; border-radius: 12px;
  background: color-mix(in srgb, var(--cat-color, var(--blue)) 12%, rgba(255,255,255,.7));
  border: 1px solid rgba(255,255,255,.8);
  font-size: 1.1rem;
}
.kpi-main { letter-spacing: -.03em; font-weight: 800; }
.kpi-comp-row { border-bottom-color: var(--line); }
.kpi-completion { border-top-color: var(--line); }

.section-title { color: var(--text-lt); }
.section-title::after {
  background: linear-gradient(90deg, rgba(100,116,139,.25), transparent);
}

.period-banner {
  border-radius: var(--radius);
  border-left: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.period-banner::before {
  content: ""; position: absolute; left: 0; top: .7rem; bottom: .7rem; width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--blue);
}

/* ── Pastilles, boutons, champs ─────────────────────────────────────────── */
.period-badge, .alert-cur-val {
  background: rgba(255,255,255,.6); border: 1px solid rgba(255,255,255,.85);
}
.filter-btn, .toggle-btn, .period-edit-btn, .pb-reset-btn, .btn-ghost, .btn-test,
#acti-input, .pb-sel-group select, .alert-field select, .alert-field input[type="number"] {
  background: rgba(255,255,255,.55);
  border: 1px solid rgba(255,255,255,.85);
  box-shadow: 0 1px 2px rgba(30,41,99,.06);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.filter-btn:hover, .toggle-btn:hover, .period-edit-btn:hover, .btn-ghost:hover, .btn-test:hover {
  background: rgba(255,255,255,.85); border-color: #fff;
}
#acti-input:focus, .pb-sel-group select:focus,
.alert-field select:focus, .alert-field input:focus {
  border-color: var(--blue-lt);
  box-shadow: 0 0 0 3px rgba(61,90,153,.15);
}
.filter-btn.active, .toggle-btn.active, .btn-primary, .pb-apply-btn, .acti-chip {
  background: var(--blue);
  border-color: transparent; color: #fff;
  box-shadow: 0 2px 6px -2px rgba(30,41,70,.3), 0 1px 0 rgba(255,255,255,.2) inset;
}
.btn-primary:hover { background: var(--blue-lt); }
.filter-btn[data-nature="Requete"].active     { background: #3f6fb0; }
.filter-btn[data-nature="Plainte"].active     { background: #b4483f; }
.filter-btn[data-nature="Commentaire"].active { background: #3a8a62; }

.trend.better  { background: rgba(58,138,98,.15); color: #2c6b4c; }
.trend.worse   { background: rgba(180,72,63,.14);  color: #93352e; }
.trend.neutral { background: rgba(100,116,139,.12); }

.notif-btn {
  background: rgba(255,255,255,.6); border: 1px solid rgba(255,255,255,.9);
  color: var(--text); font-weight: 500;
}
.notif-btn:hover { background: rgba(255,255,255,.9); }

/* ── Listes déroulantes, bannières, modales ─────────────────────────────── */
#acti-dropdown {
  background: rgba(255,255,255,.82);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: 1px solid #fff; border-radius: 16px;
  box-shadow: 0 20px 40px -12px rgba(30,41,99,.25);
}
.acti-item { border-bottom-color: var(--line); }
.acti-item:hover { background: rgba(61,90,153,.06); }

.alert-banner {
  background: color-mix(in srgb, var(--cat-color, #b5545c) 7%, rgba(255,255,255,.6));
  border-left: 1px solid var(--border); border-radius: 14px;
}

.modal-overlay {
  background: rgba(15, 23, 42, .25);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.modal {
  background: rgba(255,255,255,.78);
  -webkit-backdrop-filter: blur(28px) saturate(180%); backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid #fff; border-radius: 24px;
  box-shadow: 0 30px 80px -20px rgba(30,41,99,.4);
}
.modal-header, .modal-footer { background: rgba(255,255,255,.7); border-color: var(--line); }
.modal-header { border-radius: 24px 24px 0 0; }
.modal-footer { border-radius: 0 0 24px 24px; }
.alert-card { border: 1px solid rgba(255,255,255,.9); border-radius: 16px; background: rgba(255,255,255,.45); }
.alert-card-header { background: color-mix(in srgb, var(--cat-color, var(--blue)) 5%, rgba(255,255,255,.5)); }
.notif-note { background: rgba(255,255,255,.55); border: 1px solid rgba(255,255,255,.85); }

#loading {
  background: rgba(238, 241, 250, .55);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
.spinner { border-color: rgba(100,116,139,.2); border-top-color: var(--blue); }

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .topbar, .filters { width: calc(100% - 1.5rem); }
  .topbar { position: relative; top: 0; margin-top: .5rem; }
  header { padding: .7rem 1rem .35rem; }
  header .subtitle { margin-left: 0; width: 100%; order: 3; font-size: .75rem; }
  .tabs { padding: .15rem .5rem .6rem; }
  .tab { padding: .45rem .8rem; font-size: .8rem; }
  .filters { margin-top: .75rem; }
}

/* Le verre crée un contexte d'empilement : on garde la barre de filtres
   (et sa liste d'autocomplétion) au-dessus des cartes qui suivent. */
.filters { position: relative; z-index: 150; }
