/* ============================================================
   ECU TUNING PORTAL — Main Stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;500;600;700&family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,600&display=swap');

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

:root {
  --bg:          #0a0c12;
  --surface:     #111520;
  --surface2:    #181d2a;
  --surface3:    #1e2435;
  --border:      rgba(255,255,255,0.07);
  --border-h:    rgba(0,220,130,0.3);
  --accent:      #00dc82;
  --accent2:     #0090ff;
  --accent3:     #ff4d6d;
  --accent4:     #ffb347;
  --text:        #e8eaf0;
  --text2:       #8892a4;
  --text3:       #4a5568;
  --sidebar-w:   240px;
  --topbar-h:    58px;
  --radius:      10px;
  --radius-lg:   14px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.25);
}

html { scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

a { color: inherit; text-decoration: none; }

/* ─── SIDEBAR ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 200;
  transition: transform .3s ease;
}

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

.brand-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700; font-size: 14px; color: #000;
  flex-shrink: 0;
}

.brand-name { font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: 17px; line-height: 1.1; }
.brand-plan { font-size: 10px; color: var(--accent); text-transform: uppercase; letter-spacing: 1.5px; }

.sidebar-nav { flex: 1; padding: 10px 0; overflow-y: auto; }

.nav-section {
  padding: 10px 16px 4px;
  font-size: 10px; font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  color: var(--text2);
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s;
  cursor: pointer;
}

.nav-item:hover  { color: var(--text); background: rgba(255,255,255,0.04); }
.nav-item.active { color: var(--accent); border-left-color: var(--accent); background: rgba(0,220,130,0.07); }
.nav-icon { font-size: 15px; }
.nav-badge {
  margin-left: auto;
  background: var(--accent3);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 7px;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #000;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--accent); }
.btn-logout { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 18px; transition: color .15s; }
.btn-logout:hover { color: var(--accent3); }

/* ─── MAIN LAYOUT ───────────────────────────────────────────── */
.main-wrap { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* ─── TOPBAR ────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 22px;
  gap: 14px;
  position: sticky; top: 0; z-index: 100;
}

.sidebar-toggle { display: none; background: none; border: none; color: var(--text2); font-size: 20px; cursor: pointer; }
.topbar-title { font-family: 'Rajdhani', sans-serif; font-size: 20px; font-weight: 700; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.credit-chips { display: flex; gap: 6px; }
.credit-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--surface2);
}
.chip-tuning strong { color: var(--accent); }
.chip-slave   strong { color: var(--accent2); }
.chip-winols  strong { color: var(--accent4); }

/* ─── CONTENT ───────────────────────────────────────────────── */
.content { flex: 1; padding: 22px; }
.footer  { padding: 12px 22px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text3); }

/* ─── ALERTS ────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: center;
  padding: 10px 22px;
  font-size: 13.5px;
  border-bottom: 1px solid transparent;
}
.alert-close { margin-left: auto; background: none; border: none; cursor: pointer; font-size: 16px; }
.alert-success { background: rgba(0,220,130,0.1); color: var(--accent); border-color: rgba(0,220,130,0.2); }
.alert-error   { background: rgba(255,77,109,0.1); color: var(--accent3); border-color: rgba(255,77,109,0.2); }
.alert-info    { background: rgba(0,144,255,0.1); color: var(--accent2); border-color: rgba(0,144,255,0.2); }
.alert-warning { background: rgba(255,179,71,0.1); color: var(--accent4); border-color: rgba(255,179,71,0.2); }

/* ─── CARDS ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color .2s;
}
.card:hover { border-color: rgba(255,255,255,0.12); }

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

.card-title { font-family: 'Rajdhani', sans-serif; font-size: 17px; font-weight: 700; }
.card-body  { padding: 20px; }

/* ─── STAT CARDS ─────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: border-color .2s, transform .15s;
}
.stat-card:hover { border-color: var(--border-h); transform: translateY(-1px); }
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-label { font-size: 12px; color: var(--text2); margin-bottom: 3px; }
.stat-value { font-family: 'Rajdhani', sans-serif; font-size: 30px; font-weight: 700; line-height: 1; }
.stat-note  { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* ─── TABLES ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px; font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.025); }
tbody td { padding: 11px 14px; vertical-align: middle; }

.row-indicator { width: 3px; padding: 0 !important; }
.ind-new       { background: var(--accent4); }
.ind-archive   { background: var(--accent); }
.ind-failed    { background: var(--accent3); }
.ind-open      { background: var(--accent2); }

/* ─── BADGES ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px; font-weight: 700;
  letter-spacing: .3px;
  white-space: nowrap;
}
.badge-new      { background: rgba(255,179,71,0.15);  color: var(--accent4); }
.badge-archive  { background: rgba(0,220,130,0.15);   color: var(--accent);  }
.badge-failed   { background: rgba(255,77,109,0.15);  color: var(--accent3); }
.badge-open     { background: rgba(0,144,255,0.15);   color: var(--accent2); }
.badge-answered { background: rgba(0,220,130,0.12);   color: var(--accent);  }
.badge-closed   { background: rgba(255,255,255,0.08); color: var(--text2);   }
.badge-active   { background: rgba(0,220,130,0.15);   color: var(--accent);  }
.badge-inactive { background: rgba(255,77,109,0.12);  color: var(--accent3); }
.badge-admin    { background: rgba(0,144,255,0.15);   color: var(--accent2); }
.badge-pro      { background: rgba(0,144,255,0.15);   color: var(--accent2); }
.badge-ent      { background: rgba(156,39,176,0.2);   color: #ce93d8;        }
.badge-basic    { background: rgba(255,255,255,0.07); color: var(--text2);   }
.badge-manual   { background: rgba(255,255,255,0.07); color: var(--text2);   }
.badge-ap       { background: rgba(255,77,109,0.15);  color: var(--accent3); }

/* ─── BUTTONS ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: var(--accent);   color: #000; }
.btn-primary:hover { background: #00f090; box-shadow: 0 0 20px rgba(0,220,130,0.3); }

.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger { background: rgba(255,77,109,0.15); color: var(--accent3); border: 1px solid rgba(255,77,109,0.3); }
.btn-danger:hover { background: rgba(255,77,109,0.25); }

.btn-info    { background: rgba(0,144,255,0.15); color: var(--accent2); border: 1px solid rgba(0,144,255,0.3); }
.btn-info:hover { background: rgba(0,144,255,0.25); }

.btn-outline { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-sm   { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-lg   { padding: 12px 24px; font-size: 15px; }
.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }

/* ─── FORMS ──────────────────────────────────────────────────── */
.form-group  { margin-bottom: 16px; }
.form-label  { display: block; font-size: 11.5px; font-weight: 700; color: var(--text2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.form-hint   { font-size: 11px; color: var(--text3); margin-top: 4px; }
.form-error  { font-size: 11px; color: var(--accent3); margin-top: 4px; }

.form-control {
  display: block;
  width: 100%;
  padding: 9px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s;
  appearance: none;
}
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--text3); }
.form-control.is-invalid { border-color: var(--accent3); }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238892a4' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

/* ─── GRID / LAYOUT HELPERS ─────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.w-full { width: 100%; }

/* ─── SEARCH BAR ─────────────────────────────────────────────── */
.search-wrap { position: relative; }
.search-wrap .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text3); pointer-events: none; }
.search-wrap .form-control { padding-left: 32px; }

/* ─── PAGINATION ─────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: 4px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.page-item {
  min-width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  color: var(--text2);
  border: 1px solid transparent;
  transition: all .15s;
}
.page-item:hover   { background: var(--surface2); color: var(--text); }
.page-item.active  { background: var(--accent); color: #000; }
.page-item.dots    { cursor: default; }
.page-info { margin-left: auto; font-size: 12px; color: var(--text3); }

/* ─── TUNING OPTIONS CHECKBOXES ─────────────────────────────── */
.options-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.option-check {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
  user-select: none;
}
.option-check:hover   { border-color: var(--text2); }
.option-check.checked { border-color: var(--accent); background: rgba(0,220,130,0.08); color: var(--accent); }
.option-check input   { display: none; }
.option-check .check-mark { width: 16px; height: 16px; border-radius: 4px; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; transition: all .15s; flex-shrink: 0; }
.option-check.checked .check-mark { background: var(--accent); border-color: var(--accent); color: #000; font-size: 11px; font-weight: 900; }

/* ─── FILE DROP ZONE ─────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  color: var(--text2);
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(0,220,130,0.04);
  color: var(--accent);
}
.dropzone .dz-icon { font-size: 36px; margin-bottom: 10px; }
.dropzone .dz-text { font-size: 14px; font-weight: 500; }
.dropzone .dz-hint { font-size: 12px; color: var(--text3); margin-top: 6px; }

/* ─── INFO ROWS ──────────────────────────────────────────────── */
.info-row { display: flex; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.info-row:last-child { border-bottom: none; }
.info-key { color: var(--text2); width: 160px; flex-shrink: 0; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; display: flex; align-items: center; }
.info-val { color: var(--text); flex: 1; }

/* ─── TAG ────────────────────────────────────────────────────── */
.tag { display: inline-block; padding: 2px 8px; border-radius: 5px; font-size: 11px; background: var(--surface2); border: 1px solid var(--border); color: var(--text2); margin: 2px; }

/* ─── TABS ───────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; background: var(--surface2); border-radius: 11px; padding: 3px; margin-bottom: 20px; }
.tab { flex: 1; padding: 8px 12px; text-align: center; font-size: 13px; font-weight: 600; cursor: pointer; border-radius: 9px; transition: all .15s; color: var(--text2); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.3); }

/* ─── MODAL ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform .2s;
  box-shadow: var(--shadow);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-lg { max-width: 880px; }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-family: 'Rajdhani', sans-serif; font-size: 20px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text2); font-size: 20px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body   { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ─── EMPTY STATE ────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text2); }
.empty-icon  { font-size: 42px; margin-bottom: 12px; }
.empty-title { font-family: 'Rajdhani', sans-serif; font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.empty-text  { font-size: 13.5px; color: var(--text3); }

/* ─── AUTH PAGES ─────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 20px;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(0,220,130,.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(0,144,255,.06) 0%, transparent 60%);
}

.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 44px 40px;
  max-width: 420px; width: 100%;
  box-shadow: var(--shadow);
}

.auth-logo {
  width: 60px; height: 60px;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: 22px; color: #000;
}

.auth-title { font-family: 'Rajdhani', sans-serif; font-size: 28px; font-weight: 700; text-align: center; margin-bottom: 4px; }
.auth-sub   { color: var(--text2); font-size: 13.5px; text-align: center; margin-bottom: 28px; }

/* ─── MISC UTILITIES ─────────────────────────────────────────── */
.text-accent  { color: var(--accent); }
.text-danger  { color: var(--accent3); }
.text-warning { color: var(--accent4); }
.text-info    { color: var(--accent2); }
.text-muted   { color: var(--text2); }
.text-sm      { font-size: 12px; }
.text-xs      { font-size: 11px; }
.fw-bold      { font-weight: 700; }
.divider      { height: 1px; background: var(--border); margin: 18px 0; }
.mono         { font-family: 'Courier New', monospace; }

.credit-info-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.credit-info-box .c-label { font-size: 12px; color: var(--text2); }
.credit-info-box .c-val   { font-family: 'Rajdhani', sans-serif; font-size: 24px; font-weight: 700; }

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-240px); width: 240px; }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .credit-chips { display: none; }
  .options-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .auth-box { padding: 28px 20px; }
  .options-grid { grid-template-columns: 1fr; }
}
