/* ============================================================
   VHRTRAINING App — design tokens dark premium fitness
   ============================================================ */

/* Inter (variable, sous-ensemble latin) — auto-hébergée pour éviter le
   round-trip cross-origin vers fonts.googleapis.com/gstatic.com à chaque
   navigation (notable en PWA iOS standalone, cache HTTP moins fiable). */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/static/fonts/inter-var-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Pictogrammes au trait (style Feather, cohérent avec les SVG de la nav),
     stockés en data-URI et appliqués via `mask` pour hériter de currentColor.
     Servent à remplacer les emojis : contrairement à un caractère emoji, le
     rendu ne dépend pas de la police système et n'est pas lu à voix haute. */
  --icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 11.08V12a10 10 0 1 1-5.93-9.14'/%3E%3Cpolyline points='22 4 12 14.01 9 11.01'/%3E%3C/svg%3E");
  --icon-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='8' x2='12' y2='12'/%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'/%3E%3C/svg%3E");

  /* Thème clair VHRTRAINING (cohérent avec les emails) */
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --bg-2: #ffffff;
  --border: #e2e8f0;
  --line: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #003ae4;
  --accent-soft: #dbeafe;
  --success: #16a34a;
  --danger: #ef4444;
  --info: #003ae4;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(15,23,42,.08);
  /* Surfaces sombres conservées (header/sidebar = branding, comme le header des emails) */
  --dark: #0f172a;
  --dark-2: #1e293b;
  --on-dark: #ffffff;
  --on-dark-muted: #94a3b8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--text); text-decoration: none; }
a:hover { opacity: .8; }

.layout {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }

/* ----- Auth pages ----- */

.auth-card {
  margin: auto;
  width: 100%;
  max-width: 420px;
  padding: 48px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 32px;
}
.auth-brand img {
  height: 76px;
  width: auto;
  filter: brightness(0);
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.auth-card p {
  margin: 0 0 24px;
}

/* ----- Forms ----- */

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 24px;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form label span {
  font-size: .875rem;
  font-weight: 500;
  color: var(--muted);
}

.form input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color .15s ease;
}

.form input:focus {
  border-color: var(--text);
}

.form input[name="token"] {
  letter-spacing: .5em;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
}

.form-inline {
  margin-top: 16px;
  text-align: center;
}

/* ----- Buttons ----- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s ease, transform .05s ease;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover { opacity: .9; }

.btn-ghost {
  background: transparent;
}

.link {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: .875rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link:hover { color: var(--text); }

/* ----- Alerts ----- */

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: 16px;
}

.alert-danger {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.alert-success {
  background: #dcfce7;
  border: 1px solid #bbf7d0;
  color: #15803d;
}

/* ----- Badges ----- */

.badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: .75rem;
  font-weight: 600;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.badge-success { background: rgba(16,185,129,.15); color: var(--success); border-color: rgba(16,185,129,.35); }
.badge-danger  { background: rgba(239,68,68,.15);  color: var(--danger);  border-color: rgba(239,68,68,.35); }
.badge-info    { background: rgba(59,130,246,.15); color: var(--info);    border-color: rgba(59,130,246,.35); }

/* ============================================================
   Admin layout — Phase 2
   ============================================================ */

.admin-layout {
  display: flex;
  min-height: 100dvh;
}

/* ----- Sidebar ----- */

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--dark);
  border-right: 1px solid rgba(255,255,255,.08);
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand img {
  height: 40px;
  width: auto;
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--muted);
  transition: color .15s, background .15s;
  text-decoration: none;
}
.nav-item { color: var(--on-dark-muted); }
.nav-item:hover, .nav-item--active {
  color: #fff;
  background: rgba(255,255,255,.08);
  opacity: 1;
}
.nav-item--active { box-shadow: inset 3px 0 0 var(--accent); }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-user {
  display: block;
  font-size: .75rem;
  color: var(--on-dark-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  background: none;
  border: 1px solid rgba(255,255,255,.18);
  color: var(--on-dark-muted);
  font-size: .8125rem;
  font-weight: 600;
  cursor: pointer;
  padding: 7px 14px;
  border-radius: 8px;
  font-family: inherit;
  white-space: nowrap;
  transition: all .15s ease;
}
.btn-logout:hover {
  color: #fff;
  border-color: #7f1d1d;
  background: rgba(127, 29, 29, .25);
}

/* ----- Admin main ----- */

.admin-main {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
  background: var(--bg);
}

/* ----- Page header ----- */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ----- Buttons ----- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  text-decoration: none;
  transition: opacity .15s;
  line-height: 1;
}
.btn:hover { opacity: .82; }
.btn-primary   { background: var(--accent);     color: #fff; }
.btn-secondary { background: #fff;  color: var(--text);
                 border: 1px solid var(--border); }
.btn-danger    { background: var(--danger);     color: #fff; }
.btn-success   { background: var(--success);    color: #fff; }
.btn-sm        { padding: 6px 12px; font-size: .8125rem; }

/* ----- Tables ----- */

.table-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .02em;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 14px 16px;
  font-size: .875rem;
  border-bottom: 1px solid var(--border);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-2); }

/* ----- Status badges ----- */

.badge-draft     { background: #f1f5f9; color: #334155; border-color: #e2e8f0; }
.badge-sent      { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.badge-paid      { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.badge-cancelled { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.badge-due-soon  { background: #fef9c3; color: #854d0e; border-color: #fde68a; }
.badge-due-warn  { background: #ffedd5; color: #9a3412; border-color: #fed7aa; }
.badge-due-late  { background: #fee2e2; color: #991b1b; border-color: #fecaca; }

/* ----- Discrete link-styled button ----- */

.btn-link { background:none; border:0; padding:0; color:var(--accent); font-size:.8125rem; font-weight:600; cursor:pointer; text-decoration:underline; text-underline-offset:2px; }
.btn-link:hover { color:var(--accent-strong, #1e3a8a); }

/* ----- Filter bar ----- */

.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* ----- Form ----- */

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.form-full { grid-column: 1 / -1; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.form-group label {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--muted);
}

.form-control {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 13px;
  font-size: .875rem;
  font-family: inherit;
  transition: border-color .15s;
  width: 100%;
  box-sizing: border-box;
}
.form-control:focus { outline: none; border-color: rgba(255,255,255,.4); }
textarea.form-control { resize: vertical; }

/* ----- Items table (creation form) ----- */

.items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 4px;
}
.items-table th {
  font-size: .75rem;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.items-table td { padding: 5px 8px; }
.items-table .form-control { padding: 7px 10px; }
.item-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px 6px;
}
.item-remove:hover { color: var(--danger); }
.item-total { display: block; text-align: right; padding: 9px 4px; font-size: .875rem; }

.total-display {
  text-align: right;
  font-size: 1.125rem;
  font-weight: 700;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ----- Autocomplete / dropdown ----- */

.contact-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow-y: auto;
}

.dropdown-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: .875rem;
  border-bottom: 1px solid var(--border);
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--surface-2); }

/* ----- Detail page ----- */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.detail-card h3 {
  font-size: .75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 0 0 16px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
  gap: 12px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row dt { color: var(--muted); flex-shrink: 0; }
.detail-row dd { font-weight: 500; text-align: right; }

/* ----- Alerts ----- */

.alert {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: 20px;
}
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

/* Icône d'alerte portée par le CSS plutôt que par un caractère dans chaque
   template : une seule définition au lieu de ~40 duplications, et le pictogramme
   ne se retrouve jamais copié dans un presse-papier ou lu par un lecteur d'écran.
   `mask` + currentColor => l'icône prend la couleur du texte (vert / rouge).
   `inline-block` plutôt que flex sur .alert : le layout interne des alertes
   existantes (titres, listes, liens) reste intact. */
.alert-success::before,
.alert-error::before,
.alert-danger::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  vertical-align: -3px;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.alert-success::before {
  -webkit-mask-image: var(--icon-check);
  mask-image: var(--icon-check);
}

.alert-error::before,
.alert-danger::before {
  -webkit-mask-image: var(--icon-alert);
  mask-image: var(--icon-alert);
}

/* ----- Empty state ----- */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

/* ============================================================
   Mobile responsive — Phase 5
   Breakpoint : ≤768px (tablette portrait + mobile)
   ============================================================ */

/* Burger menu — caché en desktop, visible en mobile */
.menu-burger {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  align-items: center; justify-content: center;
  cursor: pointer;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 50;
}
.menu-burger:hover { background: var(--surface-2); }

/* Backdrop quand sidebar ouverte (mobile) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 40;
}

@media (max-width: 768px) {
  /* Sidebar : slide in/out depuis la gauche */
  .menu-burger { display: flex; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 240px;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 45;
    box-shadow: 2px 0 24px rgba(0,0,0,.4);
  }
  .sidebar--open { transform: translateX(0); }
  .sidebar--open ~ .sidebar-backdrop,
  .sidebar-backdrop--open { display: block; }

  /* Main content : pleine largeur */
  .admin-main {
    padding: 60px 16px 32px;  /* top space pour burger + padding latéral réduit */
  }

  /* Page header : stack en colonne */
  .page-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px;
  }
  .page-title { font-size: 1.5rem !important; }

  /* Tables : scroll horizontal forcé via min-width sur la table */
  .table-container { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 640px; font-size: .8125rem; }
  .data-table th, .data-table td { padding: 10px 12px !important; white-space: nowrap; }
  /* 1re colonne (noms de plans, clients…) : retour à la ligne au lieu de couper le texte */
  .data-table td:first-child, .data-table th:first-child { white-space: normal; min-width: 200px; }
  /* Indicateur visuel : ombre subtile à droite quand y a du scroll */
  .table-container::after {
    content: ""; position: sticky; right: 0; top: 0; bottom: 0;
    width: 24px; pointer-events: none;
    background: linear-gradient(to left, var(--surface), transparent);
  }

  /* Cards moins de padding */
  .detail-card,
  .kpi-card { padding: 16px !important; }
  .kpi-value { font-size: 22px !important; }

  /* Filter bar : wrap proprement, full width inputs */
  .filter-bar {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .filter-bar input,
  .filter-bar select { width: 100% !important; min-width: 0 !important; }

  /* Plans grid (espace membre) : 1 colonne */
  .plans-grid { grid-template-columns: 1fr !important; }

  /* Formulaires : 1 colonne sur mobile (factures, séances, filtres récup…) */
  .form-row { grid-template-columns: 1fr !important; gap: 14px !important; }
  .form-card { padding: 18px !important; }

  /* Tables dans les cartes : scroll horizontal au lieu de déborder */
  .detail-card { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
  .detail-card table th,
  .detail-card table td { white-space: nowrap; }

  /* Cartes de séance (membre) : un peu plus compactes */
  .cal-session { padding: 11px 12px !important; }
  .cal-session-info { gap: 10px !important; }
  .recup-slots { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)) !important; }

  /* Header membre : stack en colonne */
  .membre-header-inner {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 12px;
    padding: 16px 16px !important;
  }
  .membre-main { padding: 24px 16px 48px !important; }

  /* Public invoice page : padding réduit */
  .invoice-public { padding: 24px 16px !important; }
}
