/* ── AaplaKart Admin Panel - Styles ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #f97316;
  --primary-dark: #ea580c;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --success: #22c55e;
  --danger: #ef4444;
  --warn: #eab308;
  --sidebar: #1e293b;
  --sidebar-text: #cbd5e1;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── TOAST ── */
.toast { position: fixed; top: 20px; right: 20px; padding: 14px 24px; border-radius: var(--radius); font-weight: 600; z-index: 9999; transform: translateX(120%); transition: transform 0.3s ease; max-width: 400px; }
.toast.show { transform: translateX(0); }
.toast.success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.toast.error { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

/* ── LOADING ── */
.loading { padding: 40px; text-align: center; color: var(--muted); font-size: 15px; }

/* ── ERROR / EMPTY ── */
.error-card { background: #fee2e2; border: 1px solid #fecaca; border-radius: var(--radius); padding: 20px; margin: 16px 0; color: #b91c1c; font-weight: 600; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); font-size: 16px; }

/* ── LOGIN ── */
.login-bg { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #fff7ed 0%, #fed7aa 100%); }
.login-card { background: white; border-radius: 24px; padding: 40px; width: 400px; max-width: 90vw; box-shadow: 0 20px 60px rgba(0,0,0,0.1); text-align: center; }
.login-logo { font-size: 48px; margin-bottom: 8px; }
.login-card h1 { font-size: 24px; color: var(--text); margin-bottom: 4px; }
.login-sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.login-error { background: #fee2e2; color: #b91c1c; padding: 10px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.login-hint { margin-top: 16px; font-size: 12px; color: var(--muted); }

/* ── DASHBOARD LAYOUT ── */
.sidebar { width: 240px; min-height: 100vh; background: var(--sidebar); color: var(--sidebar-text); padding: 0; display: flex; flex-direction: column; position: fixed; left: 0; top: 0; z-index: 100; }
.sidebar-brand { padding: 20px 20px 12px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-logo { font-size: 28px; }
.sidebar-title { font-size: 18px; font-weight: 800; color: white; }
.sidebar-user { padding: 12px 20px; font-size: 13px; border-bottom: 1px solid rgba(255,255,255,0.08); opacity: 0.8; }
.sidebar-nav { flex: 1; padding: 8px 0; }
.nav-item { display: block; padding: 12px 20px; color: var(--sidebar-text); text-decoration: none; cursor: pointer; font-size: 14px; transition: all 0.2s; border-left: 3px solid transparent; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-item.active { background: rgba(249,115,22,0.15); color: #f97316; border-left-color: #f97316; font-weight: 600; }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.08); padding: 8px 0; }
.main-content { margin-left: 240px; min-height: 100vh; padding: 0; }

/* ── TOP BAR ── */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 28px; background: white; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.topbar h2 { font-size: 20px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.clock { font-size: 13px; color: var(--muted); }
.btn-refresh { background: none; border: none; font-size: 18px; cursor: pointer; padding: 6px; border-radius: 8px; transition: background 0.2s; }
.btn-refresh:hover { background: var(--bg); }

/* ── TAB CONTENT ── */
.tab-content { padding: 24px 28px; }

/* ── STATS GRID ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; margin-bottom: 8px; }
.stat-card { background: white; border-radius: var(--radius); padding: 20px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: 12px; }
.stat-num { font-size: 28px; font-weight: 800; color: var(--text); }
.stat-label { font-size: 14px; color: var(--muted); margin-top: 2px; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; opacity: 0.8; }

/* ── BUTTONS ── */
.btn-primary { background: var(--primary); color: white; border: none; padding: 10px 20px; border-radius: 10px; font-weight: 600; font-size: 14px; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-full { width: 100%; justify-content: center; padding: 14px; font-size: 16px; }
.btn-sm { padding: 6px 8px; font-size: 14px; border-radius: 8px; border: none; cursor: pointer; transition: opacity 0.2s; }
.btn-sm:hover { opacity: 0.8; }
.btn-edit { background: #eff6ff; }
.btn-del { background: #fee2e2; }
.btn-toggle { background: #f3f4f6; }
.btn-refresh { background: none; border: none; font-size: 18px; cursor: pointer; }

/* ── CARD ── */
.card { background: white; border-radius: var(--radius); padding: 20px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.card h3 { font-size: 16px; margin-bottom: 14px; color: var(--text); }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; background: white; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow); }
.table thead { background: #f8fafc; }
.table th { padding: 12px 14px; text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 2px solid var(--border); }
.table td { padding: 10px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tbody tr:hover { background: #fafafa; }
.table tbody tr:last-child td { border-bottom: none; }
.table-footer { padding: 10px 14px; font-size: 13px; color: var(--muted); background: #f8fafc; border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius); }
.actions-cell { display: flex; gap: 4px; }
code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 12px; }

/* ── BADGES ── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-kart { background: #fff7ed; color: #f97316; }
.badge-waffle { background: #f3e8ff; color: #8b5cf6; }
.badge-instock { background: #dcfce7; color: #15803d; }
.badge-ostock { background: #fee2e2; color: #b91c1c; }
.badge-pay { background: #eff6ff; color: #2563eb; }
.badge-status-pending { background: #fef3c7; color: #92400e; }
.badge-status-confirmed { background: #dbeafe; color: #1e40af; }
.badge-status-preparing { background: #fff7ed; color: #c2410c; }
.badge-status-out_for_delivery { background: #f3e8ff; color: #6d28d9; }
.badge-status-delivered { background: #dcfce7; color: #15803d; }
.badge-status-cancelled { background: #fee2e2; color: #b91c1c; }
.badge-pos { background: #e0f2fe; color: #0369a1; }

/* ── FORM ── */
.form-group { margin-bottom: 14px; text-align: left; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.form-group input, .form-group select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: white; transition: border-color 0.2s; }
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(249,115,22,0.1); }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* ── TOOLBAR ── */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.toolbar-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-left select, .toolbar-left input { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: white; }
.toolbar-left input { width: 220px; }
.toolbar-left select:focus, .toolbar-left input:focus { outline: none; border-color: var(--primary); }

/* ── STATUS SELECT ── */
.status-select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; background: white; cursor: pointer; }

/* ── MODAL ── */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal { background: white; border-radius: 20px; padding: 0; width: 520px; max-width: 90vw; max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 17px; }
.modal-header button { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--muted); width: 32px; height: 32px; border-radius: 16px; display: flex; align-items: center; justify-content: center; }
.modal-header button:hover { background: var(--bg); }
.modal-body { padding: 24px; }

/* ── CATEGORIES ── */
.section-card { margin-bottom: 16px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.section-info { display: flex; align-items: center; gap: 10px; }
.section-info h3 { font-size: 16px; margin-bottom: 0; }
.categories-list { display: flex; flex-wrap: wrap; gap: 8px; }
.category-chip { background: #f1f5f9; padding: 6px 14px; border-radius: 20px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.cat-sub-count { font-size: 11px; color: var(--muted); background: white; padding: 1px 6px; border-radius: 10px; }
.empty-sub { color: var(--muted); font-size: 13px; padding: 4px 0; }

/* ── HEALTH ── */
.health-banner { padding: 16px 20px; border-radius: var(--radius); display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; font-size: 14px; }
.health-banner.ok { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.health-banner.degraded { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.health-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.health-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--bg); border-radius: 8px; font-size: 13px; }
.health-name { font-weight: 600; text-transform: capitalize; }
.health-status.ok { color: var(--success); }
.health-status.err { color: var(--danger); }
.health-grid-full { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.health-card { display: flex; gap: 14px; background: white; padding: 18px; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
.health-card.ok { border-left: 4px solid var(--success); }
.health-card.err { border-left: 4px solid var(--danger); }
.health-card-icon { font-size: 24px; }
.health-card-info h4 { font-size: 14px; margin-bottom: 4px; text-transform: capitalize; }
.health-msg, .health-detail { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-title, .sidebar-user, .nav-item span { display: none; }
  .sidebar-brand { justify-content: center; padding: 16px 0; }
  .sidebar-logo { font-size: 24px; }
  .nav-item { text-align: center; padding: 14px 0; font-size: 20px; border-left: none; border-bottom: 2px solid transparent; }
  .nav-item.active { border-left: none; border-bottom-color: var(--primary); }
  .main-content { margin-left: 60px; }
  .topbar { padding: 12px 16px; }
  .tab-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .table { font-size: 12px; }
  .table th, .table td { padding: 8px 10px; }
  .toolbar-left input { width: 140px; }
}
