/* ============================================================
   COMPONENTS — boutons, cartes, formulaires, tableaux, badges
   ============================================================ */

/* ── Boutons ── */
.btn, .pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--s1), var(--s2));
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
  white-space: nowrap;
}

.btn:hover, .pill-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(98,168,255,.28);
  background: linear-gradient(180deg, rgba(98,168,255,.18), rgba(98,168,255,.08));
  box-shadow: var(--shadow-s);
}

.btn:active, .pill-btn:active { transform: translateY(0) scale(.985); }

.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  border-color: rgba(255,255,255,.12);
  color: #fff;
  box-shadow: var(--shadow-glow);
}
.btn-primary:hover {
  background: linear-gradient(180deg, var(--accent-soft), var(--accent));
  border-color: rgba(255,255,255,.18);
}

.btn-danger {
  background: linear-gradient(180deg, rgba(255,107,107,.20), rgba(255,107,107,.10));
  border-color: rgba(255,107,107,.28);
  color: #ffb8b8;
}
.btn-danger:hover {
  background: linear-gradient(180deg, rgba(255,107,107,.30), rgba(255,107,107,.16));
}

.btn-sm, .mini-btn {
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 13px;
}

/* ── Cartes (rework 2026) ── */
.card, .section-card, .hero-card,
.stats-card,
.import-card, .toolbar-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.card         { padding: 22px; }
.section-card { padding: 20px; }
.hero-card    { padding: 24px; margin-bottom: 18px; }
.stats-card   { padding: 18px; }
.import-card  { padding: 16px; }
.toolbar-card { padding: 16px; margin-bottom: 14px; }

.card h2, .card h3,
.section-card h2, .section-card h3 { margin-top: 0; }
.card h2, .section-card h2 { font-family: 'Space Grotesk', sans-serif; font-size: 22px; }

/* Hero */
.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.hero-title { font-family: 'Space Grotesk', sans-serif; font-size: 22px; font-weight: 700; margin: 0; }
.hero-sub   { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.stats-label {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
}
.stats-value { font-family: 'Space Grotesk', sans-serif; font-size: 32px; font-weight: 700; line-height: 1; }
.stats-card .stats-value { color: var(--text); }
.stats-sub   { margin-top: 6px; font-size: 12px; color: var(--muted); }

/* ── Formulaires ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field label, .field > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

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

.input, .select, textarea {
  width: 100%;
  min-height: 46px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-md);
  background: var(--bg-elev);
  color: var(--text);
  padding: 0 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
  font-family: inherit;
}

textarea {
  min-height: 100px;
  padding: 13px 14px;
  resize: vertical;
}

input[type="file"].input { padding: 12px 14px; }

.input::placeholder, textarea::placeholder {
  color: var(--subtle);
}

.input:focus, .select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg-card);
}

/* ── Tableaux ── */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-card);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table th {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  background: var(--bg-elev);
  white-space: nowrap;
}

.table td { color: var(--text); font-size: 14.5px; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--glass); }

/* ── Badges de statut (rework 2026) ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--line-md);
  background: var(--glass);
  width: max-content;
  text-transform: uppercase;
  letter-spacing: .04em;
  gap: 6px;
}
.status-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .9;
}

.status-new      { color: #cbd5e1; }
.status-paid     { border-color: rgba(52,211,153,.30); background: rgba(52,211,153,.10); color: var(--success); }
.status-progress { border-color: rgba(93,157,255,.30); background: rgba(93,157,255,.10); color: var(--blue); }
.status-done     { border-color: var(--accent-border); background: var(--accent-bg); color: var(--accent-soft); }
.status-error    { border-color: rgba(248,113,113,.30); background: rgba(248,113,113,.10); color: var(--danger); }

/* ── Messages et boîtes ── */
.info-box {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(98,168,255,.20);
  background: rgba(98,168,255,.08);
  color: #dfeeff;
  font-size: 13px;
}

.success-box {
  border-color: rgba(57,217,138,.25);
  background: rgba(57,217,138,.08);
  color: #9dffda;
}

.error-box {
  border-color: rgba(255,107,107,.25);
  background: rgba(255,107,107,.08);
  color: #ffb8b8;
}

/* ── Bandeau de disponibilite (RDV / Vacances / Hors horaires) ── */
.availability-banner {
  margin: 16px;
  padding: 14px 18px;
  border-radius: var(--radius-lg, 18px);
  border: 1px solid var(--line);
  display: none;
}
.availability-banner.is-visible { display: block; }
.availability-banner__title {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}
.availability-banner__msg {
  font-size: 14px;
  line-height: 1.5;
  opacity: .92;
}
.availability-banner--blocked {
  background: linear-gradient(135deg, var(--info-bg), rgba(47,115,232,.18));
  border-color: var(--info-border);
  color: #bfd9ff;
}
.availability-banner--blocked .availability-banner__title { color: var(--info-fg); }
.availability-banner--vacation {
  background: linear-gradient(135deg, var(--vacation-bg), rgba(245,158,11,.18));
  border-color: var(--vacation-border);
  color: #fcd34d;
}
.availability-banner--vacation .availability-banner__title { color: var(--vacation-fg); }
.availability-banner--off-hours {
  background: linear-gradient(135deg, var(--warn-bg), rgba(234,179,8,.18));
  border-color: var(--warn-border);
  color: #fde68a;
}
.availability-banner--off-hours .availability-banner__title { color: var(--warn-fg); }

.muted-box {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
}

.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* ── Wizard stepper (rework 2026) ── */
.wizard-badges {
  display: flex;
  gap: 0;
  margin-bottom: 26px;
  position: relative;
  padding: 0 8px;
}
.wizard-badges::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 30px; right: 30px;
  height: 2px;
  background: var(--line);
  z-index: 0;
}

.wizard-badge {
  flex: 1;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  transition: all .2s;
  margin: 0 4px;
}

.wizard-badge.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.wizard-badge.is-done {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent-soft);
}

@media (max-width: 600px) {
  .wizard-badges { padding: 0; flex-wrap: wrap; gap: 6px; }
  .wizard-badges::before { display: none; }
  .wizard-badge { flex: 1 1 calc(50% - 12px); font-size: 12px; padding: 8px; margin: 0; }
}

.wizard-step-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 18px;
}

.wizard-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ── Option cards (checkboxes) ── */
.option-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 10px;
}

.option-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  cursor: pointer;
  transition: border-color .18s, background .18s;
  min-height: 52px;
}

.option-card:has(input:checked) {
  border-color: rgba(98,168,255,.45);
  background: rgba(98,168,255,.10);
}

.option-card input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  flex-shrink: 0;
  min-height: unset;
  border-radius: 0;
}

/* ── Summary ── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 14px;
}

.summary-box {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}

.summary-box h3 { margin: 0 0 12px; font-size: 15px; }

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(255,255,255,.07);
  font-size: 14px;
}

.summary-row:last-child { border-bottom: none; }
.summary-row span       { color: var(--muted); }

.summary-total {
  font-size: 22px;
  font-weight: 800;
  margin-top: 12px;
}

.summary-strike { opacity: .6; text-decoration: line-through; }

/* ── Chips ── */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.05);
}

.chip.active {
  background: linear-gradient(180deg, rgba(98,168,255,.22), rgba(98,168,255,.10));
  border-color: rgba(98,168,255,.38);
}

.chip.ok   { border-color: rgba(57,217,138,.28); background: rgba(57,217,138,.10); color: #9dffd4; }
.chip.warn { border-color: rgba(255,207,107,.28); background: rgba(255,207,107,.10); color: #ffe9b0; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2,8,20,.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 9999;
}
.modal-backdrop.open { display: flex; }

.modal-card {
  width: min(980px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 20px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(18,32,58,.97), rgba(8,18,34,.97));
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.modal-head h3 { margin: 0 0 4px; font-size: 22px; }
.modal-sub     { margin: 0; color: var(--muted); font-size: 13px; }

.modal-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.modal-group {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
}

.modal-group h4 { margin: 0 0 10px; font-size: 14px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Vehicle cards ── */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.vehicle-card {
  background: linear-gradient(180deg, var(--s1), var(--s2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.vehicle-card h3 { margin: 8px 0 6px; font-size: 18px; font-weight: 700; }

.meta-list { margin-top: 12px; }

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(255,255,255,.07);
  font-size: 14px;
}

.meta-row:last-child { border-bottom: none; }
.meta-row span { color: var(--muted); }

/* ── Stat boxes ── */
.stat-box {
  background: linear-gradient(180deg, var(--s1), var(--s2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-box .label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.stat-box .value { font-size: 26px; font-weight: 800; }

/* ── Filter grid ── */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

/* ── Grilles utilitaires ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }

.hidden   { display: none !important; }
.nowrap   { white-space: nowrap; }
.muted    { color: var(--muted); }
.small    { font-size: 12px; color: var(--muted); }
.money    { font-size: 17px; font-weight: 700; }
.ok-text  { color: #8af0b4; }
.warn-text{ color: #ffdba2; }
.err-text { color: #ffb0b0; }

/* ── Responsive components ── */
@media (max-width: 1100px) {
  .stats-grid          { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .form-grid           { grid-template-columns: 1fr; }
  .summary-grid        { grid-template-columns: 1fr; }
  .option-grid         { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .modal-groups        { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .stats-grid          { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .option-grid         { grid-template-columns: 1fr; }
}

/* ── Auto-identification ECU (panel orange sous l'input file) ──
   Apparait quand l'utilisateur upload un .bin/.ori et que l'extraction
   ASCII cote client trouve un calculateur connu.                       */
.ecu-identify {
  margin-top: 10px;
  padding: 14px 16px;
  border-radius: var(--r-md, 12px);
  border: 1px solid var(--accent-border, rgba(255,140,40,.35));
  background: linear-gradient(180deg, rgba(255,140,40,.10), rgba(255,140,40,.04));
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: identify-fadein .18s ease-out;
}

@keyframes identify-fadein {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.identify-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.identify-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent-soft, #ffb070);
  letter-spacing: -.005em;
}

.identify-status {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.identify-message {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.45;
}

.identify-message:empty { display: none; }

.identify-candidates {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.identify-candidates:empty { display: none; }

.candidate-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 9px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  transition: background .15s, border-color .15s, transform .12s;
  text-align: left;
}

.candidate-chip:hover {
  background: rgba(255,140,40,.14);
  border-color: rgba(255,140,40,.6);
}

.candidate-chip:active { transform: scale(.97); }

.candidate-chip strong {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.2;
}

.candidate-chip .chip-meta {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: .02em;
}

/* Etats colores du panel selon le resultat */
.ecu-identify.identify-loading {
  border-color: rgba(98,168,255,.35);
  background: linear-gradient(180deg, rgba(98,168,255,.08), rgba(98,168,255,.03));
}
.ecu-identify.identify-loading .identify-title { color: #8ec0ff; }

.ecu-identify.identify-ok {
  border-color: rgba(120,220,160,.4);
  background: linear-gradient(180deg, rgba(120,220,160,.10), rgba(120,220,160,.03));
}
.ecu-identify.identify-ok .identify-title { color: #8af0b4; }

.ecu-identify.identify-warn {
  border-color: rgba(255,200,90,.38);
  background: linear-gradient(180deg, rgba(255,200,90,.10), rgba(255,200,90,.03));
}
.ecu-identify.identify-warn .identify-title { color: #ffdba2; }
