/* ─── RESET & BASE ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0C0C0E;
  --surface:    #141416;
  --surface2:   #1C1C1F;
  --border:     rgba(255,255,255,0.07);
  --border2:    rgba(255,255,255,0.12);
  --text:       #F0EFE9;
  --text-muted: #9B9A96;
  --red:        #E0182D;
  --red-dark:   #B8101F;
  --gold:       #D4A847;
  --green:      #4ade80;
  --yellow:     #facc15;
  --blue:       #60a5fa;
  --sidebar-w:  260px;
  --nav-h:      62px;
  --radius:     12px;
  --radius-lg:  18px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: clip;
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ─── SCROLLBAR ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 99px; }

/* ─── LAYOUT ────────────────────────────────────────────────── */
.admin-wrap {
  display: flex;
  min-height: 100vh;
}

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

.sidebar-logo {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo img {
  height: 32px;
  object-fit: contain;
}

.sidebar-logo-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

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

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 12px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 600;
  transition: all 0.2s;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.nav-item.active {
  background: rgba(224, 24, 45, 0.12);
  color: var(--red);
}

.nav-item i {
  width: 18px;
  text-align: center;
  font-size: 14px;
}

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

/* ─── TOPBAR ────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--nav-h);
  background: rgba(12,12,14,0.95);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  z-index: 99;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-admin {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.topbar-avatar {
  width: 34px;
  height: 34px;
  background: var(--red);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 18px;
  padding: 4px;
}

/* ─── MAIN CONTENT ──────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  padding-top: var(--nav-h);
  flex: 1;
  overflow-x: auto;
  min-height: 100vh;
}

.page-body {
  max-width: 100%;
  overflow-x: auto;
  padding: 28px;
}

/* ─── PAGE HEADER ───────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 20px;
  font-weight: 800;
}

.page-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── STAT CARDS ────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: 100%;
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color 0.2s;
}

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

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.stat-icon.red    { background: rgba(224,24,45,0.12);  color: var(--red); }
.stat-icon.gold   { background: rgba(212,168,71,0.12); color: var(--gold); }
.stat-icon.green  { background: rgba(74,222,128,0.12); color: var(--green); }
.stat-icon.blue   { background: rgba(96,165,250,0.12); color: var(--blue); }

.stat-info { flex: 1; min-width: 0; }

.stat-val {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
}

.stat-lbl {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 2px;
}

/* ─── CARD ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  .card-overflow-fix { overflow: visible; }
}

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

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

.card-body { padding: 20px; }

/* ─── TABLE ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

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

thead th {
  background: var(--surface2);
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  white-space: nowrap;
}

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

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.02); }

/* ─── BADGES ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
  white-space: nowrap;
}

.badge-new        { background: rgba(96,165,250,0.15);  color: var(--blue); }
.badge-confirmed  { background: rgba(212,168,71,0.15);  color: var(--gold); }
.badge-processing { background: rgba(212,168,71,0.15);  color: var(--gold); }
.badge-shipped    { background: rgba(96,165,250,0.15);  color: var(--blue); }
.badge-delivered  { background: rgba(74,222,128,0.15);  color: var(--green); }
.badge-cancelled  { background: rgba(224,24,45,0.15);   color: var(--red); }
.badge-returned   { background: rgba(155,154,150,0.15); color: var(--text-muted); }
.badge-pending    { background: rgba(250,204,21,0.15);  color: var(--yellow); }
.badge-paid       { background: rgba(74,222,128,0.15);  color: var(--green); }
.badge-failed     { background: rgba(224,24,45,0.15);   color: var(--red); }
.badge-success    { background: rgba(74,222,128,0.15);  color: var(--green); }
.badge-cod        { background: rgba(155,154,150,0.15); color: var(--text-muted); }
.badge-prepaid    { background: rgba(212,168,71,0.15);  color: var(--gold); }
.badge-order      { background: rgba(74,222,128,0.15);  color: var(--green); }
.badge-abandoned  { background: rgba(224,24,45,0.15);   color: var(--red); }

/* ─── BUTTONS ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 700;
  border: none;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--red);
  color: #fff;
}
.btn-primary:hover { background: var(--red-dark); }

.btn-ghost {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border2);
}
.btn-ghost:hover { border-color: var(--red); color: var(--red); }

.btn-danger {
  background: rgba(224,24,45,0.12);
  color: var(--red);
  border: 1px solid rgba(224,24,45,0.2);
}
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
  border-radius: 8px;
}

/* ─── FORMS ─────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.form-control:focus { border-color: var(--red); }

.form-control select { appearance: none; cursor: pointer; }

textarea.form-control { resize: vertical; min-height: 90px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row.col-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

/* ─── FILTERS BAR ───────────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-input {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.filter-input:focus { border-color: var(--red); }

.filter-select {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  cursor: pointer;
}

/* ─── PAGINATION ────────────────────────────────────────────── */
.pagination-wrap {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

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

.pagination {
  display: flex;
  gap: 4px;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border2);
  color: var(--text-muted);
  transition: all 0.2s;
}

.pagination a:hover { border-color: var(--red); color: var(--red); }
.pagination .active span,
.pagination span.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* ─── ALERTS ────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.alert-success {
  background: rgba(74,222,128,0.1);
  border: 1px solid rgba(74,222,128,0.2);
  color: var(--green);
}

.alert-error {
  background: rgba(224,24,45,0.1);
  border: 1px solid rgba(224,24,45,0.2);
  color: var(--red);
}

/* ─── DETAIL VIEW ───────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.detail-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.detail-row:last-child { border-bottom: none; }

.detail-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.detail-val {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ─── LOGIN PAGE ────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
}

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

.login-logo img { height: 36px; margin: 0 auto 10px; }

.login-logo h1 {
  font-size: 20px;
  font-weight: 800;
}

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

/* ─── EMPTY STATE ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 40px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 14px;
  font-weight: 600;
}

/* ─── LOGOUT FORM ───────────────────────────────────────────── */
.logout-form { margin: 0; }

.logout-btn {
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.logout-btn:hover {
  background: rgba(224,24,45,0.1);
  color: var(--red);
}

/* ─── MOBILE OVERLAY ────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

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

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .topbar {
    left: 0;
  }

  .main-content {
    margin-left: 0;
  }

  overflow-x: auto;
  .hamburger {
    display: flex;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .form-row.col-3 {
    grid-template-columns: 1fr;
  }

  .page-body {
  max-width: 100%;
  overflow-x: auto;
    padding: 16px;
  }
}

@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table { min-width: 1100px; width: max-content; }


/* ─── STICKY LAST COLUMN ─────────────────────────────────────── */
.data-table th:last-child,
.data-table td:last-child {
  position: sticky;
  right: 0;
  background: var(--surface);
  z-index: 1;
  box-shadow: -2px 0 6px rgba(0,0,0,0.15);
}

/* ─── MOBILE FIXES ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stat-card {
    padding: 14px;
    gap: 10px;
  }

  .stat-icon {
    width: 38px;
    height: 38px;
    font-size: 16px;
    flex-shrink: 0;
  }

  .stat-value {
    font-size: 20px;
  }

  .stat-label {
    font-size: 11px;
  }

  .page-body {
    padding: 14px;
  }

  .filters-bar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .filter-input,
  .filter-select {
    width: 100% !important;
  }

  .data-table th:last-child,
  .data-table td:last-child {
    position: sticky;
    right: 0;
    background: var(--surface);
    z-index: 1;
  }
}

/* ─── RESPONSIVE FIXES ───────────────────────────────────────── */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px;
    margin-bottom: 14px;
  }
  .stat-card   { padding: 14px; }
  .stat-icon   { width: 34px; height: 34px; font-size: 14px; }
  .stat-value  { font-size: 22px !important; }
  .stat-label  { font-size: 11px; }
  .page-body   { padding: 14px; }
  .filters-bar { flex-wrap: wrap; gap: 8px; }
  .filter-input, .filter-select { width: 100% !important; }
}

/* ══════════════════════════════════════
   MOBILE RESPONSIVE — Complete Fix
══════════════════════════════════════ */
@media (max-width: 768px) {

  /* Sidebar */
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 8px 0 40px rgba(0,0,0,0.5); }
  .hamburger { display: flex; }

  /* Main layout */
  .main-content { margin-left: 0; }
  .topbar { left: 0; padding: 0 14px; }
  .topbar-title { font-size: 15px; }

  /* Page */
  .page-body { padding: 14px; }

  /* Stats — always 2 cols */
  .stats-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px;
    margin-bottom: 14px;
  }
  .stat-card  { padding: 14px; gap: 10px; }
  .stat-icon  { width: 34px; height: 34px; font-size: 14px; flex-shrink: 0; }
  .stat-value { font-size: 20px !important; }
  .stat-label { font-size: 11px; }

  /* Cards */
  .card-header { padding: 14px 16px 12px; }
  .card-body   { padding: 14px 16px; }
  .card-title  { font-size: 13px; }

  /* Detail grid — single col */
  .detail-grid { grid-template-columns: 1fr !important; }

  /* Table */
  .table-wrap { border-radius: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 600px; font-size: 12px; }
  .data-table th { padding: 10px 12px; font-size: 10px; }
  .data-table td { padding: 10px 12px; font-size: 12px; }

  /* Filters */
  .filters-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .filter-input,
  .filter-select { width: 100% !important; max-width: 100% !important; }

  /* Page header */
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-header h1 { font-size: 20px; }
  .page-header div[style*="gap"] { flex-wrap: wrap; }

  /* Buttons */
  .btn    { font-size: 12px; padding: 7px 14px; }
  .btn-sm { font-size: 11px; padding: 5px 10px; }

  /* Pagination */
  .pagination-wrap { flex-direction: column; gap: 8px; padding: 12px 16px; }

  /* Form rows */
  .form-row     { grid-template-columns: 1fr !important; }
  .form-row.col-3 { grid-template-columns: 1fr !important; }

  /* Tabs */
  .tabs { overflow-x: auto; white-space: nowrap; }

  /* Topbar avatar text — hide on small */
  .topbar-admin span:not(.topbar-avatar) { display: none; }
}

@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 8px; }
  .stat-card  { padding: 12px; }
  .page-body  { padding: 12px; }
}

/* ─── REPORT TABLE FIX ───────────────────────────────────────── */
.card { overflow: visible !important; }
.table-wrap { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
.page-body { overflow-x: auto; }
.main-content { overflow-x: auto; }

/* ─── OVERFLOW SCROLL FIX ────────────────────────────────────── */
.admin-wrap {
  overflow-x: hidden;
}
.main-content {
  width: calc(100vw - var(--sidebar-w));
  max-width: calc(100vw - var(--sidebar-w));
  overflow-x: auto;
  box-sizing: border-box;
}
.page-body {
  min-width: 0;
  overflow-x: auto;
}
.card {
  min-width: 0;
}
.table-wrap {
  overflow-x: auto !important;
  width: 100%;
}
@media (max-width: 900px) {
  .main-content {
    width: 100vw;
    max-width: 100vw;
  }
}
