/* =====================================================================
   SURVOEIL v29.16 — Liquid Glass iOS 26
   ---------------------------------------------------------------------
   Inspiré du design system « Liquid Glass » introduit par Apple avec
   iOS 26 (WWDC 2025) : matériau vitré dynamique, double couche
   (highlight intérieur + ombre douce), reflet supérieur, légère
   réfraction via backdrop-filter, micro-animation au survol / appui.

   - Arrière-plan global : reste clair, mais NON-blanc (lavande/azur
     pastel) avec la bannière de marque qui transparaît derrière.
   - Tous les boutons (.btn, .btn-primary, .btn-secondary, .btn-outline,
     .btn-danger, .btn-success, .admin-tab-button, .sidebar-nav button,
     boutons natifs <button>) reçoivent l'effet Liquid Glass.
   - Variante « assertive » (primary / danger / success) conserve la
     couleur d'accent mais derrière une couche translucide vitrée.
   ===================================================================== */

/* ---------- 1) ARRIÈRE-PLAN CLAIR, NON BLANC ---------- */

/* On éclaircit franchement l'image de marque en mode clair pour qu'elle
   reste lisible mais bien visible. */
body::before {
  /* L'opacité par défaut était 0.32 — on garde mais on retire le
     filtre desaturating pour conserver la chaleur de l'image. */
  opacity: 0.42 !important;
  filter: saturate(1.15) brightness(1.08) !important;
}

/* On remplace le voile presque-blanc (rgba(255,255,255,.55→.88)) par
   un voile pastel azur/lavande/menthe : clair, lumineux, mais
   reconnaissablement coloré. */
body::after {
  background: linear-gradient(
    140deg,
    rgba(214, 230, 255, 0.78) 0%,
    rgba(226, 220, 248, 0.72) 35%,
    rgba(218, 240, 235, 0.74) 70%,
    rgba(206, 224, 252, 0.80) 100%
  ) !important;
}

/* Mode sombre : on ne touche pas au voile sombre existant. */
@media (prefers-color-scheme: dark) {
  body::before {
    opacity: 0.46 !important;
    filter: saturate(1.2) brightness(1.05) contrast(1.05) !important;
  }
}

/* Pour que le texte reste lisible sur fond pastel clair, on force
   une couleur de texte plus sombre quand le système est en clair. */
@media (prefers-color-scheme: light) {
  :root {
    --text: #0f1b2e;
    --muted: #4d5b73;
  }
  /* Cartes / panels : un voile blanc translucide */
  .form-card, .card, .panel, .alert, .table-card, .qr-card {
    background: rgba(255, 255, 255, 0.55) !important;
    backdrop-filter: blur(18px) saturate(1.4) !important;
    -webkit-backdrop-filter: blur(18px) saturate(1.4) !important;
    border: 1px solid rgba(255, 255, 255, 0.6) !important;
    color: var(--text);
  }
  .main-header {
    background: rgba(255, 255, 255, 0.55) !important;
    backdrop-filter: blur(20px) saturate(1.4) !important;
    -webkit-backdrop-filter: blur(20px) saturate(1.4) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.7);
  }
}

/* ---------- 2) LIQUID GLASS — VARIABLES & KEYFRAMES ---------- */

:root {
  --lg-radius: 16px;
  --lg-blur: 22px;
  --lg-saturate: 1.6;
  --lg-tint: rgba(255, 255, 255, 0.22);
  --lg-tint-strong: rgba(255, 255, 255, 0.32);
  --lg-border: rgba(255, 255, 255, 0.42);
  --lg-border-inner: rgba(255, 255, 255, 0.55);
  --lg-shadow:
    0 1px 0 rgba(255, 255, 255, 0.55) inset,           /* reflet haut */
    0 -1px 0 rgba(255, 255, 255, 0.18) inset,          /* reflet bas */
    0 8px 24px rgba(15, 27, 46, 0.18),                 /* ombre douce */
    0 2px 6px rgba(15, 27, 46, 0.10);
  --lg-highlight: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.55) 0%,
    rgba(255, 255, 255, 0.15) 35%,
    rgba(255, 255, 255, 0.00) 60%,
    rgba(255, 255, 255, 0.08) 100%
  );
}

@media (prefers-color-scheme: dark) {
  :root {
    --lg-tint: rgba(255, 255, 255, 0.10);
    --lg-tint-strong: rgba(255, 255, 255, 0.18);
    --lg-border: rgba(255, 255, 255, 0.18);
    --lg-border-inner: rgba(255, 255, 255, 0.24);
    --lg-shadow:
      0 1px 0 rgba(255, 255, 255, 0.22) inset,
      0 -1px 0 rgba(0, 0, 0, 0.35) inset,
      0 10px 26px rgba(0, 0, 0, 0.45),
      0 2px 8px rgba(0, 0, 0, 0.28);
    --lg-highlight: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.22) 0%,
      rgba(255, 255, 255, 0.05) 35%,
      rgba(255, 255, 255, 0.00) 60%,
      rgba(255, 255, 255, 0.03) 100%
    );
  }
}

@keyframes lg-shimmer {
  0%   { transform: translateX(-120%); opacity: 0; }
  35%  { opacity: 0.9; }
  100% { transform: translateX(220%); opacity: 0; }
}

/* ---------- 3) APPLICATION GLOBALE AUX BOUTONS ---------- */

/* Sélecteur agrégé : tous les boutons du site. */
.btn,
.btn-primary,
.btn-secondary,
.btn-outline,
.btn-danger,
.btn-success,
.btn-sm,
.admin-tab-button,
.sidebar-nav button,
.main-nav a,
.mobile-nav a,
.sidebar-nav a,
.tab-switcher button,
button.icon-btn,
button[type="button"],
button[type="submit"],
button[type="reset"] {
  position: relative;
  isolation: isolate;
  background: var(--lg-tint);
  backdrop-filter: blur(var(--lg-blur)) saturate(var(--lg-saturate));
  -webkit-backdrop-filter: blur(var(--lg-blur)) saturate(var(--lg-saturate));
  border: 1px solid var(--lg-border);
  border-radius: var(--lg-radius);
  box-shadow: var(--lg-shadow);
  color: var(--text);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
  transition:
    transform .22s cubic-bezier(.2, .7, .2, 1),
    box-shadow .22s ease,
    background .22s ease,
    border-color .22s ease;
  overflow: hidden;
}

/* Reflet supérieur (top highlight) — couche pseudo-élément */
.btn::before,
.admin-tab-button::before,
.sidebar-nav button::before,
.main-nav a::before,
.tab-switcher button::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--lg-highlight);
  pointer-events: none;
  z-index: 0;
  mix-blend-mode: screen;
}

/* Tout le contenu (icône + texte) au-dessus des couches glass */
.btn > *,
.admin-tab-button > *,
.sidebar-nav button > *,
.main-nav a > *,
.tab-switcher button > * {
  position: relative;
  z-index: 1;
}

/* Reflet liquide animé qui balaye le bouton au survol */
.btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 40%;
  height: 100%;
  background: linear-gradient(
    115deg,
    transparent 0%,
    rgba(255, 255, 255, 0.45) 50%,
    transparent 100%
  );
  transform: translateX(-120%);
  pointer-events: none;
  z-index: 0;
}

.btn:hover::after {
  animation: lg-shimmer 1.1s ease forwards;
}

/* ---------- 4) ÉTAT HOVER / ACTIVE / FOCUS ---------- */

.btn:hover,
.admin-tab-button:hover,
.sidebar-nav button:hover,
.main-nav a:hover,
.tab-switcher button:hover {
  background: var(--lg-tint-strong);
  border-color: var(--lg-border-inner);
  transform: translateY(-1.5px) scale(1.012);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.65) inset,
    0 -1px 0 rgba(255, 255, 255, 0.22) inset,
    0 14px 32px rgba(15, 27, 46, 0.22),
    0 4px 10px rgba(15, 27, 46, 0.12);
}

.btn:active,
.admin-tab-button:active,
.sidebar-nav button:active,
.tab-switcher button:active {
  transform: translateY(0) scale(0.985);
  transition-duration: .12s;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 0 0 rgba(0, 0, 0, 0) inset,
    0 4px 10px rgba(15, 27, 46, 0.14);
}

.btn:focus-visible,
.admin-tab-button:focus-visible,
.sidebar-nav button:focus-visible {
  outline: none;
  border-color: rgba(120, 170, 255, 0.85);
  box-shadow:
    0 0 0 3px rgba(120, 170, 255, 0.30),
    var(--lg-shadow);
}

/* ---------- 5) VARIANTES COLORÉES (gardent l'accent) ---------- */

/* Primary : bleu Apple-style, mais derrière du verre */
.btn-primary {
  background:
    linear-gradient(135deg, rgba(59, 130, 246, 0.78), rgba(107, 168, 255, 0.72)),
    var(--lg-tint);
  border-color: rgba(255, 255, 255, 0.55);
  color: #ffffff;
  text-shadow: 0 1px 0 rgba(0, 30, 80, 0.25);
}
.btn-primary:hover {
  background:
    linear-gradient(135deg, rgba(59, 130, 246, 0.88), rgba(107, 168, 255, 0.82)),
    var(--lg-tint-strong);
}

/* Danger : rouge corail vitré */
.btn-danger {
  background:
    linear-gradient(135deg, rgba(255, 93, 93, 0.62), rgba(255, 130, 130, 0.55)),
    var(--lg-tint);
  border-color: rgba(255, 255, 255, 0.50);
  color: #ffffff;
  text-shadow: 0 1px 0 rgba(110, 0, 0, 0.25);
}
.btn-danger:hover {
  background:
    linear-gradient(135deg, rgba(255, 93, 93, 0.78), rgba(255, 130, 130, 0.70)),
    var(--lg-tint-strong);
}

/* Success : vert menthe vitré */
.btn-success {
  background:
    linear-gradient(135deg, rgba(29, 191, 115, 0.62), rgba(94, 224, 158, 0.55)),
    var(--lg-tint);
  border-color: rgba(255, 255, 255, 0.50);
  color: #ffffff;
  text-shadow: 0 1px 0 rgba(0, 70, 35, 0.25);
}
.btn-success:hover {
  background:
    linear-gradient(135deg, rgba(29, 191, 115, 0.78), rgba(94, 224, 158, 0.72)),
    var(--lg-tint-strong);
}

/* Secondary / Outline : verre pur, sans accent coloré */
.btn-secondary,
.btn-outline {
  background: var(--lg-tint);
  color: var(--text);
}
.btn-secondary:hover,
.btn-outline:hover {
  background: var(--lg-tint-strong);
}

/* ---------- 6) ONGLETS & NAVIGATION (état actif) ---------- */

.main-nav a.active,
.sidebar-nav a.active,
.sidebar-nav button.active,
.admin-tab-button.active,
.tab-switcher button.active {
  background:
    linear-gradient(135deg, rgba(59, 130, 246, 0.55), rgba(107, 168, 255, 0.48)),
    var(--lg-tint-strong) !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.55) !important;
  text-shadow: 0 1px 0 rgba(0, 30, 80, 0.3);
}

/* ---------- 7) FALLBACK pour navigateurs sans backdrop-filter ---------- */

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .btn,
  .admin-tab-button,
  .sidebar-nav button,
  .main-nav a,
  .tab-switcher button {
    background: rgba(255, 255, 255, 0.65);
  }
  @media (prefers-color-scheme: dark) {
    .btn,
    .admin-tab-button,
    .sidebar-nav button,
    .main-nav a,
    .tab-switcher button {
      background: rgba(30, 45, 70, 0.75);
    }
  }
}

/* ---------- 8) Respecte « prefers-reduced-motion » ---------- */

@media (prefers-reduced-motion: reduce) {
  .btn,
  .admin-tab-button,
  .sidebar-nav button,
  .main-nav a,
  .tab-switcher button {
    transition: none;
  }
  .btn::after { display: none; }
  .btn:hover,
  .admin-tab-button:hover,
  .sidebar-nav button:hover {
    transform: none;
  }
}

/* =====================================================================
   SURVOEIL v29.17 — Correctifs UX
   ---------------------------------------------------------------------
   1) MODE SOMBRE (page d'accueil) : reprendre EXACTEMENT la composition
      visuelle du mode clair (image de marque douce, voile dégradé
      pastel, cartes vitrées translucides, texte lisible), mais avec
      la palette propre au mode sombre (bleu nuit / indigo profond /
      vert sapin) à la place du pastel azur / lavande / menthe.

   2) ESPACE OPÉRATEUR : restaurer les couleurs d'origine sur les
      quatre boutons d'action du formulaire de saisie :
        • « + Ajouter au rapport »            → bleu primaire (gradient)
        • « Enregistrer le rapport final »    → vert succès
        • « Réinitialiser la saisie »         → contour neutre
        • « Vider le brouillon »              → rouge danger
      Le matériau Liquid Glass appliqué globalement par v29.16
      gommait leur identité colorée — on désactive ici le voile
      générique sur ces 4 boutons précisément (ciblés par id) tout
      en gardant l'animation de hover.
   ===================================================================== */

/* ---------- 1) MODE SOMBRE — ACCUEIL : miroir du mode clair ---------- */

@media (prefers-color-scheme: dark) {

  /* Image de marque : on calque sur les valeurs douces du mode clair
     (opacité 0.22, brightness 1.08) au lieu de l'image très visible
     actuelle, pour le même rendu apaisé. */
  body[data-page="home"]::before {
    opacity: 0.22 !important;
    filter: saturate(1.05) brightness(1.08) !important;
  }

  /* Voile en dégradé — même composition pastel à 4 stops que le mode
     clair, mais transposée dans la palette nuit (bleu nuit, indigo
     profond, vert sapin sombre, bleu marine). On garde des opacités
     hautes (0.72 → 0.80) pour le même effet de calque cohérent. */
  body[data-page="home"]::after {
    background: linear-gradient(
      140deg,
      rgba(14, 22, 40, 0.78)  0%,
      rgba(22, 18, 46, 0.72)  35%,
      rgba(16, 32, 30, 0.74)  70%,
      rgba(10, 20, 42, 0.82)  100%
    ) !important;
  }

  /* Adaptation responsive (mobile) — même logique que le mode clair */
  @media (max-width: 820px) {
    body[data-page="home"]::before {
      opacity: 0.20 !important;
    }
  }

  /* Cartes / panels / header : voile translucide sombre avec
     backdrop-filter, exactement comme en mode clair (rgba blanc 0.55
     + blur 18-20) mais en rgba noir/nuit 0.42. */
  body[data-page="home"] .form-card,
  body[data-page="home"] .card,
  body[data-page="home"] .panel,
  body[data-page="home"] .alert,
  body[data-page="home"] .table-card,
  body[data-page="home"] .qr-card,
  body[data-page="home"] .hero-panel,
  body[data-page="home"] .site-card,
  body[data-page="home"] .install-strip {
    background: rgba(14, 20, 36, 0.55) !important;
    backdrop-filter: blur(18px) saturate(1.4) !important;
    -webkit-backdrop-filter: blur(18px) saturate(1.4) !important;
    border: 1px solid rgba(255, 255, 255, 0.10) !important;
    color: var(--text);
  }
  body[data-page="home"] .main-header {
    background: rgba(10, 16, 28, 0.55) !important;
    backdrop-filter: blur(20px) saturate(1.4) !important;
    -webkit-backdrop-filter: blur(20px) saturate(1.4) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  }

  /* Tagline « voir · analyser · protéger » — on garde la teinte claire
     d'origine du mode sombre, mais on remonte légèrement le contraste
     pour qu'elle se détache aussi bien que sur fond pastel clair. */
  body[data-page="home"] .hero-tagline-brand {
    color: #d9e5fb;
    opacity: 0.96;
  }
}

/* ---------- 2) ESPACE OPÉRATEUR — couleurs d'origine sur les 4
              boutons d'action (Ajouter / Enregistrer / Réinitialiser
              / Vider le brouillon).
              On surcharge la couche Liquid Glass globale uniquement
              sur ces 4 boutons précis, pour retrouver leur identité
              colorée historique. ---------- */

body[data-page="operateur"] #operatorDraftAddBtn,
body[data-page="operateur"] #operatorDraftFinalizeBtn,
body[data-page="operateur"] #operatorReportReset,
body[data-page="operateur"] #operatorDraftClearBtn {
  /* On retire le voile vitré générique de v29.16 */
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  text-shadow: none !important;
  border-radius: 14px !important;
  overflow: visible !important;
  isolation: auto !important;
  transition: transform .2s ease, box-shadow .2s ease,
              background .2s ease, border-color .2s ease,
              filter .2s ease !important;
}

/* Reflet supérieur + halo animé : on les neutralise pour ces 4 boutons,
   sinon le shimmer blanc continue de masquer la couleur d'accent. */
body[data-page="operateur"] #operatorDraftAddBtn::before,
body[data-page="operateur"] #operatorDraftFinalizeBtn::before,
body[data-page="operateur"] #operatorReportReset::before,
body[data-page="operateur"] #operatorDraftClearBtn::before,
body[data-page="operateur"] #operatorDraftAddBtn::after,
body[data-page="operateur"] #operatorDraftFinalizeBtn::after,
body[data-page="operateur"] #operatorReportReset::after,
body[data-page="operateur"] #operatorDraftClearBtn::after {
  content: none !important;
  display: none !important;
  background: none !important;
  animation: none !important;
}

/* « + Ajouter au rapport » → btn-primary, dégradé bleu d'origine */
body[data-page="operateur"] #operatorDraftAddBtn {
  background: linear-gradient(135deg, #2f7df6, #5aa0ff) !important;
  border: 1px solid rgba(47, 125, 246, 0.45) !important;
  color: #ffffff !important;
  box-shadow: 0 10px 24px rgba(47, 125, 246, 0.28) !important;
}
body[data-page="operateur"] #operatorDraftAddBtn:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(47, 125, 246, 0.34) !important;
}

/* « Enregistrer le rapport final » → btn-success, vert d'origine */
body[data-page="operateur"] #operatorDraftFinalizeBtn {
  background: rgba(29, 191, 115, 0.14) !important;
  border: 1px solid rgba(29, 191, 115, 0.40) !important;
  color: #8af2bc !important;
  box-shadow: 0 6px 18px rgba(29, 191, 115, 0.12) !important;
}
body[data-page="operateur"] #operatorDraftFinalizeBtn:hover {
  background: rgba(29, 191, 115, 0.22) !important;
  border-color: rgba(29, 191, 115, 0.55) !important;
  transform: translateY(-1px);
}

/* « Réinitialiser la saisie » → btn-outline, contour neutre d'origine */
body[data-page="operateur"] #operatorReportReset {
  background: transparent !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  color: var(--text) !important;
  box-shadow: none !important;
}
body[data-page="operateur"] #operatorReportReset:hover {
  background: rgba(255, 255, 255, 0.05) !important;
  border-color: rgba(255, 255, 255, 0.28) !important;
  transform: translateY(-1px);
}

/* « Vider le brouillon » → btn-danger, rouge d'origine */
body[data-page="operateur"] #operatorDraftClearBtn {
  background: rgba(255, 93, 93, 0.14) !important;
  border: 1px solid rgba(255, 93, 93, 0.40) !important;
  color: #ffd1d1 !important;
  box-shadow: 0 6px 18px rgba(255, 93, 93, 0.10) !important;
}
body[data-page="operateur"] #operatorDraftClearBtn:hover {
  background: rgba(255, 93, 93, 0.22) !important;
  border-color: rgba(255, 93, 93, 0.55) !important;
  transform: translateY(-1px);
}

/* Mode clair : on ajuste les teintes outline / success / danger pour
   rester lisible sur fond pastel clair. */
@media (prefers-color-scheme: light) {
  body[data-page="operateur"] #operatorDraftFinalizeBtn {
    background: rgba(22, 163, 74, 0.12) !important;
    border-color: rgba(22, 163, 74, 0.45) !important;
    color: #166534 !important;
  }
  body[data-page="operateur"] #operatorDraftFinalizeBtn:hover {
    background: rgba(22, 163, 74, 0.20) !important;
  }
  body[data-page="operateur"] #operatorReportReset {
    border-color: rgba(15, 27, 46, 0.18) !important;
    color: #0f1b2e !important;
  }
  body[data-page="operateur"] #operatorReportReset:hover {
    background: rgba(15, 27, 46, 0.06) !important;
    border-color: rgba(15, 27, 46, 0.32) !important;
  }
  body[data-page="operateur"] #operatorDraftClearBtn {
    background: rgba(220, 38, 38, 0.10) !important;
    border-color: rgba(220, 38, 38, 0.45) !important;
    color: #b91c1c !important;
  }
  body[data-page="operateur"] #operatorDraftClearBtn:hover {
    background: rgba(220, 38, 38, 0.18) !important;
  }
}
