/* =========================================================
   PREMART — Dashboard Stylesheet (Admin + Seller panels)
   Desktop-first, sidebar layout. Brand: deep violet + gold.
   ========================================================= */

:root {
  --primary: #6d28d9;
  --primary-dark: #5b21b6;
  --primary-light: #a78bfa;
  --accent: #f5c518;
  --accent-dark: #d4a40f;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info: #2563eb;
  --info-bg: #dbeafe;
  --neutral-bg: #f1f5f9;

  --bg: #f6f5fb;
  --sidebar-bg: #1c1233;
  --sidebar-bg-active: #2c1b54;
  --card: #ffffff;
  --text: #1e1b29;
  --text2: #6b6478;
  --text3: #a39fb0;
  --border: #e7e4f0;
  --shadow: 0 2px 14px rgba(31, 18, 64, 0.06);
  --shadow-md: 0 8px 28px rgba(31, 18, 64, 0.10);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 260px;
  --topbar-h: 68px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { font-family: inherit; }

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #e9e6f5;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand img { height: 34px; width: auto; }
.sidebar-brand-text { font-weight: 800; font-size: 1.05rem; color: #fff; letter-spacing: 0.2px; }
.sidebar-brand-tag { display: block; font-size: 0.68rem; color: var(--accent); font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.sidebar-section-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.6px;
  color: #7a7295; font-weight: 700; padding: 14px 12px 6px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px;
  color: #cbc6e0; font-weight: 600; font-size: 0.88rem;
  margin-bottom: 2px; transition: background 0.15s, color 0.15s;
}
.sidebar-link i { width: 18px; text-align: center; font-size: 0.95rem; opacity: 0.85; }
.sidebar-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-link.active { background: var(--sidebar-bg-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-link .nav-badge {
  margin-left: auto; background: var(--accent); color: #1c1233;
  font-size: 0.68rem; font-weight: 800; padding: 1px 7px; border-radius: 8px;
}

.sidebar-footer { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.sidebar-user img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--primary-light); }
.sidebar-user-name { font-size: 0.85rem; font-weight: 700; color: #fff; }
.sidebar-user-role { font-size: 0.72rem; color: #9b93b8; text-transform: capitalize; }

.main-area { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 100;
}
.topbar-title { font-size: 1.15rem; font-weight: 800; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.topbar-icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: var(--neutral-bg); display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text2); position: relative; font-size: 0.95rem;
}
.topbar-icon-btn .dot { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 10px; background: var(--danger); border: 1.5px solid var(--card); display: flex; align-items: center; justify-content: center; font-size: 0.62rem; font-weight: 800; color: #fff; line-height: 1; }
.menu-toggle { display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text); }

.page-content { padding: 24px; flex: 1; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.page-header h1 { font-size: 1.4rem; font-weight: 800; }
.page-subtitle { color: var(--text2); font-size: 0.88rem; margin-top: 2px; }
.breadcrumb { font-size: 0.8rem; color: var(--text3); margin-bottom: 4px; }
.breadcrumb a { color: var(--primary); font-weight: 600; }

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: none;
  font-weight: 700; font-size: 0.86rem; cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: #2b2206; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text2); }
.btn-ghost:hover { background: var(--neutral-bg); }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* =========================================================
   CARDS / STATS
   ========================================================= */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; border: 1px solid var(--border);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h3 { font-size: 1rem; font-weight: 800; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 18px 20px;
  border: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; align-items: flex-start; justify-content: space-between;
}
.stat-info .stat-label { font-size: 0.78rem; color: var(--text2); font-weight: 600; margin-bottom: 6px; }
.stat-info .stat-value { font-size: 1.55rem; font-weight: 800; }
.stat-info .stat-delta { font-size: 0.75rem; font-weight: 700; margin-top: 6px; }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }
.stat-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
  flex-shrink: 0;
}
.stat-icon.purple { background: #ede9fe; color: var(--primary); }
.stat-icon.gold { background: #fef9c3; color: var(--accent-dark); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.blue { background: var(--info-bg); color: var(--info); }
.stat-icon.red { background: var(--danger-bg); color: var(--danger); }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }

/* =========================================================
   TABLES
   ========================================================= */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
table.data-table th {
  text-align: left; padding: 10px 14px; color: var(--text2);
  font-weight: 700; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.4px;
  border-bottom: 1.5px solid var(--border); white-space: nowrap;
}
table.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tbody tr:hover { background: var(--neutral-bg); }
table.data-table tbody tr:last-child td { border-bottom: none; }
.cell-main { font-weight: 700; }
.cell-sub { font-size: 0.78rem; color: var(--text3); }
.table-thumb { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; background: var(--neutral-bg); }

.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.table-search { display: flex; align-items: center; gap: 8px; background: var(--neutral-bg); border-radius: var(--radius-sm); padding: 9px 14px; min-width: 240px; }
.table-search input { border: none; background: none; outline: none; font-size: 0.85rem; width: 100%; color: var(--text); }
.table-search i { color: var(--text3); }

.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 16px; }
.pagination a, .pagination span {
  min-width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-size: 0.82rem; font-weight: 700; color: var(--text2);
}
.pagination a:hover { background: var(--neutral-bg); }
.pagination .active { background: var(--primary); color: #fff; }

/* =========================================================
   BADGES
   ========================================================= */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 700;
  text-transform: capitalize; white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }
.badge-info    { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--neutral-bg); color: var(--text2); }

/* =========================================================
   FORMS
   ========================================================= */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label.form-label { display: block; font-size: 0.82rem; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.form-hint { font-size: 0.74rem; color: var(--text3); margin-top: 4px; }
.form-control {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 0.88rem; font-family: var(--font);
  background: var(--card); color: var(--text); outline: none; transition: border-color 0.15s;
}
.form-control:focus { border-color: var(--primary); }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }
.input-prefix-group { display: flex; align-items: stretch; }
.input-prefix-group .prefix { background: var(--neutral-bg); border: 1.5px solid var(--border); border-right: none; border-radius: var(--radius-sm) 0 0 var(--radius-sm); padding: 11px 12px; font-weight: 700; color: var(--text2); display: flex; align-items: center; }
.input-prefix-group .form-control { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.upload-box {
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  padding: 24px; text-align: center; color: var(--text2); cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.upload-box:hover { border-color: var(--primary); background: #faf8ff; }
.upload-box i { font-size: 1.6rem; color: var(--primary-light); margin-bottom: 8px; display: block; }
.upload-preview { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.upload-preview img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

.toggle-switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 24px; transition: 0.2s; }
.toggle-slider::before { content: ''; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.2s; }
.toggle-switch input:checked + .toggle-slider { background: var(--success); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* =========================================================
   ALERTS / TOASTS
   ========================================================= */
.alert { padding: 13px 16px; border-radius: var(--radius-sm); font-size: 0.86rem; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.alert-success { background: var(--success-bg); color: #14532d; }
.alert-danger { background: var(--danger-bg); color: #7f1d1d; }
.alert-warning { background: var(--warning-bg); color: #78350f; }
.alert-info { background: var(--info-bg); color: #1e3a5f; }

#toastStack { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--text); color: #fff; padding: 12px 18px; border-radius: 10px;
  font-size: 0.85rem; font-weight: 600; box-shadow: var(--shadow-md);
  animation: toastIn 0.25s ease; display: flex; align-items: center; gap: 8px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================================
   MODALS
   ========================================================= */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,12,40,0.55);
  display: none; align-items: center; justify-content: center; z-index: 500; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal-box { background: var(--card); border-radius: var(--radius); max-width: 480px; width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-md); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1.05rem; font-weight: 800; }
.modal-close { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--text2); }
.modal-body { padding: 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* =========================================================
   TABS
   ========================================================= */
.tabs { display: flex; gap: 4px; border-bottom: 1.5px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab-btn { padding: 11px 18px; font-weight: 700; font-size: 0.85rem; color: var(--text2); border-bottom: 2.5px solid transparent; white-space: nowrap; cursor: pointer; background:none; border-top:none;border-left:none;border-right:none; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* =========================================================
   EMPTY STATES
   ========================================================= */
.empty-state { text-align: center; padding: 56px 20px; color: var(--text2); }
.empty-state i { font-size: 2.6rem; color: var(--text3); margin-bottom: 14px; display: block; }
.empty-state h4 { font-size: 1rem; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 0.85rem; max-width: 320px; margin: 0 auto; }

/* =========================================================
   AUTH / LOGIN PAGES (admin + seller)
   ========================================================= */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(150deg, #1c1233 0%, #3b1f6e 55%, #6d28d9 100%); padding: 20px; }
.auth-card { background: var(--card); border-radius: 18px; width: 100%; max-width: 400px; padding: 38px 32px; box-shadow: 0 20px 60px rgba(0,0,0,0.35); }
.auth-logo { text-align: center; margin-bottom: 20px; }
.auth-logo img { height: 52px; }
.auth-role-tag { text-align: center; font-size: 0.74rem; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--primary); margin-bottom: 4px; }
.auth-title { text-align: center; font-size: 1.3rem; font-weight: 800; margin-bottom: 4px; }
.auth-subtitle { text-align: center; color: var(--text2); font-size: 0.85rem; margin-bottom: 26px; }
.auth-footer-link { text-align: center; margin-top: 18px; font-size: 0.85rem; color: var(--text2); }
.auth-demo-box { background: var(--neutral-bg); border-radius: 10px; padding: 12px 14px; font-size: 0.76rem; color: var(--text2); margin-top: 18px; line-height: 1.5; }
.auth-demo-box code { background: #fff; padding: 1px 6px; border-radius: 4px; font-weight: 700; }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .page-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 14px; }
}

/* Sidebar overlay for mobile */
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 150; display: none; }
.sidebar-overlay.show { display: block; }

/* Scrollbar */
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* Print: barcode label sheets */
@media print {
  .no-print { display: none !important; }
}

/* PP (point value) badge shown alongside prices in admin/seller tables */
.pp-badge {
  display: inline-block; background: var(--secondary, #f5c518); color: #2b2206;
  font-size: 0.68rem; font-weight: 800; padding: 1px 6px; border-radius: 4px;
  margin-left: 4px; vertical-align: middle;
}

/* Shared pagination control (admin & seller panels) */
.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 14px 0; }
.page-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 8px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card); color: var(--text2);
  font-size: 0.82rem; font-weight: 700; text-decoration: none; transition: var(--transition);
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn.disabled { opacity: 0.4; pointer-events: none; }
.page-ellipsis { padding: 0 4px; color: var(--text3); }
.pagination-summary { font-size: 0.78rem; color: var(--text3); padding-bottom: 6px; }
