/* Grizee — Design System v2 */

/* ── LIGHT MODE ──────────────────────────────────────────── */
/* html[data-theme] spécificité (0,1,1) > :root (0,1,0) → variables light gagnent */
html[data-theme="light"] {
  /* Backgrounds clairs */
  --navy:    #f0f4f8;
  --navy2:   #ffffff;
  --navy3:   #e8edf3;
  --navy4:   #d1dae6;


  --white:   #0a0f1e;
  --text:    #0f172a;
  --muted:   #1e293b;
  --faint:   #334155;

  --glass:        rgba(255,255,255,.9);
  --glass-hover:  rgba(255,255,255,1);
  --glass-active: rgba(249,115,22,.1);
  --border:       rgba(15,23,42,.12);
  --border-hover: rgba(249,115,22,.6);

  --gray-50:  #f8fafc; --gray-100: #f1f5f9; --gray-200: #e2e8f0;
  --gray-300: #1e293b; --gray-400: #1e293b; --gray-500: #1e293b;
  --gray-600: #111827; --gray-700: #0f172a; --gray-900: #030712;
  --text-muted:   #1e293b;
  --border-solid: rgba(15,23,42,.12);
  --glass-bg:     rgba(255,255,255,.9);
  --glass-border: 1px solid rgba(15,23,42,.1);
  --glass-shadow: 0 4px 20px rgba(15,23,42,.08);
  --shadow-sm:    0 1px 4px rgba(15,23,42,.08);
  --shadow:       0 4px 16px rgba(15,23,42,.1);
  --shadow-md:    0 8px 32px rgba(15,23,42,.12);
  --bg:       #f0f4f8;
  --surface:  rgba(255,255,255,.9);
  --card:     rgba(255,255,255,.9);
  --hover:    rgba(15,23,42,.06);
}

[data-theme="light"] body {
  background: #f0f4f8;
  background-image:
    radial-gradient(ellipse 80% 60% at 10% 5%,  rgba(249,115,22,.05) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 90% 95%, rgba(59,130,246,.04) 0%, transparent 55%);
  color: #0f172a;
}

/* Sidebar reste dark en light mode — les textes doivent rester clairs */
[data-theme="light"] .sidebar {
  background: #1e293b;
}
[data-theme="light"] .nav-item        { color: rgba(255,255,255,.55); }
[data-theme="light"] .nav-item:hover  { color: #fff; }
[data-theme="light"] .nav-item.active { color: var(--orange); }
[data-theme="light"] .nav-icon        { color: rgba(255,255,255,.45); }
[data-theme="light"] .nav-section     { color: rgba(255,255,255,.3); }
[data-theme="light"] .sidebar-footer .user-name { color: #fff; }
[data-theme="light"] .sidebar-footer a { color: rgba(255,255,255,.4) !important; }

[data-theme="light"] .top-bar {
  background: rgba(255,255,255,.9);
  border-bottom: 1px solid rgba(15,23,42,.1);
}

[data-theme="light"] .top-bar-title { color: #0f172a; }

[data-theme="light"] .card {
  background: rgba(255,255,255,.95);
  border-color: rgba(15,23,42,.1);
  box-shadow: 0 2px 12px rgba(15,23,42,.08);
}

[data-theme="light"] .stat-card {
  background: rgba(255,255,255,.95);
  border-color: rgba(15,23,42,.1);
  box-shadow: 0 2px 8px rgba(15,23,42,.06);
}

[data-theme="light"] .form-control {
  background: #fff;
  border-color: rgba(15,23,42,.25);
  color: #1e293b;
  box-shadow: 0 1px 3px rgba(15,23,42,.06);
}
/* Inputs spécifiques services en light */
[data-theme="light"] .svc-input,
[data-theme="light"] .svc-select,
[data-theme="light"] .prefill-input,
[data-theme="light"] .new-name-input,
[data-theme="light"] .setup-search input {
  background: #fff !important;
  border-color: rgba(15,23,42,.25) !important;
  color: #1e293b !important;
  box-shadow: 0 1px 3px rgba(15,23,42,.06);
}
[data-theme="light"] .form-control::placeholder { color: #94a3b8; }
[data-theme="light"] .form-control:focus {
  background: #fff;
  border-color: var(--orange);
}

[data-theme="light"] thead th {
  background: rgba(15,23,42,.03);
  color: #475569;
  border-bottom: 1px solid rgba(15,23,42,.1);
}
[data-theme="light"] tbody td { color: #1e293b; border-bottom-color: rgba(15,23,42,.06); }
[data-theme="light"] tbody tr:hover { background: rgba(249,115,22,.07); }
[data-theme="light"] tbody tr:hover td { color: #0f172a; }
[data-theme="light"] .table-wrap { border-color: rgba(15,23,42,.1); }

[data-theme="light"] .modal { background: #fff; border-color: rgba(15,23,42,.12); }
[data-theme="light"] .tabs { border-bottom-color: rgba(15,23,42,.12); }
[data-theme="light"] .divider { background: rgba(15,23,42,.1); }
[data-theme="light"] .badge-gray { background: rgba(15,23,42,.07); color: #475569; border-color: rgba(15,23,42,.12); }
[data-theme="light"] .section-title { color: #64748b; }

/* ── DARK MODE — override automatique des couleurs hardcodées light ──────
   Ces couleurs sont conçues pour fond clair. En dark elles sont invisibles.
   Les attribute selectors CSS ciblent les inline styles directement.    */

/* Textes très sombres (conçus pour fond blanc) → version claire en dark */
:root:not([data-theme="light"]) [style*="color:#065f46"] { color: #4ade80 !important; }
:root:not([data-theme="light"]) [style*="color:#166534"] { color: #4ade80 !important; }
:root:not([data-theme="light"]) [style*="color:#1e40af"] { color: #93c5fd !important; }
:root:not([data-theme="light"]) [style*="color:#1E40AF"] { color: #93c5fd !important; }
:root:not([data-theme="light"]) [style*="color:#6d28d9"] { color: #c4b5fd !important; }
:root:not([data-theme="light"]) [style*="color:#6D28D9"] { color: #c4b5fd !important; }
:root:not([data-theme="light"]) [style*="color:#92400e"] { color: #fcd34d !important; }
:root:not([data-theme="light"]) [style*="color:#92400E"] { color: #fcd34d !important; }
:root:not([data-theme="light"]) [style*="color:#7c3aed"] { color: #c4b5fd !important; }
:root:not([data-theme="light"]) [style*="color:#374151"] { color: var(--text) !important; }
:root:not([data-theme="light"]) [style*="color:#111827"] { color: var(--white) !important; }
:root:not([data-theme="light"]) [style*="color:#1f2937"] { color: var(--white) !important; }
:root:not([data-theme="light"]) [style*="color:#6b7280"] { color: var(--muted) !important; }
:root:not([data-theme="light"]) [style*="color:#6B7280"] { color: var(--muted) !important; }

/* Fonds très clairs (conçus pour light) → version translucide dark */
:root:not([data-theme="light"]) [style*="background:#f0fdf4"] { background: rgba(34,197,94,.1) !important; border-color: rgba(34,197,94,.2) !important; }
:root:not([data-theme="light"]) [style*="background:#eff6ff"] { background: rgba(59,130,246,.1) !important; border-color: rgba(59,130,246,.2) !important; }
:root:not([data-theme="light"]) [style*="background:#faf5ff"] { background: rgba(139,92,246,.1) !important; border-color: rgba(139,92,246,.2) !important; }
:root:not([data-theme="light"]) [style*="background:#fef3c7"],
:root:not([data-theme="light"]) [style*="background:#FEF3C7"] { background: rgba(245,158,11,.1) !important; border-color: rgba(245,158,11,.2) !important; }
:root:not([data-theme="light"]) [style*="background:#fef2f2"],
:root:not([data-theme="light"]) [style*="background:#FEF2F2"] { background: rgba(239,68,68,.1) !important; }
:root:not([data-theme="light"]) [style*="background:#f9fafb"],
:root:not([data-theme="light"]) [style*="background:#FAFBFF"] { background: rgba(255,255,255,.04) !important; }
:root:not([data-theme="light"]) [style*="background:#eef2ff"],
:root:not([data-theme="light"]) [style*="background:#EEF2FF"] { background: rgba(99,102,241,.12) !important; border-color: rgba(99,102,241,.2) !important; }

/* LIGHT MODE — textes qui utilisent var(--navy) comme couleur → rendre sombres */
[data-theme="light"] [style*="color:var(--navy)"]  { color: #0f172a !important; }
[data-theme="light"] [style*="color: var(--navy)"] { color: #0f172a !important; }

/* Auth en light mode */
[data-theme="light"] .auth-page { background: #e8eef5; }
[data-theme="light"] .auth-box  { background:#fff; border-color:rgba(15,23,42,.12); box-shadow:0 8px 40px rgba(15,23,42,.12); }
[data-theme="light"] .auth-logo h1 { color:#0f172a; }
[data-theme="light"] .auth-logo p  { color:#475569; }

/* Textes en light mode */
[data-theme="light"] h1,[data-theme="light"] h2,[data-theme="light"] h3 { color:#0f172a; }
[data-theme="light"] p { color:#334155; }
[data-theme="light"] .text-muted  { color:#334155; }
[data-theme="light"] .card-title  { color:#334155; }
[data-theme="light"] .stat-label  { color:#334155; }
[data-theme="light"] .stat-value  { color:#0f172a; }
[data-theme="light"] .form-hint   { color:#64748b; }
/* Liens simples orange, mais PAS les boutons (sinon orange sur orange) */
[data-theme="light"] a:not(.btn)    { color:var(--orange); }

/* Boutons light — texte forcé pour ne pas hériter de la couleur du lien */
[data-theme="light"] .btn-primary   { color:#fff !important; }
[data-theme="light"] .btn-secondary { background:#fff; color:#1e293b !important; border-color:rgba(15,23,42,.15); }
[data-theme="light"] .btn-outline   { color:#334155 !important; border-color:rgba(15,23,42,.22); background:transparent; }
[data-theme="light"] .btn-outline:hover { color:var(--orange) !important; border-color:var(--orange); background:rgba(249,115,22,.07); }
[data-theme="light"] .btn-ghost     { color:#334155 !important; border-color:rgba(15,23,42,.15); background:rgba(15,23,42,.05); }
[data-theme="light"] .btn-ghost:hover { color:#0f172a !important; background:rgba(15,23,42,.1); }
[data-theme="light"] .btn-navy      { background:#1e293b; color:#fff !important; }
[data-theme="light"] .btn-success   { color:#fff !important; }
[data-theme="light"] .btn-danger    { color:var(--red); }

/* Tabs, modals, alerts en light mode */
[data-theme="light"] .tabs { border-bottom-color:rgba(15,23,42,.12); }
[data-theme="light"] .tab  { color:#475569; }
[data-theme="light"] .tab:hover { color:#0f172a; background:rgba(15,23,42,.04); }
[data-theme="light"] .modal { background:#fff; border-color:rgba(15,23,42,.1); }
[data-theme="light"] .modal-close { background:rgba(15,23,42,.06); color:#475569; }
[data-theme="light"] .modal-header, [data-theme="light"] .card-header { border-bottom-color:rgba(15,23,42,.08); }
[data-theme="light"] .alert-success { background:#f0fdf4; color:#166534; border-color:#bbf7d0; }
[data-theme="light"] .alert-error   { background:#fef2f2; color:#991b1b; border-color:#fecaca; }
[data-theme="light"] .alert-warning { background:#fffbeb; color:#92400e; border-color:#fde68a; }
[data-theme="light"] .alert-info    { background:#eff6ff; color:#1e40af; border-color:#bfdbfe; }
[data-theme="light"] .empty-state h3 { color:#334155; }
[data-theme="light"] .empty-state p  { color:#64748b; }
[data-theme="light"] .section-title  { color:#64748b; }
[data-theme="light"] .onboarding-banner h3 { color:var(--orange); }
[data-theme="light"] .onboarding-banner p  { color:#475569; }

/* Toggle bouton */
.theme-toggle {
  width: 36px; height: 36px;
  border-radius: 50%; border: 1px solid var(--border);
  background: var(--glass); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); transition: all .2s ease;
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--orangeL);
  border-color: var(--orange);
  color: var(--orange);
  transform: rotate(20deg) scale(1.1);
}
[data-theme="light"] .theme-toggle {
  background: rgba(15,23,42,.08);
  border-color: rgba(15,23,42,.2);
  color: #1e293b;
}
[data-theme="light"] .theme-toggle:hover {
  background: var(--orangeL);
  border-color: var(--orange);
  color: var(--orange);
}


/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --navy:    #0b1120;
  --navy2:   #111d35;
  --navy3:   #1a2847;
  --navy4:   #243358;

  --orange:  #f97316;
  --oranged: #ea6c0a;
  --orangeL: rgba(249,115,22,.12);
  --orangeG: rgba(249,115,22,.25);

  --green:   #22c55e;
  --greenL:  rgba(34,197,94,.15);
  --red:     #ef4444;
  --redL:    rgba(239,68,68,.15);
  --yellow:  #f59e0b;
  --yellowL: rgba(245,158,11,.15);
  --blue:    #3b82f6;
  --blueL:   rgba(59,130,246,.15);
  --purple:  #a855f7;
  --purpleL: rgba(168,85,247,.15);

  --white:   #ffffff;
  --text:    #f1f5f9;
  --muted:   #cbd5e1;
  --faint:   #94a3b8;

  /* Glass dark */
  --glass:        rgba(255,255,255,.07);
  --glass-hover:  rgba(255,255,255,.13);
  --glass-active: rgba(249,115,22,.18);
  --border:       rgba(255,255,255,.14);
  --border-hover: rgba(249,115,22,.6);

  /* Compat aliases (ancien CSS) */
  --gray-50:  #1e2d47; --gray-100: #1e2d47; --gray-200: #253352;
  --gray-300: #cbd5e1; --gray-400: #94a3b8; --gray-500: #cbd5e1;
  --gray-600: #e2e8f0; --gray-700: #f1f5f9; --gray-900: #ffffff;
  --text-muted:   #cbd5e1;
  --primary:      #f97316;
  --primary-dark: #ea6c0a;
  --border-solid: rgba(255,255,255,.12);
  --glass-blur:   blur(16px) saturate(180%);
  --glass-bg:     rgba(255,255,255,.06);
  --glass-border: 1px solid rgba(255,255,255,.1);
  --glass-shadow: 0 4px 20px rgba(0,0,0,.3);
  --shadow-sm:    0 2px 8px rgba(0,0,0,.25);
  --shadow:       0 4px 20px rgba(0,0,0,.35);
  --shadow-md:    0 12px 40px rgba(0,0,0,.45);
  --danger:   #ef4444;
  --success:  #22c55e;
  --warning:  #f59e0b;
  --hover:    rgba(255,255,255,.09);
  --surface:  rgba(255,255,255,.06);
  --card:     rgba(255,255,255,.06);
  --bg:       #0b1120;

  /* Layout */
  --sidebar-w: 248px;
  --topbar-h:  60px;
  --radius:    10px;
  --touch:     48px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,.25);
  --shadow:    0 4px 20px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.45);
  --glow-o:    0 0 24px rgba(249,115,22,.4);
  --glow-g:    0 0 24px rgba(34,197,94,.3);
  --glow-r:    0 0 24px rgba(239,68,68,.3);
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'DM Sans', -apple-system, 'Segoe UI', sans-serif;
  background: var(--navy);
  background-image:
    radial-gradient(ellipse 80% 60% at 10% 5%,  rgba(249,115,22,.07) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 90% 95%, rgba(59,130,246,.05) 0%, transparent 55%);
  background-attachment: fixed;
  min-height: 100vh;
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--orange); text-decoration: none; transition: color .15s; }
a:hover { color: #fb923c; }

/* ── Typography ─────────────────────────────────────────── */
h1, h2, h3 { font-family: 'Oswald', sans-serif; text-transform: uppercase; letter-spacing: .04em; color: var(--white); line-height: 1.2; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: .95rem; font-weight: 600; }
p  { margin-bottom: .75rem; color: var(--text); }

/* ── Layout ─────────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: rgba(11,17,32,.95);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  /* Safe area iPhone (PWA standalone) */
  padding-top: env(safe-area-inset-top);
  z-index: 100;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}

.sidebar-logo {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--orange), #fb923c);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(249,115,22,.4);
}
.sidebar-logo-icon svg { color: #fff; }
.sidebar-logo-text { font-family: 'Oswald', sans-serif; font-size: .95rem; font-weight: 700; color: var(--white); text-transform: uppercase; letter-spacing: .06em; }
.sidebar-logo-sub  { font-size: .65rem; color: var(--muted); font-weight: 400; display: block; margin-top: 1px; text-transform: none; letter-spacing: 0; }

.sidebar-nav { flex: 1; padding: 10px 0; overflow-y: auto; }

.nav-section {
  padding: 16px 18px 5px;
  font-size: .6rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--faint);
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  height: var(--touch);
  color: var(--muted);
  font-size: .875rem; font-weight: 500;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all .15s ease;
  cursor: pointer;
  position: relative;
}
.nav-item::after {
  content: '';
  position: absolute; inset: 4px 8px;
  border-radius: 8px;
  background: transparent;
  transition: background .15s;
  z-index: -1;
}
.nav-item:hover {
  color: var(--white);
  border-left-color: var(--orange);
  text-decoration: none;
}
.nav-item:hover::after { background: rgba(249,115,22,.18); }
.nav-item:hover .nav-icon { color: var(--orange); transform: scale(1.2); filter: drop-shadow(0 0 6px rgba(249,115,22,.7)); }

.nav-item.active {
  color: var(--orange);
  border-left-color: var(--orange);
  font-weight: 600;
  text-shadow: 0 0 20px rgba(249,115,22,.4);
}
.nav-item.active::after { background: rgba(249,115,22,.18); }
.nav-item.active .nav-icon { color: var(--orange); filter: drop-shadow(0 0 6px rgba(249,115,22,.7)); }

.nav-icon {
  width: 20px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  transition: color .15s, transform .15s;
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-footer .user-name { color: var(--white); font-weight: 600; font-size: .875rem; }
.sidebar-footer .user-role { color: var(--muted); font-size: .72rem; }

/* ── MAIN CONTENT ────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex; flex-direction: column;
  min-height: 100vh;
}

/* TOP BAR */
.top-bar {
  background: rgba(11,17,32,.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  /* Safe area iPhone — pousse le contenu sous l'encoche */
  padding-top: env(safe-area-inset-top);
  min-height: calc(var(--topbar-h) + env(safe-area-inset-top));
  display: flex; align-items: flex-end; justify-content: space-between;
  padding-bottom: 10px;
  position: sticky; top: 0; z-index: 50;
}
.top-bar-title {
  font-family: 'Oswald', sans-serif;
  font-size: 1.1rem; font-weight: 600;
  color: var(--white); text-transform: uppercase; letter-spacing: .06em;
}
.top-bar-right { display: flex; align-items: center; gap: 10px; }

.page-content { padding: 24px; flex: 1; max-width: 1320px; }

/* ── GLASS CARD ──────────────────────────────────────────── */
.card {
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.card:hover {
  border-color: rgba(255,255,255,.18);
  box-shadow: var(--shadow);
}
.card.card-interactive:hover {
  border-color: var(--orange);
  box-shadow: 0 8px 32px rgba(249,115,22,.15);
  transform: translateY(-2px);
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-family: 'Oswald', sans-serif;
  font-size: .8rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted);
}

/* ── STAT CARDS ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-top: 3px solid transparent;
  padding: 22px 20px;
  transition: all .2s ease;
  cursor: default;
}
.stat-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
}
.stat-card.orange { border-top-color: var(--orange); }
.stat-card.green  { border-top-color: var(--green); }
.stat-card.blue   { border-top-color: var(--blue); }
.stat-card.red    { border-top-color: var(--red); }
.stat-card.orange:hover { box-shadow: 0 12px 40px rgba(249,115,22,.45); border-color: rgba(249,115,22,.5); }
.stat-card.green:hover  { box-shadow: 0 12px 40px rgba(34,197,94,.4);  border-color: rgba(34,197,94,.5); }
.stat-card.blue:hover   { box-shadow: 0 12px 40px rgba(59,130,246,.4); border-color: rgba(59,130,246,.5); }
.stat-card.red:hover    { box-shadow: 0 12px 40px rgba(239,68,68,.4);  border-color: rgba(239,68,68,.5); }

.stat-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
  transition: transform .2s;
}
.stat-card:hover .stat-icon { transform: scale(1.1); }
.stat-icon.orange { background: var(--orangeL); color: var(--orange); }
.stat-icon.green  { background: var(--greenL);  color: var(--green); }
.stat-icon.blue   { background: var(--blueL);   color: var(--blue); }
.stat-icon.red    { background: var(--redL);     color: var(--red); }

.stat-value {
  font-family: 'Oswald', sans-serif;
  font-size: 2rem; font-weight: 700;
  color: var(--white); line-height: 1;
  letter-spacing: -.02em; margin-bottom: 5px;
}
.stat-label {
  font-size: .72rem; font-weight: 600;
  color: var(--muted);
  text-transform: uppercase; letter-spacing: .07em;
}

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 20px; height: var(--touch);
  font-family: 'DM Sans', sans-serif;
  font-size: .875rem; font-weight: 600;
  cursor: pointer; border: 1px solid transparent;
  border-radius: 8px;
  transition: all .18s ease;
  text-decoration: none; white-space: nowrap;
}
.btn svg { flex-shrink: 0; }

.btn-primary {
  background: linear-gradient(135deg, var(--orange), #fb923c);
  color: #fff;
  box-shadow: 0 4px 14px rgba(249,115,22,.35);
}
.btn-primary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 10px 32px rgba(249,115,22,.7), 0 0 0 1px rgba(249,115,22,.4);
  color: #fff; text-decoration: none;
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--glass);
  color: var(--text);
  border-color: var(--border);
  backdrop-filter: blur(12px);
}
.btn-secondary:hover {
  background: var(--glass-hover);
  border-color: rgba(255,255,255,.25);
  color: var(--white); text-decoration: none;
  transform: translateY(-1px);
}

.btn-success {
  background: rgba(34,197,94,.15);
  color: var(--green);
  border-color: rgba(34,197,94,.3);
}
.btn-success:hover {
  background: var(--green);
  color: #fff; border-color: var(--green);
  box-shadow: 0 8px 28px rgba(34,197,94,.6), 0 0 0 1px rgba(34,197,94,.4);
  text-decoration: none; transform: translateY(-3px) scale(1.02);
}

.btn-danger {
  background: rgba(239,68,68,.1);
  color: var(--red);
  border-color: rgba(239,68,68,.25);
}
.btn-danger:hover {
  background: var(--red);
  color: #fff; border-color: var(--red);
  box-shadow: 0 8px 28px rgba(239,68,68,.6), 0 0 0 1px rgba(239,68,68,.4);
  text-decoration: none; transform: translateY(-3px) scale(1.02);
}

.btn-navy {
  background: var(--navy3);
  color: var(--white);
  border-color: var(--border);
}
.btn-navy:hover {
  background: var(--navy4);
  border-color: rgba(255,255,255,.2);
  color: var(--white); text-decoration: none;
}

.btn-outline {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.btn-outline:hover {
  color: var(--orange);
  border-color: var(--orange);
  background: var(--orangeL);
  text-decoration: none;
}

.btn-sm { height: 36px; padding: 0 14px; font-size: .8rem; border-radius: 6px; }
.btn-lg { height: 54px; padding: 0 30px; font-size: 1rem; border-radius: 10px; }

/* ── FORMS ───────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: .75rem; font-weight: 700;
  color: var(--white);
  margin-bottom: 7px;
  text-transform: uppercase; letter-spacing: .06em;
}

.form-control {
  display: block; width: 100%;
  padding: 0 14px; height: var(--touch);
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .95rem; font-family: 'DM Sans', inherit;
  color: var(--white);
  transition: border-color .15s, background .15s, box-shadow .15s;
  outline: none; appearance: none;
}
.form-control::placeholder { color: var(--faint); }
.form-control:hover { border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.08); }
.form-control:focus {
  border-color: var(--orange);
  background: rgba(255,255,255,.08);
  box-shadow: 0 0 0 3px rgba(249,115,22,.15);
}
textarea.form-control { height: auto; padding: 12px 14px; min-height: 100px; resize: vertical; }

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  padding-right: 38px; cursor: pointer;
}
select.form-control option { background: var(--navy2); color: var(--white); }

.form-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-hint  { font-size: .76rem; color: var(--faint); margin-top: 5px; }
.form-error { font-size: .76rem; color: var(--red); margin-top: 5px; font-weight: 600; }

/* ── TABLES ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.mobile-only { display: none; }
.desktop-only { display: block; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }

thead th {
  padding: 14px 16px;
  font-family: 'Oswald', sans-serif;
  font-size: .68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted);
  background: rgba(255,255,255,.04);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,.05);
  color: var(--text);
  vertical-align: middle;
}

tbody tr {
  background: transparent;
  transition: background .12s, border-left-color .12s;
  border-left: 3px solid transparent;
}
tbody tr:hover {
  background: rgba(249,115,22,.12);
  border-left-color: var(--orange);
  box-shadow: inset 0 0 0 1px rgba(249,115,22,.15);
}
tbody tr:hover td { color: var(--white); }
tbody tr:last-child td { border-bottom: none; }

/* ── BADGES ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  border-radius: 99px;
  border: 1px solid transparent;
  transition: all .15s;
}

.badge-orange { background: var(--orangeL); color: var(--orange); border-color: rgba(249,115,22,.25); }
.badge-green  { background: var(--greenL);  color: var(--green);  border-color: rgba(34,197,94,.25); }
.badge-red    { background: var(--redL);    color: var(--red);    border-color: rgba(239,68,68,.25); }
.badge-blue   { background: var(--blueL);   color: var(--blue);   border-color: rgba(59,130,246,.25); }
.badge-yellow { background: var(--yellowL); color: var(--yellow); border-color: rgba(245,158,11,.25); }
.badge-purple { background: var(--purpleL); color: var(--purple); border-color: rgba(168,85,247,.25); }
.badge-gray   { background: rgba(255,255,255,.07); color: var(--muted); border-color: var(--border); }

/* Dot de statut */
.badge-dot {
  width: 6px; height: 6px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.badge-orange .badge-dot { background: var(--orange); }
.badge-green .badge-dot  { background: var(--green); animation: pulse-dot 2s infinite; }
.badge-red .badge-dot    { background: var(--red); }
@keyframes pulse-dot { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ── ALERTS ──────────────────────────────────────────────── */
.alert {
  padding: 14px 18px;
  border-radius: 8px;
  font-size: .9rem;
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 16px;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
}
.alert-success { background: rgba(34,197,94,.08);  color: #86efac; border-color: rgba(34,197,94,.2);  border-left-color: var(--green); }
.alert-error   { background: rgba(239,68,68,.08);  color: #fca5a5; border-color: rgba(239,68,68,.2);  border-left-color: var(--red); }
.alert-warning { background: rgba(245,158,11,.08); color: #fde68a; border-color: rgba(245,158,11,.2); border-left-color: var(--yellow); }
.alert-info    { background: rgba(59,130,246,.08); color: #93c5fd; border-color: rgba(59,130,246,.2); border-left-color: var(--blue); }

/* ── AUTH ────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--navy);
  background-image:
    radial-gradient(ellipse 70% 50% at 15% 20%, rgba(249,115,22,.12) 0%, transparent 60%),
    radial-gradient(ellipse 50% 70% at 85% 80%, rgba(59,130,246,.08) 0%, transparent 60%);
  padding: 24px;
}

.auth-box {
  background: rgba(255,255,255,.06);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  padding: 44px 40px;
  width: 100%; max-width: 430px;
  box-shadow: 0 24px 64px rgba(0,0,0,.4);
}

.auth-logo { text-align: center; margin-bottom: 36px; }
.auth-logo-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--orange), #fb923c);
  border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(249,115,22,.4);
}
.auth-logo h1 { font-size: 1.4rem; margin-bottom: 6px; color: var(--white); }
.auth-logo p  { font-size: .875rem; color: var(--muted); margin: 0; }

/* ── TABS ────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  gap: 4px;
}
.tab {
  padding: 0 18px; height: 44px;
  font-size: .875rem; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
  display: inline-flex; align-items: center;
  border-radius: 8px 8px 0 0;
  transition: all .15s;
}
.tab:hover { color: var(--white); background: rgba(255,255,255,.05); text-decoration: none; }
.tab.active { color: var(--orange); border-bottom-color: var(--orange); background: rgba(249,115,22,.06); }

/* ── MODALS ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.92);
  backdrop-filter: none;
  z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
[data-theme="light"] .modal-overlay {
  background: rgba(15,23,42,.85);
  backdrop-filter: none;
}
@media (min-width: 768px) {
  .modal-overlay { align-items: center; padding: 24px; }
}
.modal {
  background: var(--navy2,#1e293b);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 16px 16px 0 0;
  padding: 28px;
  width: 100%; max-width: 580px;
  box-shadow: 0 -8px 40px rgba(0,0,0,.6);
  max-height: 90vh; overflow-y: auto;
  /* Pas de backdrop-filter sur la modale elle-même — évite la transparence */
  backdrop-filter: none;
}
@media (min-width: 768px) {
  .modal { border-radius: 16px; box-shadow: 0 24px 60px rgba(0,0,0,.6); }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
/* Bouton fermer — visible en dark ET light */
.modal-close {
  background: rgba(255,255,255,.18);
  border: 1.5px solid rgba(255,255,255,.35);
  border-radius: 10px;
  cursor: pointer;
  color: #ffffff;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
}
.modal-close:hover {
  background: rgba(239,68,68,.2);
  border-color: rgba(239,68,68,.5);
  color: #f87171;
}
[data-theme="light"] .modal-close {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #334155;
}
[data-theme="light"] .modal-close:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

/* ── EMPTY STATES ────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 24px; color: var(--muted); }
.empty-icon  { margin-bottom: 16px; opacity: .4; }
.empty-state h3 { color: var(--text); margin-bottom: 8px; }
.empty-state p  { font-size: .9rem; margin-bottom: 20px; color: var(--muted); }

/* ── GRID UTILS ──────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

/* ── HAMBURGER ───────────────────────────────────────────── */
.hamburger {
  display: none; cursor: pointer;
  padding: 10px; color: var(--white);
  min-width: var(--touch); min-height: var(--touch);
  align-items: center; justify-content: center;
  border-radius: 10px; border: 1.5px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.1);
  transition: all .15s;
}
.hamburger:hover { background: rgba(249,115,22,.2); border-color: var(--orange); color: var(--orange); }
[data-theme="light"] .hamburger { color: #0f172a; border-color: rgba(15,23,42,.2); background: rgba(15,23,42,.07); }
[data-theme="light"] .hamburger:hover { background: var(--orangeL); border-color: var(--orange); color: var(--orange); }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 768px) {
  html, body { overflow-x: hidden; max-width: 100%; }
  .main-content { overflow-x: hidden; max-width: 100%; }
  .page-content { overflow-x: hidden; max-width: 100%; }
  .hide-mobile { display: none !important; }
  .hide-on-mobile { display: none !important; }
  .desktop-only { display: none !important; }
  .mobile-only { display: block !important; }
  /* Tableau scrollable en interne — pas toute la page */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  table { min-width: 0; }
  thead th { white-space: normal; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.6); backdrop-filter: blur(4px); z-index: 99;
  }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .hamburger { display: flex !important; }
  .page-content { padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row, .form-row3 { grid-template-columns: 1fr; }
  .btn { width: 100%; justify-content: center; }
  .btn-sm, .btn-icon, .btn-ghost { width: auto; }
  .top-bar .btn, .top-bar .btn-sm { width: auto; }
  th .btn, td .btn { width: auto; }
  table { font-size: .85rem; }
  thead th { padding: 10px 12px; }
  tbody td { padding: 14px 12px; }
  .auth-box { padding: 28px 22px; border-radius: 16px; }
  .top-bar {
    padding: env(safe-area-inset-top) 16px 10px;
    min-height: calc(var(--topbar-h) + env(safe-area-inset-top));
    align-items: flex-end;
  }
}

/* ── Google Places autocomplete ─────────────────────────── */
.pac-container {
  max-width: calc(100vw - 32px) !important;
  box-sizing: border-box !important;
  border-radius: 8px !important;
  box-shadow: 0 8px 24px rgba(0,0,0,.15) !important;
  font-family: 'DM Sans', sans-serif !important;
  font-size: .88rem !important;
  z-index: 9999 !important;
}
.pac-item { padding: 8px 12px !important; cursor: pointer !important; }
.pac-item:hover { background: var(--orangeL, #fff7ed) !important; }
.pac-item-query { font-size: .88rem !important; }

/* ── VIDEO / DIAGNOSTIC ──────────────────────────────────── */
.video-page { min-height: 100vh; background: #05090f; display: flex; flex-direction: column; }
.video-header {
  background: rgba(11,17,32,.95); padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.video-header .logo { color: var(--orange); font-weight: 700; font-family: 'Oswald', sans-serif; text-transform: uppercase; letter-spacing: .08em; }
.video-header .info { color: var(--muted); font-size: .8rem; }
.video-frame-wrap { flex: 1; }
.video-frame-wrap iframe { width: 100%; height: 100%; min-height: calc(100vh - 130px); border: none; }
.video-status-bar {
  background: rgba(11,17,32,.9); padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between;
  color: var(--muted); font-size: .82rem; flex-wrap: wrap; gap: 8px;
  border-top: 1px solid var(--border);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.status-dot.green  { background: var(--green); animation: pulse-dot 2s infinite; }
.status-dot.orange { background: var(--orange); }
.status-dot.gray   { background: var(--faint); }

/* ── AVATAR ──────────────────────────────────────────────── */
.avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--orange), #fb923c);
  color: #fff;
  font-weight: 700; font-size: .8rem;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; border-radius: 50%;
  box-shadow: 0 2px 8px rgba(249,115,22,.3);
}

/* ── ONBOARDING BANNER ───────────────────────────────────── */
.onboarding-banner {
  background: rgba(249,115,22,.08);
  border: 1px solid rgba(249,115,22,.2);
  border-left: 4px solid var(--orange);
  border-radius: var(--radius);
  color: var(--text);
  padding: 20px 24px;
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 24px;
  transition: all .2s;
}
.onboarding-banner:hover { background: rgba(249,115,22,.12); box-shadow: 0 4px 20px rgba(249,115,22,.1); }
.onboarding-banner h3 { color: var(--orange); margin-bottom: 4px; }
.onboarding-banner p  { color: var(--muted); font-size: .875rem; margin: 0; }

/* ── SPINNER ─────────────────────────────────────────────── */
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin .55s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── DIVIDER ─────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ── SECTION LABEL ───────────────────────────────────────── */
.section-title {
  font-family: 'Oswald', sans-serif;
  font-size: .7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); margin-bottom: 12px;
}

/* ── UTILITIES ───────────────────────────────────────────── */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--muted); font-size: .875rem; }
.text-orange  { color: var(--orange); }
.text-green   { color: var(--green); }
.text-red     { color: var(--red); }
.text-bold    { font-weight: 700; }
.text-sm      { font-size: .82rem; }
.text-xs      { font-size: .75rem; }
.text-white   { color: var(--white); }

.mt-4  { margin-top:  4px; } .mt-8  { margin-top:  8px; }
.mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-4  { margin-bottom:  4px; } .mb-8  { margin-bottom:  8px; }
.mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }

.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none; }

/* ── ACTION BUTTONS (terrain mobile) ────────────────────── */
.action-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 16px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--glass);
  font-size: 1rem; font-weight: 700;
  color: var(--text); cursor: pointer;
  transition: all .2s ease;
  font-family: 'DM Sans', sans-serif;
}
.action-btn:hover { transform: translateY(-3px); }
.action-btn.go    { border-color: rgba(34,197,94,.3); }
.action-btn.go:hover   { background: rgba(34,197,94,.15); color: var(--green); box-shadow: 0 8px 24px rgba(34,197,94,.25); border-color: var(--green); }
.action-btn.here  { border-color: rgba(59,130,246,.3); }
.action-btn.here:hover { background: rgba(59,130,246,.15); color: var(--blue); box-shadow: 0 8px 24px rgba(59,130,246,.25); border-color: var(--blue); }
.action-btn.late  { border-color: rgba(245,158,11,.3); }
.action-btn.late:hover { background: rgba(245,158,11,.15); color: var(--yellow); box-shadow: 0 8px 24px rgba(245,158,11,.25); border-color: var(--yellow); }
.action-btn.done  { border-color: rgba(168,85,247,.3); }
.action-btn.done:hover { background: rgba(168,85,247,.15); color: var(--purple); box-shadow: 0 8px 24px rgba(168,85,247,.25); border-color: var(--purple); }
