@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

/* ── Variables globales (cohérence MaxLabs) ─────────────── */
:root {
  --bg:         #f4f6fb;
  --surface:    #ffffff;
  --border:     #e4e8f0;
  --text:       #0d1117;
  --text-muted: #6b7280;
  --text-light: #9ca3af;

  --accent:     #6366f1;
  --accent-2:   #818cf8;
  --accent-bg:  #eef2ff;

  --blue:       #3b82f6;
  --blue-bg:    #eff6ff;
  --purple:     #a855f7;
  --purple-bg:  #faf5ff;
  --orange:     #f97316;
  --orange-bg:  #fff7ed;

  --green:      #16a34a;
  --green-bg:   #f0fdf4;
  --green-text: #15803d;
  --red:        #dc2626;
  --red-bg:     #fef2f2;
  --red-text:   #b91c1c;
  --yellow:     #d97706;
  --yellow-bg:  #fffbeb;
  --yellow-text:#92400e;

  /* CarTracker — couleur principale (sky blue) */
  --ct:         #0ea5e9;
  --ct-dark:    #0284c7;
  --ct-bg:      #f0f9ff;
  --ct-border:  #bae6fd;
  --ct-text:    #0369a1;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:     0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg:  0 12px 40px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.06);

  --radius:     14px;
  --radius-sm:  9px;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════
   NAVBAR
══════════════════════════════ */

.navbar {
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-img {
  height: 48px;
  width: auto;
  max-width: 180px;
  display: block;
  object-fit: contain;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.38rem 0.75rem;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
}

.nav-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px rgba(22,163,74,.2); }

.nav-btn {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, background 0.15s;
  margin-left: 0.25rem;
}

.nav-btn:hover { color: var(--text); background: var(--bg); }
.nav-btn--back  { color: var(--ct-text); background: var(--ct-bg); border: 1.5px solid var(--ct-border); }
.nav-btn--back:hover { background: #e0f2fe; }
.nav-btn--danger { color: var(--red-text); }
.nav-btn--danger:hover { background: var(--red-bg); color: var(--red-text); }

/* ══════════════════════════════
   PAGE WRAPPER
══════════════════════════════ */

.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

/* ══════════════════════════════
   PAGE HERO
══════════════════════════════ */

.page-hero {
  margin-bottom: 2rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-hero-left h1 {
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.hero-highlight {
  background: linear-gradient(135deg, var(--ct), var(--ct-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  margin-top: 0.4rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.page-hero-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  align-items: center;
}

/* ══════════════════════════════
   BOUTONS
══════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  background: linear-gradient(135deg, var(--ct), var(--ct-dark));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.2rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(14,165,233,.3);
  transition: opacity 0.15s, transform 0.15s, box-shadow 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(14,165,233,.35); }
.btn:active { transform: translateY(0); }
.btn--sm { padding: 0.45rem 0.9rem; font-size: 0.8rem; }
.btn--ghost {
  background: var(--surface);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.btn--ghost:hover { color: var(--text); border-color: var(--text-muted); background: var(--surface); box-shadow: var(--shadow); }
.btn--danger-ghost {
  background: var(--surface);
  color: var(--red-text);
  border: 1.5px solid #fecaca;
  box-shadow: var(--shadow-sm);
}
.btn--danger-ghost:hover { background: var(--red-bg); box-shadow: var(--shadow); }
.btn--full { width: 100%; }

/* ══════════════════════════════
   FICHE VÉHICULE
══════════════════════════════ */

.vehicle-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-top: 3px solid var(--ct);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.vehicle-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.vehicle-card-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.vehicle-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: var(--ct-bg);
  border: 1.5px solid var(--ct-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.vehicle-name { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.03em; }
.vehicle-year { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.1rem; }

.vehicle-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
}

.meta-pill--km {
  background: var(--ct-bg);
  border-color: var(--ct-border);
  color: var(--ct-text);
  font-weight: 700;
}

/* ══════════════════════════════
   SÉLECTEUR DE VÉHICULE (TABS)
══════════════════════════════ */

.vehicle-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.vehicle-tab {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}

.vehicle-tab:hover { border-color: var(--ct-border); color: var(--ct-text); background: var(--ct-bg); }
.vehicle-tab.active { background: var(--ct-bg); border-color: var(--ct-border); color: var(--ct-text); }

/* ══════════════════════════════
   KPI CARDS
══════════════════════════════ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.kpi-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.kpi-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.1;
}

.kpi-value--muted { color: var(--text-muted); font-size: 1rem; font-weight: 600; }

.kpi-sub {
  font-size: 0.77rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

/* ══════════════════════════════
   ALERTES
══════════════════════════════ */

.alerts-section { margin-bottom: 1.75rem; }

.alerts-section h2 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.alert-item--critical { background: var(--red-bg);    border-color: #fecaca; }
.alert-item--warning  { background: var(--yellow-bg); border-color: #fde68a; }
.alert-item--ok       { background: var(--green-bg);  border-color: #bbf7d0; }

.alert-icon { font-size: 1rem; flex-shrink: 0; margin-top: 0.05rem; }

.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 600; color: var(--text); }
.alert-detail { color: var(--text-muted); margin-top: 0.15rem; font-size: 0.82rem; }

.alert-item--critical .alert-title { color: var(--red-text); }
.alert-item--warning  .alert-title { color: var(--yellow-text); }
.alert-item--ok       .alert-title { color: var(--green-text); }

/* ══════════════════════════════
   SECTION TITRE
══════════════════════════════ */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 1rem;
}

.section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ══════════════════════════════
   LISTE INTERVENTIONS
══════════════════════════════ */

.entry-list { display: flex; flex-direction: column; gap: 0.6rem; }

.entry-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.entry-item:hover { box-shadow: var(--shadow); border-color: var(--ct-border); }

.entry-type-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--ct);
  flex-shrink: 0;
}

.entry-info { flex: 1; min-width: 0; }
.entry-title { font-weight: 600; font-size: 0.9rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-meta  { font-size: 0.77rem; color: var(--text-muted); margin-top: 0.15rem; }

.entry-right { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }

.type-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--ct-bg);
  border: 1px solid var(--ct-border);
  color: var(--ct-text);
  white-space: nowrap;
}

.cost-badge {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.entry-actions { display: flex; gap: 0.35rem; }

.icon-btn {
  width: 30px; height: 30px;
  border-radius: 7px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-muted);
}

.icon-btn:hover { border-color: var(--ct-border); background: var(--ct-bg); color: var(--ct-text); }
.icon-btn--del:hover  { border-color: #fecaca; background: var(--red-bg); color: var(--red-text); }

/* ══════════════════════════════
   FILTRES (historique)
══════════════════════════════ */

.filter-bar {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.filter-chip {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-block;
}

.filter-chip:hover { border-color: var(--ct-border); color: var(--ct-text); background: var(--ct-bg); }
.filter-chip.active { background: var(--ct-bg); border-color: var(--ct-border); color: var(--ct-text); }

/* ══════════════════════════════
   FORMULAIRES
══════════════════════════════ */

.form-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  max-width: 640px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1.25rem;
}

.form-grid .field--full { grid-column: 1 / -1; }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.field input,
.field select,
.field textarea {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.field select { cursor: pointer; }
.field textarea { resize: vertical; min-height: 80px; }

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--ct);
  box-shadow: 0 0 0 3px rgba(14,165,233,.15);
  background: var(--surface);
}

.field input::placeholder { color: var(--text-light); }

.field-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: -0.1rem;
}

.form-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

/* ══════════════════════════════
   ÉTATS VIDES
══════════════════════════════ */

.empty-state {
  text-align: center;
  padding: 3.5rem 2rem;
  color: var(--text-muted);
}

.empty-icon  { font-size: 2.75rem; margin-bottom: 0.75rem; }
.empty-title { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 0.4rem; }
.empty-sub   { font-size: 0.875rem; line-height: 1.6; }

/* ══════════════════════════════
   ALERTES FLASH (toasts/inline)
══════════════════════════════ */

.flash {
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  font-size: 0.85rem;
  line-height: 1.55;
  margin-bottom: 1.25rem;
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.flash--error   { background: var(--red-bg);   border: 1px solid #fecaca; color: var(--red-text); }
.flash--success { background: var(--green-bg); border: 1px solid #bbf7d0; color: var(--green-text); }

/* ══════════════════════════════
   PHOTOS VÉHICULE
══════════════════════════════ */

/* Photo principale sur le dashboard */
.vehicle-photo-wrap {
  position: relative;
  width: calc(100% + 3rem);
  margin: -1.5rem -1.5rem 1.25rem;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  max-height: 260px;
}

.vehicle-photo {
  width: 100%;
  height: 260px;
  object-fit: cover;
  display: block;
}

.vehicle-photo-edit {
  position: absolute;
  bottom: 0.65rem;
  right: 0.75rem;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  text-decoration: none;
  backdrop-filter: blur(4px);
  transition: background 0.15s;
}

.vehicle-photo-edit:hover { background: rgba(0,0,0,.75); }

/* Galerie dans vehicle-form */
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.photo-thumb {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1.5px solid var(--border);
  background: var(--bg);
  aspect-ratio: 4/3;
  transition: opacity 0.2s;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-main-badge {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  background: rgba(0,0,0,.6);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}

.photo-actions {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.55));
  padding: 1.5rem 0.4rem 0.4rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.3rem;
  opacity: 0;
  transition: opacity 0.15s;
}

.photo-thumb:hover .photo-actions { opacity: 1; }

.photo-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: none;
  background: rgba(255,255,255,.85);
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
}

.photo-btn:hover { background: #fff; }
.photo-btn--del:hover { background: var(--red-bg); }

/* Zone d'upload */
.photo-upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--bg);
}

.photo-upload-zone:hover,
.photo-upload-zone.drag-over {
  border-color: var(--ct);
  background: var(--ct-bg);
}

.upload-icon  { font-size: 1.75rem; margin-bottom: 0.4rem; }
.upload-label { font-size: 0.875rem; font-weight: 600; color: var(--text); }
.upload-hint  { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; }

@media (max-width: 640px) {
  .photo-gallery { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .vehicle-photo { height: 180px; }
}

/* ══════════════════════════════
   FOOTER
══════════════════════════════ */

.footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.footer a { color: var(--text-muted); text-decoration: none; }
.footer a:hover { color: var(--ct); }

/* ══════════════════════════════
   RESPONSIVE
══════════════════════════════ */

@media (max-width: 640px) {
  .navbar-inner { padding: 0 1rem; }
  .page         { padding: 1.75rem 1rem 4rem; }
  .nav-chip     { display: none; }
  .kpi-grid     { grid-template-columns: 1fr 1fr; }
  .form-grid    { grid-template-columns: 1fr; }
  .form-grid .field--full { grid-column: 1; }
  .entry-item   { flex-wrap: wrap; }
  .entry-right  { width: 100%; justify-content: flex-start; }
  .footer       { flex-direction: column; gap: 0.4rem; text-align: center; }
  .page-hero    { flex-direction: column; }
  .vehicle-card-header { flex-direction: column; }
}

@media (max-width: 400px) {
  .kpi-grid { grid-template-columns: 1fr; }
}
