/* ============================================================
   NteMart Admin — Design System v3
   Dark sidebar + Clean card-based content
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---- CSS Variables ---- */
:root {
  --sidebar-bg:    #0f172a;
  --sidebar-text:  #94a3b8;
  --sidebar-active-bg: rgba(22, 163, 74, 0.15);
  --sidebar-active-text: #4ade80;
  --sidebar-hover-bg: rgba(255,255,255,0.05);
  --sidebar-border: rgba(255,255,255,0.08);
  --sidebar-width:  240px;

  --green:        #16a34a;
  --green-light:  #dcfce7;
  --green-text:   #15803d;
  --blue:         #2563eb;
  --blue-light:   #dbeafe;
  --orange:       #ea580c;
  --orange-light: #ffedd5;
  --red:          #dc2626;
  --red-light:    #fee2e2;
  --purple:       #7c3aed;
  --purple-light: #ede9fe;
  --yellow:       #d97706;
  --yellow-light: #fef3c7;

  --bg:           #f1f5f9;
  --card:         #ffffff;
  --border:       #e2e8f0;
  --border-light: #f1f5f9;

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.06);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --transition: 0.18s ease;

  --topbar-height: 64px;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--sidebar-border);
  text-decoration: none;
}
.sidebar-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--green), #15803d);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.sidebar-logo-text {
  font-size: 1rem;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: -0.02em;
}
.sidebar-logo-sub {
  font-size: 0.65rem;
  color: var(--sidebar-text);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar-section {
  padding: 1.25rem 0.75rem 0.5rem;
}
.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sidebar-text);
  padding: 0 0.5rem;
  margin-bottom: 0.375rem;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--sidebar-text);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
}
.sidebar-link i { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-link:hover { background: var(--sidebar-hover-bg); color: #f8fafc; }
.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}
.sidebar-link .badge-count {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}
.sidebar-footer {
  margin-top: auto;
  padding: 1rem 0.75rem;
  border-top: 1px solid var(--sidebar-border);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
}
.sidebar-user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), #06b6d4);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sidebar-user-name { font-size: 0.8rem; font-weight: 600; color: #f8fafc; }
.sidebar-user-role { font-size: 0.68rem; color: var(--sidebar-text); }

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ---- Top Bar ---- */
.top-bar {
  height: var(--topbar-height);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.top-bar-title { font-size: 1.125rem; font-weight: 700; color: var(--text-primary); }
.top-bar-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 1px; }
.top-bar-actions { display: flex; align-items: center; gap: 0.75rem; }
.top-bar-btn {
  display: flex; align-items: center; gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.825rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: all var(--transition);
}
.top-bar-btn.primary { background: var(--green); color: #fff; }
.top-bar-btn.primary:hover { background: #15803d; }
.top-bar-btn.secondary { background: var(--border-light); color: var(--text-secondary); border: 1px solid var(--border); }
.top-bar-btn.secondary:hover { background: var(--border); }

/* Page Content */
.page-content {
  padding: 2rem;
  flex: 1;
}

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: box-shadow var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); }
.kpi-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.125rem;
}
.kpi-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 1.625rem; font-weight: 800; color: var(--text-primary); letter-spacing: -0.03em; line-height: 1; }
.kpi-change { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); }
.kpi-change .up { color: var(--green); }
.kpi-change .down { color: var(--red); }

/* Specific KPI icon colors */
.kpi-green { background: var(--green-light); color: var(--green-text); }
.kpi-blue  { background: var(--blue-light);  color: var(--blue); }
.kpi-orange{ background: var(--orange-light); color: var(--orange); }
.kpi-purple{ background: var(--purple-light); color: var(--purple); }
.kpi-red   { background: var(--red-light);    color: var(--red); }
.kpi-yellow{ background: var(--yellow-light); color: var(--yellow); }

/* ============================================================
   CARDS & PANELS
   ============================================================ */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.125rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); }
.card-subtitle { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.card-body { padding: 1.5rem; }
.card-body-sm { padding: 1rem 1.5rem; }

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.25rem; }
.grid-3-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; }

/* ============================================================
   DATA TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.825rem;
}
thead th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--border-light);
  border-bottom: 1px solid var(--border);
}
thead th:first-child { border-radius: var(--radius-sm) 0 0 0; padding-left: 1.5rem; }
thead th:last-child  { border-radius: 0 var(--radius-sm) 0 0; padding-right: 1.5rem; }
tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child { border-bottom: none; }
tbody td {
  padding: 0.875rem 1rem;
  color: var(--text-primary);
  vertical-align: middle;
}
tbody td:first-child { padding-left: 1.5rem; }
tbody td:last-child  { padding-right: 1.5rem; }

.text-right { text-align: right; }
.text-center { text-align: center; }

/* Expandable row */
.expand-row { cursor: pointer; }
.expand-row:hover td { background: #f0fdf4; }
.expand-content td { background: #f8fafc; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); }
.expand-content { display: none; }
.expand-content.open { display: table-row; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-green   { background: var(--green-light);  color: var(--green-text); }
.badge-blue    { background: var(--blue-light);   color: var(--blue); }
.badge-orange  { background: var(--orange-light); color: var(--orange); }
.badge-red     { background: var(--red-light);    color: var(--red); }
.badge-purple  { background: var(--purple-light); color: var(--purple); }
.badge-yellow  { background: var(--yellow-light); color: var(--yellow); }
.badge-gray    { background: #f1f5f9; color: #64748b; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn i { font-size: 0.9rem; }
.btn-primary  { background: var(--green); color: #fff; }
.btn-primary:hover { background: #15803d; box-shadow: 0 0 0 3px rgba(22,163,74,0.2); }
.btn-secondary{ background: #fff; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border-light); }
.btn-danger   { background: var(--red-light); color: var(--red); }
.btn-danger:hover { background: #fecaca; }
.btn-warning  { background: var(--orange-light); color: var(--orange); }
.btn-warning:hover { background: #fed7aa; }
.btn-blue     { background: var(--blue-light); color: var(--blue); }
.btn-blue:hover { background: #bfdbfe; }
.btn-icon { padding: 0.4rem 0.5rem; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.75rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 0.9rem; }

/* ============================================================
   FORMS & MODALS
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none; align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 90%; max-width: 620px;
  max-height: 90vh; overflow-y: auto;
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 50%; border: none; cursor: pointer;
  background: var(--border-light); color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center; font-size: 0.9rem;
}
.modal-close:hover { background: var(--border); }
.modal-body { padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

.form-group { display: flex; flex-direction: column; gap: 0.375rem;}
.form-group label { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.6rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.85rem;
  color: var(--text-primary); background: #fff;
  transition: border var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22,163,74,0.15);
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.875rem 1rem;
  background: var(--border-light); border-radius: var(--radius-sm);
}
.toggle-label { font-size: 0.85rem; font-weight: 600; }
.toggle-sub { font-size: 0.75rem; color: var(--text-muted); }
input[type="checkbox"].toggle { width: 40px; height: 22px; appearance: none; background: var(--border); border-radius: 999px; cursor: pointer; position: relative; transition: background 0.2s; }
input[type="checkbox"].toggle:checked { background: var(--green); }
input[type="checkbox"].toggle::after { content: ''; position: absolute; width: 18px; height: 18px; background: #fff; border-radius: 50%; top: 2px; left: 2px; transition: left 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
input[type="checkbox"].toggle:checked::after { left: 20px; }

/* ============================================================
   SEARCH / FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 1.25rem; flex-wrap: wrap;
}
.search-wrap {
  position: relative; flex: 1; min-width: 200px; max-width: 360px;
}
.search-wrap i { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-input {
  width: 100%; padding: 0.55rem 0.875rem 0.55rem 2.25rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.825rem; color: var(--text-primary);
  background: #fff; outline: none;
  transition: border var(--transition), box-shadow var(--transition);
}
.search-input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22,163,74,0.1); }

.filter-select {
  padding: 0.55rem 0.875rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.825rem; background: #fff; color: var(--text-primary); cursor: pointer;
}
.chip-strip { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.chip {
  padding: 0.375rem 0.875rem;
  border-radius: 999px;
  font-size: 0.75rem; font-weight: 600;
  cursor: pointer; border: 1.5px solid var(--border);
  background: #fff; color: var(--text-secondary);
  transition: all var(--transition);
}
.chip.active { background: var(--green); color: #fff; border-color: var(--green); }

/* ============================================================
   CHART CONTAINERS
   ============================================================ */
.chart-container { position: relative; }
.chart-container canvas { max-width: 100%; }

/* ============================================================
   MISC
   ============================================================ */
.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: 0.75rem; }
.empty-state-title { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.25rem; color: var(--text-secondary); }

.skeleton { background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 4px; }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* Toast */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  background: var(--sidebar-bg); color: #f8fafc;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.825rem; font-weight: 500;
  animation: toastIn 0.2s ease;
  max-width: 300px;
}
.toast.success i { color: var(--green); }
.toast.error i   { color: var(--red); }
@keyframes toastIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Product thumbnail */
.product-thumb {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  object-fit: cover; border: 1px solid var(--border);
}

/* Vendor rating stars */
.stars { color: var(--yellow); font-size: 0.8rem; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

/* Auth page */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-bg);
}
.auth-card {
  background: var(--card);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 2rem;
}
.auth-logo-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--green), #15803d);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.25rem;
}
.auth-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 0.25rem; }
.auth-sub { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 2rem; }
.auth-error {
  padding: 0.75rem 1rem;
  background: var(--red-light); color: var(--red);
  border-radius: var(--radius-sm); font-size: 0.82rem; font-weight: 500;
  margin-bottom: 1rem; display: none;
}
.auth-btn {
  width: 100%; padding: 0.875rem;
  background: var(--green); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-size: 0.925rem; font-weight: 700; cursor: pointer;
  transition: background var(--transition);
  margin-top: 0.5rem;
}
.auth-btn:hover { background: #15803d; }

/* Responsive */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3, .grid-3-1 { grid-template-columns: 1fr; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}