/* ══════════════════════════════════════════════
   ECU Tuning Platform — Dark Theme
   SOS ADBLUE / Diagnostic Auto IDF
   ══════════════════════════════════════════════ */

:root {
  --bg-0: #0d0f12;
  --bg-1: #13161b;
  --bg-2: #1a1f27;
  --bg-3: #232a35;
  --bg-4: #2c3444;

  --border: #2e3a4a;
  --border-light: #3d4e61;

  --text-0: #e8edf3;
  --text-1: #b0bcc9;
  --text-2: #6e7f91;
  --text-3: #4a5a6a;

  --accent: #00bfff;
  --accent-dark: #0088bb;
  --accent-glow: rgba(0, 191, 255, 0.15);

  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.12);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.12);
  --yellow: #f59e0b;
  --yellow-bg: rgba(245, 158, 11, 0.12);
  --purple: #a855f7;

  --sidebar-w: 220px;
  --radius: 8px;
  --radius-sm: 5px;
  --transition: 0.15s ease;
  --font-mono: 'Courier New', 'Consolas', monospace;
}

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

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ══════════════════════════════════════════════
   LOGIN
   ══════════════════════════════════════════════ */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 30%, #0a1929 0%, var(--bg-0) 70%);
}

.login-box {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 36px;
  width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon {
  font-size: 40px;
  margin-bottom: 10px;
  filter: drop-shadow(0 0 12px var(--accent));
}

.login-logo h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-0);
}

.login-logo p {
  color: var(--text-2);
  font-size: 13px;
  margin-top: 4px;
}

/* ══════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════ */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-icon { font-size: 24px; }
.sidebar-title { font-weight: 700; font-size: 15px; color: var(--accent); }
.sidebar-sub { font-size: 11px; color: var(--text-2); }

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--text-1);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all var(--transition);
  font-size: 13px;
}

.nav-item:hover {
  background: var(--bg-2);
  color: var(--text-0);
}

.nav-item.active {
  background: var(--accent-glow);
  border-left-color: var(--accent);
  color: var(--accent);
}

.nav-icon { font-size: 15px; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-2);
}

/* ── Main content ── */
#main-content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-0);
  padding: 24px;
}

/* ══════════════════════════════════════════════
   PAGES
   ══════════════════════════════════════════════ */
.page { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-0);
}

/* ══════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════ */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card-header {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ══════════════════════════════════════════════
   STATS GRID
   ══════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition);
}

.stat-card:hover { border-color: var(--accent); }

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

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  color: var(--text-2);
  font-size: 12px;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ══════════════════════════════════════════════
   GRID
   ══════════════════════════════════════════════ */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ══════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

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

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg-2); }

.mono { font-family: var(--font-mono); font-size: 12px; color: var(--accent); }
.calib-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════
   BADGES & TAGS
   ══════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-green  { background: var(--green-bg);  color: var(--green);  border: 1px solid rgba(34,197,94,0.3);  }
.badge-red    { background: var(--red-bg);    color: var(--red);    border: 1px solid rgba(239,68,68,0.3);  }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); border: 1px solid rgba(245,158,11,0.3); }
.badge-blue   { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(0,191,255,0.3); }
.badge-purple { background: rgba(168,85,247,0.12); color: var(--purple); border: 1px solid rgba(168,85,247,0.3); }

.tags { display: flex; flex-wrap: wrap; gap: 4px; }

.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
.tag-adblue   { background: rgba(239,68,68,0.15);  color: #fb7185; }
.tag-fap      { background: rgba(245,158,11,0.15); color: #fbbf24; }
.tag-egr      { background: rgba(168,85,247,0.15); color: #c084fc; }
.tag-stage1   { background: rgba(34,197,94,0.15);  color: #4ade80; }
.tag-dtc      { background: rgba(100,116,139,0.2); color: #94a3b8; }

/* ══════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary  { background: var(--accent); color: #000; }
.btn-primary:hover:not(:disabled)  { background: #33ccff; }
.btn-secondary { background: var(--bg-3); color: var(--text-0); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-4); }
.btn-success  { background: var(--green); color: #000; }
.btn-success:hover:not(:disabled)  { background: #4ade80; }
.btn-warning  { background: var(--yellow); color: #000; }
.btn-warning:hover:not(:disabled) { background: #fbbf24; }
.btn-danger   { background: var(--red); color: #fff; }
.btn-ghost    { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn-xs { padding: 2px 8px; font-size: 11px; }

/* ══════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════ */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; color: var(--text-2); font-weight: 500; }

.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.flex-1 { flex: 1; }

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-0);
  padding: 8px 12px;
  font-size: 13px;
  transition: border-color var(--transition);
  width: 100%;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.input-mono { font-family: var(--font-mono); font-size: 12px; }

.search-input {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-0);
  padding: 7px 14px;
  font-size: 13px;
  outline: none;
  min-width: 260px;
}

.search-input:focus { border-color: var(--accent); }

.select-input {
  padding: 7px 12px;
  min-width: 180px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-1);
}

/* ══════════════════════════════════════════════
   DROP ZONE
   ══════════════════════════════════════════════ */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--text-1);
}

.drop-zone.has-file {
  border-color: var(--green);
  background: var(--green-bg);
}

.drop-icon { font-size: 36px; }
.drop-sub { font-size: 12px; color: var(--text-3); }
.mt-1 { margin-top: 4px; }

/* ══════════════════════════════════════════════
   ALERTS / STATUS
   ══════════════════════════════════════════════ */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border-left: 3px solid;
}
.alert-error   { background: var(--red-bg);    color: var(--red);    border-color: var(--red);    }
.alert-success { background: var(--green-bg);  color: var(--green);  border-color: var(--green);  }
.alert-warning { background: var(--yellow-bg); color: var(--yellow); border-color: var(--yellow); }
.alert-info    { background: var(--accent-glow); color: var(--accent); border-color: var(--accent); }

/* ══════════════════════════════════════════════
   MATCH LEVEL
   ══════════════════════════════════════════════ */
.match-level-1 { background: var(--green-bg);  color: var(--green); }
.match-level-2 { background: var(--yellow-bg); color: var(--yellow); }
.match-level-3 { background: rgba(168,85,247,0.12); color: var(--purple); }

/* ══════════════════════════════════════════════
   IDENT GRID
   ══════════════════════════════════════════════ */
.ident-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.ident-item { }
.ident-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.ident-value { font-size: 13px; color: var(--text-0); margin-top: 2px; }
.ident-value.mono { font-family: var(--font-mono); font-size: 12px; color: var(--accent); }

/* ══════════════════════════════════════════════
   SOLUTION RADIO CARDS
   ══════════════════════════════════════════════ */
.solution-cards { display: flex; flex-direction: column; gap: 8px; }

.solution-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}

.solution-card:hover { border-color: var(--accent); }
.solution-card.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.solution-card input[type="radio"] { accent-color: var(--accent); }

/* ══════════════════════════════════════════════
   LOG OUTPUT
   ══════════════════════════════════════════════ */
.log-output {
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-1);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 500px;
  overflow-y: auto;
  line-height: 1.6;
}

/* ══════════════════════════════════════════════
   MOD TYPES CHART
   ══════════════════════════════════════════════ */
.mod-types-list { display: flex; flex-direction: column; gap: 8px; }
.mod-type-row { display: flex; align-items: center; gap: 10px; }
.mod-type-name { width: 160px; font-size: 12px; color: var(--text-1); }
.mod-type-bar-wrap { flex: 1; background: var(--bg-3); border-radius: 3px; height: 8px; }
.mod-type-bar { height: 8px; border-radius: 3px; background: var(--accent); }
.mod-type-count { font-size: 12px; color: var(--text-2); min-width: 24px; text-align: right; }

/* ══════════════════════════════════════════════
   PAGINATION
   ══════════════════════════════════════════════ */
.pagination {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.page-btn {
  padding: 4px 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  cursor: pointer;
  font-size: 12px;
  transition: all var(--transition);
}

.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); color: #000; border-color: var(--accent); }

/* ══════════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════════ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
}

.modal-box {
  position: relative;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 640px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  z-index: 1;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 16px; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text-0); }

.modal-body { padding: 20px; }

/* ══════════════════════════════════════════════
   NOUVEAU MOD CLIENT
   ══════════════════════════════════════════════ */
.nm-match-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--green-bg);
  border: 1px solid rgba(34,197,94,0.25);
  border-radius: var(--radius);
  font-size: 13px;
  flex-wrap: wrap;
}
.nm-match-bar strong { color: var(--accent); font-family: var(--font-mono); font-size: 12px; }

.nm-verify-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 10px 16px;
  align-items: center;
  font-size: 13px;
}
.nm-verify-label { color: var(--text-2); }
.nm-verify-value { font-weight: 500; }

.solution-card-inner { flex: 1; }
.solution-meta { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ══════════════════════════════════════════════
   UTILITIES
   ══════════════════════════════════════════════ */
.hidden { display: none !important; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.gap-2 { gap: 16px; }
.text-muted { color: var(--text-2); font-size: 13px; margin-bottom: 16px; }
.text-mono { font-family: var(--font-mono); font-size: 12px; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-accent { color: var(--accent); }

/* ══════════════════════════════════════════════
   SPINNER
   ══════════════════════════════════════════════ */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2col  { grid-template-columns: 1fr; }
  .ident-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 200px; }
  #main-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
