/* ==========================================================================
   driver.css — Interface web livreur (PWA), charte L21STUDIOS.
   Alignée sur l'app mobile Expo : bleu nuit #0D1626 + or #f8bb02, Montserrat,
   mobile-first, app-shell (header + contenu + barre du bas). Feuille DÉDIÉE :
   ne touche pas au style.css du site client (thème rouge).
   ========================================================================== */

:root {
  --navy: #0D1626;
  --navy-soft: #16223a;
  --gold: #f8bb02;
  --gold-dark: #D9A400;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --border: #E2E8F1;
  --divider: #EEF1F6;
  --text: #0D1626;
  --text-secondary: #55617A;
  --text-tertiary: #8A94A6;
  --text-on-dark: #E4EAF3;
  --text-on-dark-muted: #9DAEC6;
  --success: #15A34A;
  --success-light: #E7F7EE;
  --warning: #E8920C;
  --warning-light: #FFF4E2;
  --danger: #E5484D;
  --danger-light: #FDEDED;
  --info: #1F9CF0;
  --info-light: #E8F4FE;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 6px 20px rgba(13, 22, 38, 0.10);
  --tabbar-h: 64px;
}

* { box-sizing: border-box; }

/* Icônes SVG inline : taille par défaut proportionnelle au texte. Les
   contextes spécifiques (boutons, barre du bas) surchargent ci-dessous. */
svg { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.15em; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--navy);
  color: var(--text);
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Écran mobile centré sur desktop (l'app tient dans une colonne étroite). */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* -------- En-tête : titre or sur fond navy (comme le mobile) -------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 8px;
}
.app-header h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--gold);
}
.app-header .header-action {
  background: none;
  border: none;
  color: var(--gold);
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  padding: 6px;
}

/* -------- Contenu défilant, laisse la place à la barre du bas -------- */
.app-content {
  flex: 1;
  padding: 8px 16px calc(var(--tabbar-h) + 24px);
  overflow-y: auto;
}
.app-content.no-tabbar { padding-bottom: 24px; }

/* -------- Cartes blanches -------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card.flat { box-shadow: none; }

/* Accents de carte */
.card-gold { background: var(--gold); border-color: var(--gold-dark); }
.card-gold .muted { color: var(--navy); opacity: 0.72; }
.card-success { background: var(--success-light); border-color: var(--success); }
.card-warning { background: var(--warning-light); border-color: var(--warning); }
.card-danger { background: var(--danger-light); border-color: var(--danger); }
.card-info { background: var(--info-light); border-color: var(--info); }

/* -------- Typo utilitaires -------- */
.h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.4px; margin: 0 0 4px; color: var(--text); }
.h2 { font-size: 18px; font-weight: 700; margin: 0 0 8px; color: var(--text); }
.h3 { font-size: 16px; font-weight: 700; margin: 0 0 8px; color: var(--text); }
.section-title { font-size: 16px; font-weight: 700; color: var(--text-on-dark); margin: 20px 2px 8px; }
.muted { color: var(--text-secondary); font-size: 13px; }
.tiny { color: var(--text-tertiary); font-size: 12px; }
.strong { font-weight: 700; }
.gold-text { color: var(--gold); }
.value-xl { font-size: 34px; font-weight: 800; letter-spacing: -0.5px; }
.value-lg { font-size: 22px; font-weight: 800; }

/* -------- Boutons -------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.05s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.99); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-gold { background: var(--gold); color: var(--navy); border-color: var(--gold-dark); }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-inline { width: auto; padding: 9px 14px; font-size: 13px; }

.link { color: var(--info); text-decoration: none; font-weight: 600; }
.link-on-dark { color: var(--gold); }

/* -------- Champs -------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 600; }
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--surface);
}
.field input:focus,
.field select:focus,
.field textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(248, 187, 2, 0.15); }
.field .hint { font-size: 12px; color: var(--text-tertiary); margin: 4px 0 0; }
.field.error input { border-color: var(--danger); }
.field-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* -------- Onglets de période (Aujourd'hui/Semaine/Mois/Tout) -------- */
.period-tabs {
  display: flex;
  background: var(--divider);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 16px;
}
.period-tab {
  flex: 1;
  border: none;
  background: none;
  padding: 8px 0;
  border-radius: 999px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}
.period-tab.active { background: var(--gold); color: var(--navy); font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }

/* -------- Onglets méthode (Téléphone / Email) -------- */
.method-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.method-tab {
  flex: 1;
  padding: 11px 0;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}
.method-tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* -------- Badges de statut -------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-neutral { background: var(--divider); color: var(--text-secondary); }

/* -------- Points / statut en ligne -------- */
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-online { background: var(--success); }
.dot-offline { background: var(--text-tertiary); }

/* -------- Interrupteur (toggle en ligne) -------- */
.switch { position: relative; display: inline-block; width: 52px; height: 30px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: 0.2s; }
.switch .slider::before { content: ''; position: absolute; height: 24px; width: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
.switch input:checked + .slider { background: var(--success); }
.switch input:checked + .slider::before { transform: translateX(22px); }
.switch input:disabled + .slider { opacity: 0.5; }

/* -------- Barre de navigation du bas -------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--tabbar-h);
  background: var(--navy-soft);
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 50;
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-on-dark-muted);
  font-size: 11px;
  font-weight: 600;
}
.tabbar a.active { color: var(--gold); }
.tabbar a svg { width: 22px; height: 22px; }

/* -------- Page centrée (login) -------- */
.centered {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.centered .card { width: 100%; max-width: 420px; margin: 0; box-shadow: var(--shadow); }

/* -------- Logo -------- */
.logo-badge {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--gold); color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 24px; margin: 0 auto 14px;
}

/* -------- Divers -------- */
.info-box { background: var(--info-light); border: 1px solid var(--info); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px; color: var(--text); margin-bottom: 16px; }
.info-box.dev-hint { background: var(--warning-light); border-color: var(--warning); }
.code-display { font-family: 'Courier New', monospace; font-weight: 800; letter-spacing: 3px; color: var(--navy); }
.error { color: var(--danger); font-size: 13px; text-align: center; margin: 12px 0 0; min-height: 18px; }
.empty { text-align: center; color: var(--text-secondary); padding: 20px; }
.center-row { display: flex; align-items: center; justify-content: center; gap: 8px; }
.space-between { display: flex; align-items: center; justify-content: space-between; }

.avatar-circle { width: 56px; height: 56px; border-radius: 50%; background: var(--info-light); color: var(--navy); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 22px; overflow: hidden; }
.avatar-circle img { width: 100%; height: 100%; object-fit: cover; }

/* Spinner */
.spinner { width: 26px; height: 26px; border: 3px solid var(--divider); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 16px);
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  max-width: 90%;
  text-align: center;
}
.toast.show { opacity: 1; }

.hidden { display: none !important; }

/* -------- Champ téléphone (composant PhoneInput) -------- */
/* Sans ces règles, l'indicatif et le numéro s'empilent verticalement. */
.phone-input {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.country-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  flex-shrink: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.country-selector:hover { border-color: var(--gold); }
.country-selector .chevron {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-left: 2px;
}
.phone-input input {
  flex: 1;
  margin: 0;
}
.field .phone-input input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(248, 187, 2, 0.15);
}

/* -------- Liste des pays (popover) -------- */
.country-list {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.country-search {
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-bottom: 1px solid var(--divider);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  background: var(--surface-2);
  color: var(--text);
}
.country-list-items {
  max-height: 240px;
  overflow-y: auto;
}
.country-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--divider);
  transition: background 0.12s;
}
.country-item:last-child { border-bottom: none; }
.country-item:hover { background: rgba(248, 187, 2, 0.12); }
.country-item-flag { font-size: 20px; flex-shrink: 0; }
.country-item-name { flex: 1; font-size: 14px; text-align: left; color: var(--text); }
.country-item-dial { font-size: 13px; color: var(--text-tertiary); font-weight: 500; }

/* -------- Saisie OTP en cases (standard L21) -------- */
.otp-boxes { display: flex; gap: 8px; justify-content: center; margin: 4px 0 8px; }
.otp-box {
  flex: 1;
  min-width: 0;
  max-width: 52px;
  aspect-ratio: 1;
  text-align: center;
  font-family: inherit;
  font-size: 24px;
  font-weight: 800;
  color: var(--navy);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.otp-box:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(248, 187, 2, 0.2); }
