/* =====================================================================
   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;
  }
}
