/* ============================================================
   NK Racing System — Custom Racing Theme
   Color Palette:
     Black  40%  #1a1a2e / #16213e / #0f0f0f
     Red    30%  #e63946 / #c1121f / #ff1744
     Blue   30%  #1565c0 / #0d47a1 / #1976d2
   ============================================================ */

:root {
  --nk-black:       #1a1a2e;
  --nk-black-dark:  #0f0f0f;
  --nk-black-light: #16213e;
  --nk-red:         #e63946;
  --nk-red-dark:    #c1121f;
  --nk-red-light:   #ff4d5a;
  --nk-blue:        #1565c0;
  --nk-blue-dark:   #0d47a1;
  --nk-blue-light:  #1976d2;
  --nk-white:       #f8f9fa;
  --nk-gray:        #adb5bd;
  --nk-sidebar-w:   260px;
}

/* ---- Reset & Base ----------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  background-color: #f0f2f5;
  font-family: 'Segoe UI', 'Kanit', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  color: #212529;
}

a { text-decoration: none; }

/* ---- Scrollbar -------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--nk-black-light); }
::-webkit-scrollbar-thumb { background: var(--nk-red); border-radius: 3px; }

/* ============================================================
   AUTH / LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--nk-black-dark) 0%, var(--nk-black) 40%, var(--nk-black-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(230,57,70,0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(21,101,192,0.15) 0%, transparent 60%);
  pointer-events: none;
}

.login-card {
  background: rgba(26,26,46,0.95);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo .brand-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--nk-red), var(--nk-blue));
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: 1rem;
  box-shadow: 0 8px 20px rgba(230,57,70,0.4);
}

.login-logo h1 {
  color: var(--nk-white);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin: 0;
}

.login-logo p {
  color: var(--nk-gray);
  font-size: 0.85rem;
  margin: 0.25rem 0 0;
}

.login-card .form-control {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--nk-white);
  border-radius: 8px;
  padding: 0.7rem 1rem;
  transition: border-color 0.2s, background 0.2s;
}
.login-card .form-control:focus {
  background: rgba(255,255,255,0.1);
  border-color: var(--nk-red);
  color: var(--nk-white);
  box-shadow: 0 0 0 3px rgba(230,57,70,0.2);
}
.login-card .form-control::placeholder { color: rgba(255,255,255,0.35); }
.login-card .form-label { color: var(--nk-gray); font-size: 0.85rem; font-weight: 500; }
.login-card .input-group-text {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--nk-gray);
}

/* ============================================================
   ADMIN LAYOUT
   ============================================================ */
.admin-wrapper { display: flex; min-height: 100vh; }

/* ---- Sidebar ---------------------------------------------- */
.sidebar {
  width: var(--nk-sidebar-w);
  background: linear-gradient(180deg, var(--nk-black-dark) 0%, var(--nk-black) 100%);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.sidebar-brand .brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--nk-red), var(--nk-blue));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(230,57,70,0.35);
}

.sidebar-brand .brand-text h5 {
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
  letter-spacing: 0.3px;
}
.sidebar-brand .brand-text small { color: var(--nk-gray); font-size: 0.7rem; }

.sidebar-nav { padding: 0.75rem 0; flex: 1; }

.nav-section-label {
  color: rgba(255,255,255,0.3);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 0.75rem 1.25rem 0.35rem;
  display: block;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1.25rem;
  color: rgba(255,255,255,0.65);
  font-size: 0.875rem;
  border-radius: 0;
  transition: all 0.2s;
  position: relative;
}

.sidebar-nav .nav-link i {
  width: 18px;
  text-align: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.sidebar-nav .nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,0.05);
}

.sidebar-nav .nav-link.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(230,57,70,0.25) 0%, rgba(21,101,192,0.15) 100%);
}
.sidebar-nav .nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--nk-red), var(--nk-blue));
  border-radius: 0 2px 2px 0;
}

/* Submenu */
.sidebar-nav .collapse .nav-link { padding-left: 2.75rem; font-size: 0.83rem; }

.sidebar-nav .nav-item.has-submenu > .nav-link::after {
  content: '\f107';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  margin-left: auto;
  font-size: 0.75rem;
  transition: transform 0.2s;
}
.sidebar-nav .nav-item.has-submenu > .nav-link[aria-expanded="true"]::after {
  transform: rotate(180deg);
}

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

/* ---- Topbar ----------------------------------------------- */
.topbar {
  margin-left: var(--nk-sidebar-w);
  background: #fff;
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  position: sticky; top: 0;
  z-index: 1030;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  transition: margin-left 0.3s;
}

.topbar .page-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--nk-black);
  margin: 0;
}

.topbar .topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }

.topbar .user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--nk-red), var(--nk-blue));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.85rem; font-weight: 600;
  cursor: pointer;
}

/* ---- Main Content ----------------------------------------- */
.main-content {
  margin-left: var(--nk-sidebar-w);
  padding: 1.5rem;
  min-height: calc(100vh - 60px);
  transition: margin-left 0.3s;
}

/* ============================================================
   CARDS & COMPONENTS
   ============================================================ */
.nk-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  margin-bottom: 1.5rem;
}

.nk-card .card-header {
  background: transparent;
  border-bottom: 1px solid #e5e7eb;
  padding: 1rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between;
  border-radius: 12px 12px 0 0;
}

.nk-card .card-header h5 { margin: 0; font-size: 1rem; font-weight: 600; }
.nk-card .card-body { padding: 1.25rem; }

/* Stat Cards */
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  display: flex; align-items: center; gap: 1rem;
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

.stat-card .stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-icon.red   { background: rgba(230,57,70,0.1);  color: var(--nk-red); }
.stat-icon.blue  { background: rgba(21,101,192,0.1); color: var(--nk-blue); }
.stat-icon.dark  { background: rgba(26,26,46,0.08);  color: var(--nk-black); }
.stat-icon.green { background: rgba(25,135,84,0.1);  color: #198754; }

.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; color: var(--nk-black); }
.stat-card .stat-label { font-size: 0.8rem; color: #6c757d; margin-top: 0.2rem; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-nk-red {
  background: linear-gradient(135deg, var(--nk-red-dark), var(--nk-red));
  color: #fff; border: none; border-radius: 8px; font-weight: 500;
  transition: all 0.2s;
}
.btn-nk-red:hover { background: linear-gradient(135deg, var(--nk-red), var(--nk-red-light)); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(230,57,70,0.4); }

.btn-nk-blue {
  background: linear-gradient(135deg, var(--nk-blue-dark), var(--nk-blue));
  color: #fff; border: none; border-radius: 8px; font-weight: 500;
  transition: all 0.2s;
}
.btn-nk-blue:hover { background: linear-gradient(135deg, var(--nk-blue), var(--nk-blue-light)); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(21,101,192,0.4); }

.btn-nk-dark {
  background: linear-gradient(135deg, var(--nk-black-dark), var(--nk-black));
  color: #fff; border: none; border-radius: 8px; font-weight: 500;
  transition: all 0.2s;
}
.btn-nk-dark:hover { background: var(--nk-black-light); color: #fff; transform: translateY(-1px); }

/* ============================================================
   TABLES
   ============================================================ */
.nk-table { border-radius: 8px; overflow: hidden; }
.nk-table thead th {
  background: var(--nk-black);
  color: rgba(255,255,255,0.85);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border: none;
  padding: 0.85rem 1rem;
  white-space: nowrap;
}
.nk-table tbody tr { transition: background 0.15s; }
.nk-table tbody tr:hover { background: rgba(230,57,70,0.03); }
.nk-table tbody td { padding: 0.75rem 1rem; vertical-align: middle; font-size: 0.9rem; border-color: #f0f0f0; }

/* ============================================================
   FORMS
   ============================================================ */
.form-label { font-weight: 500; font-size: 0.875rem; color: #495057; }

.form-control, .form-select {
  border-radius: 8px;
  border: 1px solid #dee2e6;
  padding: 0.5rem 0.875rem;
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--nk-blue);
  box-shadow: 0 0 0 3px rgba(21,101,192,0.15);
}

.invalid-feedback { font-size: 0.8rem; }

/* ---- Section Header ------------------------------------- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.section-header h4 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--nk-black);
  display: flex; align-items: center; gap: 0.5rem;
}
.section-header h4::before {
  content: '';
  width: 4px; height: 22px;
  background: linear-gradient(180deg, var(--nk-red), var(--nk-blue));
  border-radius: 2px;
  display: inline-block;
}

/* ---- Badges --------------------------------------------- */
.badge-active   { background: rgba(25,135,84,0.12);  color: #198754; font-weight: 600; }
.badge-inactive { background: rgba(220,53,69,0.12);  color: #dc3545; font-weight: 600; }

/* ---- Role Badges ---------------------------------------- */
.role-badge {
  display: inline-block;
  padding: 0.25em 0.65em;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}
.role-admin    { background: rgba(230,57,70,0.12);   color: var(--nk-red); }
.role-manager  { background: rgba(21,101,192,0.12);  color: var(--nk-blue); }
.role-cashier  { background: rgba(25,135,84,0.12);   color: #198754; }
.role-mechanic { background: rgba(255,152,0,0.12);   color: #f57c00; }

/* ---- Image Preview -------------------------------------- */
.img-preview-wrap {
  width: 120px; height: 120px;
  border: 2px dashed #dee2e6;
  border-radius: 12px;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: #f8f9fa;
  cursor: pointer;
  transition: border-color 0.2s;
}
.img-preview-wrap:hover { border-color: var(--nk-blue); }
.img-preview-wrap img { width: 100%; height: 100%; object-fit: cover; }
.img-preview-wrap .placeholder { color: #adb5bd; text-align: center; font-size: 0.8rem; }
.img-preview-wrap .placeholder i { font-size: 2rem; display: block; margin-bottom: 0.25rem; }

/* ---- Barcode Modal -------------------------------------- */
.barcode-container {
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
}
.barcode-container svg { max-width: 100%; }
.barcode-sku {
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--nk-black);
  margin-top: 0.5rem;
}

/* ---- Alerts --------------------------------------------- */
.alert { border-radius: 10px; border: none; font-size: 0.9rem; }

/* ---- Pagination ----------------------------------------- */
.page-item .page-link {
  border-radius: 8px !important;
  margin: 0 2px;
  font-size: 0.875rem;
  color: var(--nk-black);
  border-color: #dee2e6;
}
.page-item.active .page-link {
  background: linear-gradient(135deg, var(--nk-red), var(--nk-blue));
  border-color: transparent;
  color: #fff;
}
.page-item .page-link:hover { background: #f0f2f5; color: var(--nk-red); }

/* ---- Breadcrumb ----------------------------------------- */
.breadcrumb { margin: 0; font-size: 0.82rem; }
.breadcrumb-item + .breadcrumb-item::before { color: #adb5bd; }
.breadcrumb-item a { color: var(--nk-blue); }
.breadcrumb-item.active { color: #6c757d; }

/* ---- Dividers with gradient ----------------------------- */
.divider-racing {
  height: 2px;
  background: linear-gradient(90deg, var(--nk-red), var(--nk-blue), transparent);
  border: none;
  margin: 1.5rem 0;
  opacity: 1;
}

/* ============================================================
   RESPONSIVE — collapse sidebar on small
   ============================================================ */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .topbar, .main-content { margin-left: 0; }

  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1039;
  }
  .sidebar-overlay.show { display: block; }
}

/* ---- Spinner -------------------------------------------- */
.nk-spinner-wrap {
  display: flex; align-items: center; justify-content: center;
  height: 200px;
}
