/* =====================================================================
   Parc Auto — Design system "tableau de bord / instrument cluster"
   Palette : asphalte nocturne + ambre de jauge + vert route + rouge stop
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&family=Tajawal:wght@400;500;700&display=swap');

:root {
  /* Couleurs */
  --asphalt-900: #131826;
  --asphalt-800: #1C2333;
  --asphalt-700: #262F45;
  --asphalt-600: #333F5C;
  --gauge-amber: #F2A63B;
  --gauge-amber-dim: #C9852A;
  --route-green: #3FA34D;
  --stop-red: #D64545;
  --steel-400: #8B93A7;
  --steel-200: #C7CCD9;
  --paper-100: #F5F3EE;
  --paper-050: #FBFAF7;
  --white: #FFFFFF;

  /* Typo */
  --font-display: 'Barlow Condensed', 'Tajawal', sans-serif;
  --font-body: 'Inter', 'Tajawal', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow-1: 0 1px 2px rgba(19,24,38,.06), 0 1px 3px rgba(19,24,38,.08);
  --shadow-2: 0 8px 24px rgba(19,24,38,.14);
}

html[dir="rtl"] { --font-display: 'Tajawal', sans-serif; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--paper-100);
  color: var(--asphalt-900);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

html[dir="rtl"] body { font-family: var(--font-body), 'Tajawal', sans-serif; }

h1, h2, h3, h4, .display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: .01em;
  text-transform: uppercase;
  color: var(--asphalt-900);
  margin: 0 0 4px;
}
html[dir="rtl"] h1, html[dir="rtl"] h2, html[dir="rtl"] h3, html[dir="rtl"] .display {
  text-transform: none;
  font-family: 'Tajawal', sans-serif;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

a { color: inherit; }

/* Focus visibility */
:focus-visible { outline: 2px solid var(--gauge-amber); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------------------------------------------------------------------
   Layout admin (sidebar console)
   --------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--asphalt-800);
  color: var(--paper-100);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--gauge-amber);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 6px 10px 20px;
  border-bottom: 1px solid var(--asphalt-600);
  margin-bottom: 14px;
}
.sidebar-brand small { display: block; font-family: var(--font-body); text-transform: none; font-size: 11px; color: var(--steel-400); letter-spacing: 0; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius);
  color: var(--steel-200); text-decoration: none;
  font-size: 14px; font-weight: 500; margin-bottom: 2px;
}
.nav-item .ic { font-size: 17px; width: 20px; text-align: center; }
.nav-item:hover { background: var(--asphalt-700); color: var(--white); }
.nav-item.active { background: var(--gauge-amber); color: var(--asphalt-900); font-weight: 600; }

.sidebar-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--asphalt-600); }
.sidebar-user { font-size: 12px; color: var(--steel-400); padding: 0 12px 8px; }

.main-col { flex: 1; min-width: 0; }
.topbar {
  background: var(--white); border-bottom: 1px solid #E4E1D8;
  padding: 14px 24px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.content { padding: 24px; max-width: 1280px; }

.lang-switch { display: flex; gap: 4px; }
.lang-switch a {
  padding: 4px 8px; border-radius: 6px; font-size: 12px; text-decoration: none;
  border: 1px solid #E4E1D8; color: var(--steel-400); font-weight: 600;
}
.lang-switch a.active { background: var(--asphalt-800); color: var(--gauge-amber); border-color: var(--asphalt-800); }

/* ---------------------------------------------------------------------
   Cartes / KPI (jauges)
   --------------------------------------------------------------------- */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 620px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow-1); border: 1px solid #ECE9E1;
}

.kpi { position: relative; overflow: hidden; }
.kpi .kpi-value { font-family: var(--font-mono); font-size: 32px; font-weight: 700; color: var(--asphalt-900); }
.kpi .kpi-label { font-size: 12px; color: var(--steel-400); text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; }
.kpi .kpi-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--gauge-amber); }
.kpi.ok .kpi-bar { background: var(--route-green); }
.kpi.warn .kpi-bar { background: var(--gauge-amber); }
.kpi.danger .kpi-bar { background: var(--stop-red); }

/* Badges statut */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; }
.badge.status-active { background: rgba(63,163,77,.12); color: #257A34; }
.badge.status-active .badge-dot { background: var(--route-green); }
.badge.status-maintenance { background: rgba(242,166,59,.15); color: #9A6317; }
.badge.status-maintenance .badge-dot { background: var(--gauge-amber); }
.badge.status-inactive { background: rgba(139,147,167,.15); color: #5C6478; }
.badge.status-inactive .badge-dot { background: var(--steel-400); }
.badge.status-alert { background: rgba(214,69,69,.12); color: #A32F2F; }
.badge.status-alert .badge-dot { background: var(--stop-red); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--steel-400); padding: 10px 12px; border-bottom: 2px solid #ECE9E1; }
html[dir="rtl"] th, html[dir="rtl"] td { text-align: right; }
td { padding: 11px 12px; border-bottom: 1px solid #F0EEE7; vertical-align: middle; }
tr:hover td { background: #FAF9F5; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 10px 18px; border-radius: var(--radius); border: none; cursor: pointer;
  font-family: var(--font-body); font-weight: 600; font-size: 14px; text-decoration: none;
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--gauge-amber); color: var(--asphalt-900); }
.btn-primary:hover { background: var(--gauge-amber-dim); }
.btn-dark { background: var(--asphalt-800); color: var(--white); }
.btn-dark:hover { background: var(--asphalt-700); }
.btn-outline { background: transparent; border: 1px solid #D9D5C9; color: var(--asphalt-800); }
.btn-outline:hover { background: #F0EEE7; }
.btn-danger { background: var(--stop-red); color: var(--white); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Forms */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--asphalt-800); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #D9D5C9; border-radius: var(--radius);
  font-family: var(--font-body); font-size: 14px; background: var(--white); color: var(--asphalt-900);
}
textarea { resize: vertical; min-height: 70px; }
.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 160px; }

.alert { padding: 12px 14px; border-radius: var(--radius); font-size: 14px; margin-bottom: 16px; }
.alert-success { background: rgba(63,163,77,.12); color: #257A34; }
.alert-error { background: rgba(214,69,69,.12); color: #A32F2F; }
.alert-info { background: rgba(51,63,92,.08); color: var(--asphalt-800); }

/* ---------------------------------------------------------------------
   Gauge (jauge semi-circulaire) — signature visuelle
   --------------------------------------------------------------------- */
.gauge-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.gauge-num { font-family: var(--font-mono); font-size: 22px; font-weight: 700; }
.gauge-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--steel-400); }

/* ---------------------------------------------------------------------
   Interface chauffeur (mobile-first)
   --------------------------------------------------------------------- */
.driver-shell { max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--paper-050); display: flex; flex-direction: column; }
.driver-header {
  background: var(--asphalt-800); color: var(--white); padding: 18px 20px 24px;
  border-bottom-left-radius: 24px; border-bottom-right-radius: 24px;
}
.driver-header .greet { font-size: 13px; color: var(--steel-200); }
.driver-header .veh { font-family: var(--font-display); font-size: 20px; color: var(--gauge-amber); text-transform: uppercase; }
.driver-body { flex: 1; padding: 18px 18px 90px; }

.clock-ring {
  width: 190px; height: 190px; border-radius: 50%; margin: 10px auto 18px;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  background: conic-gradient(var(--gauge-amber) var(--pct, 0%), var(--asphalt-700) 0);
  position: relative;
}
.clock-ring::before {
  content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--asphalt-900);
}
.clock-ring .inner { position: relative; z-index: 1; text-align: center; color: var(--white); }
.clock-ring .inner .t { font-family: var(--font-mono); font-size: 26px; font-weight: 700; color: var(--gauge-amber); }
.clock-ring .inner .l { font-size: 11px; color: var(--steel-200); text-transform: uppercase; letter-spacing: .05em; }

.driver-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; background: var(--white); border-top: 1px solid #ECE9E1;
  display: flex; justify-content: space-around; padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(19,24,38,.08);
}
.driver-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: var(--steel-400); font-size: 10px; padding: 6px 10px; border-radius: 10px; }
.driver-nav a .ic { font-size: 20px; }
.driver-nav a.active { color: var(--gauge-amber-dim); }

.tip-card { display: flex; gap: 12px; padding: 14px; border-radius: var(--radius-lg); background: var(--white); border: 1px solid #ECE9E1; margin-bottom: 10px; }
.tip-card .ic { font-size: 26px; }
.tip-card h4 { text-transform: none; font-family: var(--font-body); font-size: 14px; margin-bottom: 3px; }
.tip-card p { font-size: 13px; color: var(--steel-400); margin: 0; line-height: 1.4; }

.checklist-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 4px; border-bottom: 1px solid #F0EEE7; }
.checklist-item .label { font-size: 14px; }
.toggle { display: flex; border-radius: 999px; background: #EFEDE6; padding: 3px; }
.toggle button { border: none; background: transparent; padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; cursor: pointer; color: var(--steel-400); }
.toggle button.on-ok.selected { background: var(--route-green); color: var(--white); }
.toggle button.on-issue.selected { background: var(--stop-red); color: var(--white); }

.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--asphalt-900); padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--white); border-radius: var(--radius-lg); padding: 30px 26px; box-shadow: var(--shadow-2); }
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .ic { font-size: 34px; }
.login-brand .display { color: var(--asphalt-900); font-size: 24px; }

.map-box { border-radius: var(--radius-lg); overflow: hidden; border: 1px solid #ECE9E1; }
#map { height: 520px; width: 100%; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
}

.mobile-topnav { display: none; }
@media (max-width: 860px) {
  .mobile-topnav {
    display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px; background: var(--asphalt-800);
  }
  .mobile-topnav a { white-space: nowrap; color: var(--steel-200); text-decoration: none; font-size: 13px; padding: 6px 12px; border-radius: 999px; }
  .mobile-topnav a.active { background: var(--gauge-amber); color: var(--asphalt-900); font-weight: 700; }
}
