/* ============================================================
   CARNET D'ENTRETIEN — STYLES
   ============================================================ */

:root {
  --bg: #0a0e1a;
  --bg-card: #131826;
  --bg-elev: #1a2030;
  --bg-modal: rgba(5, 8, 16, 0.85);
  --border: #232a3d;
  --border-light: #2d3548;

  --accent: #ff6b35;
  --accent-glow: rgba(255, 107, 53, 0.25);
  --accent-2: #ffd60a;
  --green: #06d6a0;
  --red: #ef476f;
  --orange: #ffaa44;
  --purple: #c084fc;
  --blue: #5eb1ff;

  --text: #e8ecf3;
  --text-dim: #8a93a8;
  --text-muted: #5a6378;

  --radius: 12px;
  --radius-sm: 6px;
  --transition: 0.2s ease;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Manrope', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse at top right, rgba(255, 107, 53, 0.08), transparent 50%),
    radial-gradient(ellipse at bottom left, rgba(6, 214, 160, 0.05), transparent 50%);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: 0;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  position: relative;
  z-index: 1;
}

/* ==================== HEADER ==================== */
.header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
  flex-wrap: wrap;
  gap: 24px;
}

.header-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(48px, 7vw, 96px);
  line-height: 0.85;
  letter-spacing: -0.02em;
  font-weight: 400;
}

.header-title span {
  color: var(--accent);
  display: block;
  font-size: 0.5em;
  letter-spacing: 0.15em;
  margin-top: 12px;
  text-shadow: 0 0 30px var(--accent-glow);
}

.header-meta {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-dim);
}

.header-meta .plate {
  display: inline-block;
  background: #fff;
  color: #000;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.1em;
  border-radius: 4px;
  border: 2px solid #1a1a1a;
  margin-bottom: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.header-meta .vin {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ==================== TABS ==================== */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.tab {
  padding: 14px 20px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  margin-bottom: -1px;
}

.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: none;
  animation: fadeIn 0.4s ease;
}

.tab-content.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== KPI CARDS ==================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.kpi-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0.6;
}

.kpi-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.kpi-value {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 44px;
  line-height: 1;
  margin-bottom: 6px;
}

.kpi-value.accent { color: var(--accent); }
.kpi-value.green { color: var(--green); }
.kpi-value.red { color: var(--red); }

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==================== SECTION ==================== */
.section-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 32px;
  letter-spacing: 0.05em;
  margin: 40px 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-weight: 400;
}

.section-title::before {
  content: '';
  width: 4px;
  height: 24px;
  background: var(--accent);
}

.section-subtitle {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 24px;
  margin-top: -12px;
}

/* ==================== FILTERS ==================== */
.filters {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-btn {
  padding: 5px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text-dim);
  font-family: 'Manrope', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.filter-btn:hover {
  border-color: var(--border-light);
  color: var(--text);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0e1a;
  font-weight: 700;
}

.filter-select,
.filter-input {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 6px 12px;
  font-family: 'Manrope', sans-serif;
  font-size: 12px;
  outline: none;
  transition: border-color var(--transition);
}

.filter-select:focus,
.filter-input:focus {
  border-color: var(--accent);
}

.filter-input { min-width: 220px; }

.filter-reset {
  margin-left: auto;
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all var(--transition);
}

.filter-reset:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ==================== TABLE ==================== */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  background: var(--bg-elev);
}

th {
  padding: 14px 12px;
  text-align: left;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th[data-sort] {
  cursor: pointer;
  user-select: none;
}

th[data-sort]:hover { color: var(--accent); }

th.num-col,
td.num {
  text-align: right;
}

td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover { background: var(--bg-elev); }
tbody tr:last-child td { border-bottom: none; }

td.num {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
}

td.date {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
}

.table-footer {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  padding: 12px 4px;
  letter-spacing: 0.05em;
}

/* ==================== TAGS ==================== */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.tag-vidange      { background: rgba(6, 214, 160, 0.15);  color: #06d6a0; border: 1px solid rgba(6, 214, 160, 0.3); }
.tag-freinage     { background: rgba(239, 71, 111, 0.15); color: #ef476f; border: 1px solid rgba(239, 71, 111, 0.3); }
.tag-revision     { background: rgba(255, 214, 10, 0.15); color: #ffd60a; border: 1px solid rgba(255, 214, 10, 0.3); }
.tag-carrosserie  { background: rgba(168, 85, 247, 0.15); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); }
.tag-pneus        { background: rgba(255, 170, 68, 0.15); color: #ffaa44; border: 1px solid rgba(255, 170, 68, 0.3); }
.tag-distribution { background: rgba(255, 107, 53, 0.15); color: #ff6b35; border: 1px solid rgba(255, 107, 53, 0.3); }
.tag-transmission { background: rgba(94, 177, 255, 0.15); color: #5eb1ff; border: 1px solid rgba(94, 177, 255, 0.3); }
.tag-adblue       { background: rgba(157, 141, 241, 0.15); color: #9d8df1; border: 1px solid rgba(157, 141, 241, 0.3); }
.tag-echappement  { background: rgba(180, 180, 180, 0.15); color: #b4b4b4; border: 1px solid rgba(180, 180, 180, 0.3); }
.tag-garantie     { background: rgba(255, 255, 255, 0.05); color: var(--text-dim); border: 1px solid var(--border); }
.tag-default      { background: var(--bg-elev); color: var(--text-dim); border: 1px solid var(--border); }

.assurance-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  background: rgba(6, 214, 160, 0.15);
  color: #06d6a0;
  font-size: 9px;
  font-weight: 700;
  border-radius: 3px;
  letter-spacing: 0.05em;
  border: 1px solid rgba(6, 214, 160, 0.3);
}

.facture-link {
  color: var(--accent);
  text-decoration: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  cursor: pointer;
}

.facture-link:hover {
  text-decoration: underline;
}

/* ==================== STATUS CARDS (Suivi) ==================== */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.status-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.status-card.ok   { border-left: 4px solid var(--green); }
.status-card.warn { border-left: 4px solid var(--orange); }
.status-card.bad  { border-left: 4px solid var(--red); }

.status-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.status-card-title {
  font-size: 15px;
  font-weight: 700;
}

.status-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.status-pill.ok   { background: rgba(6, 214, 160, 0.15);  color: var(--green); }
.status-pill.warn { background: rgba(255, 170, 68, 0.15); color: var(--orange); }
.status-pill.bad  { background: rgba(239, 71, 111, 0.15); color: var(--red); }

.status-card-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.status-meta-item .lbl {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.status-meta-item .val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 600;
}

.status-progress {
  height: 6px;
  background: var(--bg-elev);
  border-radius: 3px;
  overflow: hidden;
  margin: 12px 0 8px;
}

.status-progress-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

.status-progress-bar.ok   { background: var(--green); }
.status-progress-bar.warn { background: var(--orange); }
.status-progress-bar.bad  { background: var(--red); }

.status-note {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
  margin-top: 8px;
}

/* ==================== TIMELINE (Prochainement) ==================== */
.timeline {
  position: relative;
  padding-left: 32px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  margin-left: 16px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -25px;
  top: 24px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border-light);
}

.timeline-item.urgent::before    { border-color: var(--red);    box-shadow: 0 0 12px rgba(239, 71, 111, 0.6); }
.timeline-item.bientot::before   { border-color: var(--orange); box-shadow: 0 0 12px rgba(255, 170, 68, 0.4); }
.timeline-item.aprevoir::before  { border-color: var(--accent-2); }
.timeline-item.lointain::before  { border-color: var(--green); }

.timeline-item.urgent    { border-left: 4px solid var(--red); }
.timeline-item.bientot   { border-left: 4px solid var(--orange); }
.timeline-item.aprevoir  { border-left: 4px solid var(--accent-2); }
.timeline-item.lointain  { border-left: 4px solid var(--green); }

.timeline-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}

.timeline-title {
  font-size: 16px;
  font-weight: 700;
}

.timeline-when {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 4px 10px;
  background: var(--bg-elev);
  border-radius: 4px;
  white-space: nowrap;
}

.timeline-item.urgent .timeline-when    { background: rgba(239, 71, 111, 0.15); color: var(--red); }
.timeline-item.bientot .timeline-when   { background: rgba(255, 170, 68, 0.15); color: var(--orange); }
.timeline-item.aprevoir .timeline-when  { background: rgba(255, 214, 10, 0.15); color: var(--accent-2); }
.timeline-item.lointain .timeline-when  { background: rgba(6, 214, 160, 0.15); color: var(--green); }

.timeline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 8px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-dim);
}

.timeline-meta strong {
  color: var(--text);
  font-weight: 700;
}

.timeline-note {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 6px;
  font-style: italic;
}

/* ==================== ALERTS ==================== */
.alert-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alert {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 20px;
  align-items: start;
}

.alert.urgent    { border-left: 4px solid var(--red); }
.alert.important { border-left: 4px solid var(--orange); }
.alert.toplan    { border-left: 4px solid var(--accent-2); }
.alert.ok        { border-left: 4px solid var(--green); }
.alert.info      { border-left: 4px solid var(--text-muted); }

.alert-priority {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.alert.urgent    .alert-priority { color: var(--red); }
.alert.important .alert-priority { color: var(--orange); }
.alert.toplan    .alert-priority { color: var(--accent-2); }
.alert.ok        .alert-priority { color: var(--green); }
.alert.info      .alert-priority { color: var(--text-muted); }

.alert-cat {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
}

.alert-body { font-size: 13px; }
.alert-obs    { color: var(--text); margin-bottom: 8px; line-height: 1.5; }
.alert-action { color: var(--text-dim); font-style: italic; font-size: 12px; line-height: 1.5; }
.alert-action::before { content: '→ '; color: var(--accent); font-weight: 700; }

/* ==================== CHARTS ==================== */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 40px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.chart-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.chart-canvas-wrap {
  height: 300px;
  position: relative;
}

/* ==================== MODAL ==================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--bg-modal);
  backdrop-filter: blur(8px);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 900px;
  max-height: 90vh;
  overflow: auto;
  padding: 24px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--accent);
  color: #0a0e1a;
}

.modal-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

/* ==================== FOOTER ==================== */
footer {
  margin-top: 60px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 880px) {
  .container { padding: 20px 16px 60px; }
  .chart-grid { grid-template-columns: 1fr; }
  .alert { grid-template-columns: 1fr; gap: 8px; }
  .header { flex-direction: column; align-items: flex-start; }
  .header-meta { text-align: left; }
  .filters { flex-direction: column; align-items: stretch; }
  .filter-reset { margin-left: 0; align-self: flex-end; }
  .filter-input { min-width: 0; width: 100%; }
}

@media (max-width: 600px) {
  .kpi-value { font-size: 32px; }
  .section-title { font-size: 24px; }
  table { font-size: 12px; }
  th, td { padding: 8px 6px; }
}

/* ==================== PRINT ==================== */
@media print {
  body::before, .tabs, .filters, .modal { display: none; }
  .tab-content { display: block !important; page-break-after: always; }
  body { background: white; color: black; }
}
