/* ==========================================================
   DATA PORTAL — Modern SaaS Design System
   Overrides Bootstrap 5 to deliver a clean, professional UI
   ========================================================== */

/* ---------- Design Tokens ---------- */
:root {
  --font-sans: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;

  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;

  --success: #16a34a;
  --success-dark: #15803d;
  --success-soft: #f0fdf4;

  --warning: #d97706;
  --warning-soft: #fffbeb;

  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --danger-soft: #fef2f2;

  --info: #0891b2;
  --info-soft: #ecfeff;

  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #ffffff;
  --sidebar-hover: #1e293b;

  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;

  --text: #0f172a;
  --text-muted: #64748b;

  --radius: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 24px -8px rgba(15, 23, 42, 0.16);
  --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, 0.22);
}

/* ---------- Base ---------- */
body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.925rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  text-decoration: none;
}

/* ==========================================================
   APP SHELL — Sidebar + Topbar Layout
   ========================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 264px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 8px 18px -6px rgba(79, 70, 229, 0.7);
}

.brand-name {
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.brand-name small {
  display: block;
  color: var(--sidebar-text);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-section {
  padding: 18px 22px 6px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #475569;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px 12px;
}

.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin: 2px 0;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: 0.885rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-nav .nav-item i {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
}

.sidebar-nav .nav-item:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}

.sidebar-nav .nav-item.active {
  background: var(--primary);
  color: var(--sidebar-active);
  box-shadow: 0 8px 18px -8px rgba(79, 70, 229, 0.8);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-footer .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: 0.885rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-footer .nav-item i {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
}

.sidebar-footer .nav-item:hover {
  background: rgba(220, 38, 38, 0.12);
  color: #fca5a5;
}

.main {
  flex: 1;
  margin-left: 264px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-spacer {
  flex: 1;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.user-chip .user-meta {
  line-height: 1.15;
}

.user-chip .user-meta strong {
  display: block;
  font-size: 0.82rem;
  color: var(--text);
}

.user-chip .user-meta span {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.1rem;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1035;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
}

.page-content {
  padding: 26px 28px 40px;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
}

/* ---------- Page header helpers ---------- */
.page-heading {
  margin-bottom: 22px;
}

.page-heading h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

.page-heading p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ==========================================================
   CARDS
   ========================================================== */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.card-header {
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
  padding: 14px 18px;
  font-weight: 600;
}

.card-header.bg-primary, .card-header.bg-success, .card-header.bg-danger,
.card-header.bg-info, .card-header.bg-dark, .card-header.bg-secondary,
.card-header.bg-warning {
  color: #fff;
  border-bottom: none;
}

.card-header.bg-warning {
  color: #1f2937;
}

.card-body {
  padding: 18px;
}

/* Stat cards */
.stat-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-card .stat-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}

.stat-card .stat-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.stat-card.icon-success .stat-icon { background: var(--success-soft); color: var(--success); }
.stat-card.icon-primary .stat-icon { background: var(--primary-soft); color: var(--primary); }
.stat-card.icon-warning .stat-icon { background: var(--warning-soft); color: var(--warning); }
.stat-card.icon-danger .stat-icon { background: var(--danger-soft); color: var(--danger); }
.stat-card.icon-info .stat-icon { background: var(--info-soft); color: var(--info); }

/* Welcome / hero banner card */
.welcome-card {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 55%, #4f46e5 120%);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.welcome-card .card-body {
  padding: 22px 24px;
}

.welcome-card .badge {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
}

/* ==========================================================
   BUTTONS
   ========================================================== */
.btn {
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.885rem;
  padding: 8px 16px;
  transition: all 0.15s ease;
}

.btn-lg {
  padding: 12px 22px;
  font-size: 0.95rem;
  border-radius: var(--radius);
}

.btn-sm {
  padding: 5px 11px;
  font-size: 0.8rem;
  border-radius: 8px;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-success {
  background: var(--success);
  border-color: var(--success);
}

.btn-success:hover, .btn-success:focus, .btn-success:active {
  background: var(--success-dark);
  border-color: var(--success-dark);
}

.btn-warning {
  background: var(--warning);
  border-color: var(--warning);
  color: #fff;
}

.btn-warning:hover, .btn-warning:focus, .btn-warning:active {
  background: #b45309;
  border-color: #b45309;
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover, .btn-danger:focus, .btn-danger:active {
  background: var(--danger-dark);
  border-color: var(--danger-dark);
}

.btn-info {
  background: var(--info);
  border-color: var(--info);
}

.btn-info:hover, .btn-info:focus, .btn-info:active {
  background: #0e7490;
  border-color: #0e7490;
}

.btn-outline-light {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.45);
}

.btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: #fff;
  color: #fff;
}

.btn-dark {
  background: var(--sidebar-bg);
  border-color: var(--sidebar-bg);
}

.btn:focus {
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18);
}

.btn-danger:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18); }
.btn-success:focus { box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18); }
.btn-warning:focus { box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.18); }
.btn-info:focus { box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.18); }

/* ==========================================================
   FORMS
   ========================================================== */
.form-control, .form-select {
  border: 1px solid #cbd5e1;
  border-radius: var(--radius);
  padding: 9px 13px;
  font-size: 0.9rem;
  color: var(--text);
  background-color: #fff;
  min-height: 42px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-control::placeholder {
  color: #94a3b8;
}

.form-control-lg {
  min-height: 50px;
  font-size: 1rem;
  padding: 12px 16px;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.form-select {
  appearance: auto;
}

.input-group .btn {
  border-radius: var(--radius);
}

.input-group > .form-control + .btn,
.input-group > .form-control:not(:last-child) {
  border-top-right-radius: var(--radius) !important;
  border-bottom-right-radius: var(--radius) !important;
}

.input-group > .form-control:first-child {
  border-top-left-radius: var(--radius) !important;
  border-bottom-left-radius: var(--radius) !important;
}

/* Search hero */
.search-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 26px 28px;
}

.search-hero .search-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 14px;
}

.search-hero h2 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

.search-hero p {
  color: var(--text-muted);
  margin: 0 0 18px;
}

/* ==========================================================
   TABLES
   ========================================================== */
.table {
  --bs-table-hover-bg: #f8fafc;
  --bs-table-hover-color: inherit;
  color: var(--text);
  font-size: 0.885rem;
  margin-bottom: 0;
}

.table thead th {
  background: #f1f5f9;
  color: #475569;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid #eef2f7;
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr {
  transition: background 0.12s ease;
}

.table tbody tr:hover {
  background: #f8fafc;
}

.table-bordered {
  border-color: var(--border);
}

.table-bordered th, .table-bordered td {
  border-color: #e9eef5;
}

.table-responsive {
  border-radius: var(--radius);
}

/* ==========================================================
   BADGES & STATUS
   ========================================================== */
.badge {
  padding: 5px 11px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--radius-pill);
}

.badge.bg-success { background: var(--success) !important; }
.badge.bg-danger { background: var(--danger) !important; }
.badge.bg-warning { background: var(--warning) !important; }
.badge.bg-info { background: var(--info) !important; }
.badge.bg-primary { background: var(--primary) !important; }
.badge.bg-secondary { background: #64748b !important; }

/* ==========================================================
   ALERTS
   ========================================================== */
.alert {
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.885rem;
}

.alert-warning {
  background: var(--warning-soft);
  border-color: #fde68a;
  color: #92400e;
}

.alert-danger {
  background: var(--danger-soft);
  border-color: #fecaca;
  color: #991b1b;
}

.alert-success {
  background: var(--success-soft);
  border-color: #bbf7d0;
  color: #166534;
}

.alert-info {
  background: var(--info-soft);
  border-color: #a5f3fc;
  color: #155e75;
}

/* ==========================================================
   PROGRESS
   ========================================================== */
.progress {
  background: #e2e8f0;
  border-radius: var(--radius-pill);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}

.progress-bar {
  background: var(--primary);
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}

.progress-bar.bg-info { background: var(--info); }
.progress-bar.bg-success { background: var(--success); }

/* ==========================================================
   SEARCH RESULT CARDS (injected by API responses)
   ========================================================== */
#masterResult .card,
#result .card,
#vehicleResult .card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

#masterResult .card-header,
#result .card-header,
#vehicleResult .card-header {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* ==========================================================
   SPINNERS & LOADING
   ========================================================== */
.spinner-border {
  width: 2.4rem;
  height: 2.4rem;
  color: var(--primary);
}

.spinner-border-sm {
  width: 1rem;
  height: 1rem;
  border-width: 0.18em;
}

/* ==========================================================
   UTILITIES
   ========================================================== */
.text-muted { color: var(--text-muted) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-primary { color: var(--primary) !important; }
.text-info { color: var(--info) !important; }

.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow { box-shadow: var(--shadow) !important; }
.shadow-md { box-shadow: var(--shadow-md) !important; }
.shadow-lg { box-shadow: var(--shadow-lg) !important; }

/* ==========================================================
   RESPONSIVE
   ========================================================== */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-backdrop.show {
    display: block;
  }

  .main {
    margin-left: 0;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .page-content {
    padding: 20px 16px 32px;
  }

  .topbar {
    padding: 0 16px;
  }

  .user-chip .user-meta span {
    display: none;
  }
}

@media (max-width: 575.98px) {
  .topbar-user .user-chip .user-meta {
    display: none;
  }

  .page-content {
    padding: 16px 12px 28px;
  }

  .stat-card .stat-value {
    font-size: 1.6rem;
  }

  .search-hero {
    padding: 20px 16px;
  }

  .table thead th {
    letter-spacing: 0.03em;
  }
}
