/* ================================================================
   NAMY — Arctic Design System
   Fichier CSS partagé par toutes les pages
   ================================================================ */

/* ─── VARIABLES ──────────────────────────────────────────────── */
:root {
  /* Fond */
  --bg-page:        #F7F9FC;
  --bg-surface:     #FFFFFF;
  --bg-hover:       #F0F4F9;
  --bg-active:      #E8EDF5;

  /* Texte */
  --text-primary:   #0F1923;
  --text-secondary: #4A5568;
  --text-muted:     #8A9BAE;
  --text-hint:      #B8C4CE;

  /* Accent — vert menthe */
  --accent:         #00C9A7;
  --accent-light:   #E6FAF6;
  --accent-dark:    #009E85;

  /* Bordures */
  --border:         #E8EDF3;
  --border-strong:  #CDD5DF;

  /* Sémantique */
  --success:        #166534;
  --success-bg:     #DCFCE7;
  --warning:        #854D0E;
  --warning-bg:     #FEF9C3;
  --danger:         #991B1B;
  --danger-bg:      #FEE2E2;
  --info:           #1E40AF;
  --info-bg:        #DBEAFE;
  --neutral:        #374151;
  --neutral-bg:     #F3F4F6;

  /* Shadows */
  --shadow-sm:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:      0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:      0 8px 24px rgba(0,0,0,.10);

  /* Radius */
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      14px;
  --radius-xl:      20px;
  --radius-pill:    999px;

  /* Spacing */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;

  /* Fonts */
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;
}

/* ─── RESET ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-page);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ─── TYPOGRAPHY ─────────────────────────────────────────────── */
h1 { font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
h2 { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
h3 { font-size: 15px; font-weight: 500; }
h4 { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.label { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.mono { font-family: var(--font-mono); }

/* ─── TOPBAR ─────────────────────────────────────────────────── */
.topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 4px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-logo {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: .12em;
  margin-right: 16px;
  text-decoration: none;
}
.topbar-logo::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-left: 6px;
  vertical-align: middle;
}
.topbar-sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 12px;
}
.topbar-section { font-size: 13px; color: var(--text-muted); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.nav-item {
  font-size: 13px;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.nav-item:hover { color: var(--text-primary); background: var(--bg-hover); }
.nav-item.active { color: var(--text-primary); background: var(--bg-active); font-weight: 500; }

/* ─── LAYOUT ─────────────────────────────────────────────────── */
.page-wrapper {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title { font-size: 20px; font-weight: 600; color: var(--text-primary); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ─── CARDS ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }

/* ─── KPI CARDS ──────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s;
}
.kpi-card:hover { box-shadow: var(--shadow-md); }
.kpi-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.kpi-value {
  font-size: 26px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
  font-family: var(--font-mono);
}
.kpi-trend { font-size: 12px; margin-top: 6px; display: flex; align-items: center; gap: 3px; }
.kpi-trend.up   { color: var(--accent-dark); }
.kpi-trend.down { color: var(--danger); }
.kpi-trend.flat { color: var(--text-muted); }
.kpi-icon { font-size: 18px; margin-bottom: 8px; }

/* ─── BUTTONS ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .15s;
  white-space: nowrap;
  font-family: var(--font-body);
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--text-primary); color: #fff; }
.btn-primary:hover { background: #2D3748; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(153,27,27,.15); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: var(--radius-sm); }
.btn-lg { padding: 11px 22px; font-size: 14px; }

/* ─── BADGES ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: .7;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral); }
.badge-accent  { background: var(--accent-light); color: var(--accent-dark); }

/* ─── TABLES ─────────────────────────────────────────────────── */
.table-wrapper {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  background: var(--bg-page);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
tbody td { padding: 12px 16px; color: var(--text-secondary); vertical-align: middle; }
tbody td strong { color: var(--text-primary); font-weight: 500; }

/* ─── FORMS ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-surface);
  font-family: var(--font-body);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:hover { border-color: var(--text-hint); }
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,201,167,.12); }
.form-control::placeholder { color: var(--text-hint); }
textarea.form-control { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ─── MODALS ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,25,35,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-lg { max-width: 700px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}
.modal-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-hover);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.modal-close:hover { background: var(--bg-active); color: var(--text-primary); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 0 24px 20px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ─── FILTER BAR ─────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.filter-sep { width: 1px; height: 28px; background: var(--border); margin: 0 4px; }

/* Date nav */
.date-nav {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.date-nav-btn {
  padding: 7px 12px;
  background: var(--bg-surface);
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
  font-family: var(--font-body);
}
.date-nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.date-nav-btn.active { background: var(--text-primary); color: #fff; font-weight: 500; }

/* Period tabs */
.period-tabs {
  display: inline-flex;
  background: var(--bg-page);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}
.period-tab {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
  font-family: var(--font-body);
}
.period-tab.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

/* Statut toggle buttons */
.statut-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all .15s;
}
.statut-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.statut-btn.active { color: #fff; }
.statut-btn[data-statut="en_attente"].active { background: var(--neutral); border-color: var(--neutral); }
.statut-btn[data-statut="planifie"].active { background: var(--info); border-color: var(--info); }
.statut-btn[data-statut="en_cours"].active { background: var(--warning); border-color: var(--warning); }
.statut-btn[data-statut="livre"].active { background: var(--success); border-color: var(--success); }
.statut-btn[data-statut="echec"].active { background: var(--danger); border-color: var(--danger); }
.statut-btn[data-statut="litige"].active { background: var(--danger); border-color: var(--danger); }

/* ─── SIDEBAR (dispatch/grilles) ─────────────────────────────── */
.layout-with-sidebar {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  height: calc(100vh - 56px);
}
.sidebar {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  z-index: 1;
}
.sidebar-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
.sidebar-item:hover { background: var(--bg-hover); }
.sidebar-item.active { background: var(--accent-light); border-left: 3px solid var(--accent); }

/* ─── PAGINATION ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 0;
}
.page-btn {
  min-width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.page-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.page-btn.active { background: var(--text-primary); border-color: var(--text-primary); color: #fff; }
.page-btn:disabled { opacity: .3; cursor: not-allowed; }

/* ─── TOAST ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--text-primary);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: 13px;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
  display: none;
}

/* ─── CHART CONTAINERS ───────────────────────────────────────── */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.chart-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.chart-card-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 12px; }
.chart-container { position: relative; height: 280px; }

/* ─── UTILITY ────────────────────────────────────────────────── */
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }
.text-mono { font-family: var(--font-mono); }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.ml-auto { margin-left: auto; }

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
  .layout-with-sidebar { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .page-wrapper { padding: 16px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .topbar { padding: 0 12px; gap: 2px; }
  .topbar .nav-item { font-size: 11px; padding: 4px 8px; }
}

/* ─── SCROLLBAR ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-hint); }

/* ═══════════════════════════════════════════════════════════════
   UTILITAIRES Arctic — extraction des patterns inline répétitifs
   identifiés via audit code (suivi-flotte/dispatch/formulaire-vendeur).
   À utiliser à la place de styles inline pour cohérence + DRY.
   ═══════════════════════════════════════════════════════════════ */

/* Rayons */
.r-8  { border-radius: 8px; }
.r-12 { border-radius: 12px; }
.r-16 { border-radius: 16px; }
.r-pill { border-radius: 999px; }

/* Bordures Arctic */
.b-1   { border: 1px solid var(--border); }
.b-1-strong { border: 1px solid var(--border-strong); }

/* Ombres Arctic */
.shadow-sm { box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.shadow-md { box-shadow: 0 2px 8px rgba(15,23,42,.06); }
.shadow-lg { box-shadow: 0 8px 24px rgba(15,23,42,.10); }

/* Tags / Badges sémantiques (palette états Arctic) */
.tag-success { background: rgba(16,185,129,.12); color: #047857; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; display: inline-block; }
.tag-warning { background: rgba(245,158,11,.12); color: #92400E; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; display: inline-block; }
.tag-danger  { background: rgba(239,68,68,.12);  color: #991B1B; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; display: inline-block; }
.tag-info    { background: rgba(59,130,246,.12); color: #1E40AF; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; display: inline-block; }
.tag-neutral { background: var(--bg-hover, #F1F5F9); color: var(--text-muted); padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; display: inline-block; }

/* Mono (chiffres, IDs, prix) — DRY de l'inline `font-family:'DM Mono',monospace` */
.mono { font-family: 'DM Mono', ui-monospace, monospace; }

/* Surfaces Arctic standard */
.surface { background: var(--bg-surface, #fff); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.surface-soft { background: var(--bg-hover, #F8FAFC); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }

/* Stack helpers (réduit les `display:flex;gap:8px;align-items:center` inline) */
.stack-row { display: flex; align-items: center; gap: 8px; }
.stack-row-12 { display: flex; align-items: center; gap: 12px; }
.stack-col { display: flex; flex-direction: column; gap: 8px; }
.stack-col-12 { display: flex; flex-direction: column; gap: 12px; }

/* Centrage vertical/horizontal */
.center { display: flex; align-items: center; justify-content: center; }

/* Texte muted / aide */
.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle, #9CA3AF); }
.text-hint { color: var(--text-hint, #94A3B8); font-size: 11.5px; line-height: 1.45; }
