/* =====================================================================
   Apna Hardware Shop — Design System  (BS Hardware ERP Style)
   ===================================================================== */

/* ── Google Font loaded via layout ── */

/* ── CSS Variables — Light Theme ───────────────────────────────────── */
:root {
  /* Sidebar */
  --sb-w:            230px;
  --sb-collapsed:    64px;
  --sb-bg:           #1a1f2e;
  --sb-bg2:          #141824;
  --sb-text:         #9ba8c0;
  --sb-hover-bg:     #252d42;
  --sb-active-bg:    #3b82f6;
  --sb-active-text:  #fff;
  --sb-border:       rgba(255,255,255,.07);
  --sb-icon:         #6b7a99;

  /* Header */
  --hdr-h:           56px;
  --hdr-bg:          #fff;
  --hdr-border:      #e8ecf0;

  /* Content */
  --bg:              #f0f2f5;
  --card-bg:         #ffffff;
  --card-border:     #e8ecf0;
  --card-radius:     12px;
  --text:            #1a1f2e;
  --text-muted:      #6b7a99;
  --text-light:      #9ba8c0;

  /* Brand colors */
  --primary:         #3b82f6;
  --primary-dark:    #2563eb;
  --primary-light:   #eff6ff;
  --success:         #22c55e;
  --warning:         #f59e0b;
  --danger:          #ef4444;
  --info:            #06b6d4;
  --purple:          #8b5cf6;
  --orange:          #f97316;

  /* Stat card colors */
  --stat-blue:       linear-gradient(135deg,#3b82f6,#1d4ed8);
  --stat-green:      linear-gradient(135deg,#22c55e,#15803d);
  --stat-orange:     linear-gradient(135deg,#f97316,#c2410c);
  --stat-purple:     linear-gradient(135deg,#8b5cf6,#6d28d9);

  /* Shadows */
  --shadow-sm:       0 1px 4px rgba(0,0,0,.08);
  --shadow-md:       0 4px 20px rgba(0,0,0,.10);
  --shadow-lg:       0 8px 40px rgba(0,0,0,.14);

  --radius:          12px;
  --radius-sm:       8px;
  --radius-xs:       6px;
  --transition:      .22s ease;
}

/* ── Dark Theme ─────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --sb-bg:           #0d1117;
  --sb-bg2:          #090d13;
  --sb-hover-bg:     #1a2235;

  --hdr-bg:          #161b2a;
  --hdr-border:      #1e2a3a;

  --bg:              #0f1623;
  --card-bg:         #161b2a;
  --card-border:     #1e2a3a;
  --text:            #e2e8f0;
  --text-muted:      #8899b4;
  --text-light:      #526070;
}

/* ── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App Shell ──────────────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

/* =====================================================================
   SIDEBAR
   ===================================================================== */
.sidebar {
  width: var(--sb-w);
  min-height: 100vh;
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 1000;
  transition: width var(--transition);
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sb-collapsed); }

/* Collapsed state — hide text, center icons */
.sidebar.collapsed .sb-brand        { padding: 14px 0; justify-content: center; }
.sidebar.collapsed .sb-brand-text   { display: none; }
.sidebar.collapsed .sb-logo-wrap    { margin: 0 auto; }
.sidebar.collapsed .sb-user         { padding: 8px 0; justify-content: center; }
.sidebar.collapsed .sb-user-name,
.sidebar.collapsed .sb-user-role    { display: none; }
.sidebar.collapsed .sb-avatar       { margin: 0 auto; }
.sidebar.collapsed .sb-help         { display: none; }
.sidebar.collapsed .sb-footer       { display: none; }

/* Brand */
.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--sb-bg2);
  border-bottom: 1px solid var(--sb-border);
  min-height: var(--hdr-h);
  overflow: hidden;
}
.sb-logo-wrap {
  width: 36px; height: 36px;
  background: linear-gradient(135deg,#f59e0b,#d97706);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.sb-brand-text .sb-title {
  font-size: 14px; font-weight: 700;
  color: #fff; white-space: nowrap; line-height: 1.2;
}
.sb-brand-text .sb-subtitle {
  font-size: 10px; color: #f59e0b; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  white-space: nowrap;
}

/* User Info */
.sb-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--sb-border);
  overflow: hidden;
}
.sb-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg,var(--primary),var(--primary-dark));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.sb-user-name {
  font-size: 13px; font-weight: 600;
  color: #fff; white-space: nowrap;
}
.sb-user-role {
  font-size: 11px; color: var(--sb-text);
  white-space: nowrap;
}
.sb-online-dot {
  width: 8px; height: 8px;
  background: var(--success);
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}

/* Nav */
.sb-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sb-nav::-webkit-scrollbar { width: 4px; }
.sb-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.sb-section-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: #3d4f6e;
  padding: 12px 16px 4px;
  white-space: nowrap; overflow: hidden;
  transition: opacity .2s, padding .2s, height .2s;
}
.sidebar.collapsed .sb-section-label {
  opacity: 0; height: 0; padding: 0; overflow: hidden;
}

.sb-nav-item { position: relative; }

.sb-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--sb-text);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  border: none; background: none; width: 100%; text-align: left;
  text-decoration: none;
  overflow: hidden;
}
.sb-nav-link:hover {
  background: var(--sb-hover-bg);
  color: #fff;
  text-decoration: none;
}
.sb-nav-link.active {
  background: var(--sb-active-bg);
  color: var(--sb-active-text);
}
.sb-nav-link .sb-nav-icon {
  width: 22px; min-width: 22px;
  text-align: center;
  font-size: 17px; flex-shrink: 0;
  color: inherit;
}
.sb-nav-link .sb-nav-text {
  flex: 1;
  transition: opacity .2s, width .2s;
  opacity: 1;
}
.sb-nav-link .sb-nav-arrow {
  font-size: 11px;
  transition: transform var(--transition), opacity .2s;
  margin-left: auto;
  flex-shrink: 0;
}
.sb-nav-link[aria-expanded="true"] .sb-nav-arrow { transform: rotate(90deg); }

/* ── Collapsed state — icon only ─────────────────────────────── */
.sidebar.collapsed .sb-nav-link {
  padding:        10px 0;
  justify-content:center;
  gap:            0;
}
.sidebar.collapsed .sb-nav-link .sb-nav-text  { opacity: 0; width: 0; overflow: hidden; }
.sidebar.collapsed .sb-nav-link .sb-nav-arrow { opacity: 0; width: 0; overflow: hidden; }
.sidebar.collapsed .sb-nav-link .sb-nav-icon  { width: 100%; text-align: center; font-size: 18px; }

/* Tooltip on collapsed hover */
.sidebar.collapsed .sb-nav-item {
  position: relative;
}
.sidebar.collapsed .sb-nav-link::after {
  content:    attr(data-label);
  position:   absolute;
  left:       calc(100% + 8px);
  top:        50%;
  transform:  translateY(-50%);
  background: #1e293b;
  color:      #fff;
  font-size:  12px;
  font-weight:600;
  padding:    5px 10px;
  border-radius: 6px;
  white-space:nowrap;
  pointer-events:none;
  opacity:    0;
  transition: opacity .15s;
  z-index:    9999;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
.sidebar.collapsed .sb-nav-link:hover::after {
  opacity: 1;
}

/* Submenu */
.sb-submenu { background: rgba(0,0,0,.2); }
.sb-submenu .sb-nav-link { padding-left: 44px; font-size: 13px; }
.sidebar.collapsed .sb-submenu { display: none; }

/* Help box */
.sb-help {
  margin: 12px;
  background: linear-gradient(135deg,#f59e0b22,#f59e0b11);
  border: 1px solid #f59e0b44;
  border-radius: 10px;
  padding: 12px;
  overflow: hidden;
}
.sb-help-title {
  font-size: 12px; font-weight: 700; color: #f59e0b;
  display: flex; align-items: center; gap: 6px;
}
.sb-help-phone { font-size: 12px; color: var(--sb-text); margin-top: 2px; }
.sidebar.collapsed .sb-help { display: none; }

/* Footer */
.sb-footer {
  padding: 10px 16px;
  font-size: 11px;
  color: #3d4f6e;
  border-top: 1px solid var(--sb-border);
  overflow: hidden;
  white-space: nowrap;
}

/* =====================================================================
   MAIN CONTENT AREA
   ===================================================================== */
.main-wrap {
  margin-left: var(--sb-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}
.main-wrap.expanded { margin-left: var(--sb-collapsed); }

/* =====================================================================
   TOP HEADER
   ===================================================================== */
.top-header {
  height: var(--hdr-h);
  background: var(--hdr-bg);
  border-bottom: 1px solid var(--hdr-border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0; z-index: 900;
  box-shadow: var(--shadow-sm);
}

/* Hamburger */
.hdr-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 20px;
  padding: 6px; border-radius: var(--radius-xs);
  transition: background var(--transition);
  flex-shrink: 0;
}
.hdr-toggle:hover { background: var(--bg); color: var(--primary); }

/* Search bar */
.hdr-search {
  flex: 1; max-width: 400px;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 6px 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.hdr-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.hdr-search i { color: var(--text-muted); font-size: 14px; }
.hdr-search input {
  border: none; background: none; outline: none;
  font-size: 13px; color: var(--text); flex: 1;
  font-family: inherit;
}
.hdr-search input::placeholder { color: var(--text-light); }
.hdr-search .search-shortcut {
  font-size: 11px; color: var(--text-light);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 4px; padding: 1px 5px;
  white-space: nowrap;
}

/* Scan button */
.btn-scan {
  background: #0ea5e9; color: #fff; border: none;
  padding: 7px 14px; border-radius: 7px;
  font-size: 12px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; gap: 6px;
  transition: background var(--transition);
  white-space: nowrap;
}
.btn-scan:hover { background: #0284c7; }

/* Quick Sale button */
.btn-quick-sale {
  background: var(--success); color: #fff; border: none;
  padding: 7px 14px; border-radius: 7px;
  font-size: 12px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; gap: 6px;
  transition: background var(--transition);
  white-space: nowrap;
}
.btn-quick-sale:hover { background: #16a34a; }

/* FY selector */
.fy-select {
  background: var(--bg); border: 1px solid var(--card-border);
  border-radius: 7px; padding: 6px 10px;
  font-size: 12px; font-weight: 600; color: var(--text);
  cursor: pointer; display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
}

/* Header right actions */
.hdr-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.hdr-btn {
  background: none; border: 1px solid var(--card-border);
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text-muted);
  cursor: pointer; position: relative;
  transition: all var(--transition);
}
.hdr-btn:hover { background: var(--bg); color: var(--primary); border-color: var(--primary); }

.notif-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 700;
  width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--hdr-bg);
}

/* Theme toggle */
.theme-toggle {
  background: var(--bg); border: 1px solid var(--card-border);
  border-radius: 8px; padding: 6px 10px;
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; transition: all var(--transition);
  white-space: nowrap;
}
.theme-toggle:hover { border-color: var(--primary); color: var(--primary); }

/* User profile */
.hdr-user {
  display: flex; align-items: center; gap: 8px;
  background: none; border: 1px solid var(--card-border);
  border-radius: 8px; padding: 5px 10px;
  cursor: pointer; transition: all var(--transition);
}
.hdr-user:hover { background: var(--bg); border-color: var(--primary); }
.hdr-user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg,var(--primary),var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 12px;
}
.hdr-user-name { font-size: 13px; font-weight: 600; color: var(--text); }

/* =====================================================================
   PAGE CONTENT
   ===================================================================== */
.page-content { padding: 20px; flex: 1; }

/* Page header row */
.page-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 10px;
}
.page-header h1 {
  font-size: 22px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.page-header .page-date {
  font-size: 13px; color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 8px; padding: 6px 12px;
}

/* =====================================================================
   STAT CARDS (image top-4 cards)
   ===================================================================== */
.stat-cards { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 20px; }

@media(max-width:1100px){ .stat-cards{ grid-template-columns: repeat(2,1fr); } }
@media(max-width:600px){  .stat-cards{ grid-template-columns: 1fr; } }

.stat-card {
  border-radius: var(--radius);
  padding: 20px;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.stat-card-blue   { background: var(--stat-blue); }
.stat-card-green  { background: var(--stat-green); }
.stat-card-orange { background: var(--stat-orange); }
.stat-card-purple { background: var(--stat-purple); }

.stat-card-icon {
  font-size: 36px; opacity: .3;
  position: absolute; right: 16px; top: 16px;
}
.stat-card-label {
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  opacity: .85; margin-bottom: 6px;
}
.stat-card-value {
  font-size: 28px; font-weight: 800; line-height: 1;
  margin-bottom: 8px;
}
.stat-card-link {
  font-size: 12px; color: rgba(255,255,255,.8);
  display: flex; align-items: center; gap: 4px;
  cursor: pointer; transition: color var(--transition);
}
.stat-card-link:hover { color: #fff; }

/* =====================================================================
   CARDS
   ===================================================================== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--card-border);
  background: var(--card-bg);
}
.card-header h5 {
  font-size: 14px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 7px; margin: 0;
}
.card-body { padding: 18px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--card-border); }

/* =====================================================================
   CHART TABS (7 Days / 30 Days / This Month)
   ===================================================================== */
.chart-tabs {
  display: flex; gap: 4px;
  background: var(--bg); border-radius: 8px; padding: 3px;
}
.chart-tab {
  padding: 4px 12px; font-size: 12px; font-weight: 600;
  border-radius: 6px; border: none; cursor: pointer;
  color: var(--text-muted); background: none;
  transition: all var(--transition);
}
.chart-tab.active { background: var(--primary); color: #fff; }

/* =====================================================================
   TABLES
   ===================================================================== */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.data-table thead th {
  background: var(--bg); color: var(--text-muted);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  padding: 10px 14px;
  border-bottom: 2px solid var(--card-border);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--card-border);
  vertical-align: middle; color: var(--text);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(59,130,246,.04); }

/* =====================================================================
   BADGES
   ===================================================================== */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: .03em;
}
.badge-success  { background: #dcfce7; color: #15803d; }
.badge-danger   { background: #fee2e2; color: #dc2626; }
.badge-warning  { background: #fef3c7; color: #d97706; }
.badge-info     { background: #e0f2fe; color: #0369a1; }
.badge-secondary{ background: #f1f5f9; color: var(--text-muted); }
.badge-primary  { background: #eff6ff; color: var(--primary); }
[data-theme="dark"] .badge-success  { background: #052e16; color: #4ade80; }
[data-theme="dark"] .badge-danger   { background: #450a0a; color: #f87171; }
[data-theme="dark"] .badge-warning  { background: #431407; color: #fbbf24; }
[data-theme="dark"] .badge-secondary{ background: #1e2a3a; color: #64748b; }

/* =====================================================================
   QUICK ACTION BUTTONS
   ===================================================================== */
.quick-actions {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 10px;
}
.qa-btn {
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 4px;
  padding: 14px 8px; border-radius: 10px;
  color: #fff; font-size: 12px; font-weight: 700;
  cursor: pointer; border: none;
  transition: transform var(--transition), box-shadow var(--transition);
  text-decoration: none; text-align: center;
}
.qa-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); color: #fff; text-decoration: none; }
.qa-btn i { font-size: 20px; }
.qa-btn .qa-key { font-size: 10px; font-weight: 500; opacity: .7; }

.qa-blue   { background: linear-gradient(135deg,#3b82f6,#1d4ed8); }
.qa-green  { background: linear-gradient(135deg,#22c55e,#15803d); }
.qa-orange { background: linear-gradient(135deg,#f97316,#c2410c); }
.qa-teal   { background: linear-gradient(135deg,#14b8a6,#0f766e); }
.qa-purple { background: linear-gradient(135deg,#8b5cf6,#6d28d9); }
.qa-gray   { background: linear-gradient(135deg,#64748b,#475569); }

/* =====================================================================
   DONUT CHART LEGEND
   ===================================================================== */
.legend-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted); margin-bottom: 6px;
}
.legend-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}

/* =====================================================================
   BUTTONS (general)
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  font-size: 13px; font-weight: 500;
  transition: all var(--transition); text-decoration: none;
  white-space: nowrap; font-family: inherit;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; text-decoration: none; }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #16a34a; color: #fff; text-decoration: none; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #dc2626; color: #fff; text-decoration: none; }
.btn-secondary { background: var(--card-bg); color: var(--text); border-color: var(--card-border); }
.btn-secondary:hover { background: var(--bg); text-decoration: none; }
.btn-outline-primary { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; text-decoration: none; }
.btn-sm  { padding: 4px 10px; font-size: 12px; }
.btn-lg  { padding: 10px 22px; font-size: 15px; }
.btn-icon{ padding: 6px 8px; }

/* =====================================================================
   FORMS
   ===================================================================== */
.form-group { margin-bottom: 14px; }
.form-label  {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text); margin-bottom: 5px;
}
.req { color: var(--danger); margin-left: 2px; }
.form-control, .form-select {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--card-border); border-radius: var(--radius-xs);
  font-size: 13px; color: var(--text);
  background: var(--card-bg); outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback { font-size: 11px; color: var(--danger); margin-top: 3px; display: block; }
textarea.form-control { resize: vertical; min-height: 76px; }

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background: #1e2a3a; color: var(--text); border-color: var(--card-border);
}
[data-theme="dark"] .form-control::placeholder { color: #526070; }

/* =====================================================================
   FILTER BAR
   ===================================================================== */
.filter-bar {
  display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px;
  padding: 14px 18px;
  background: var(--bg); border-bottom: 1px solid var(--card-border);
}
[data-theme="dark"] .filter-bar { background: #12192a; }
.filter-bar .form-group { margin-bottom: 0; min-width: 130px; }

/* =====================================================================
   PAGINATION
   ===================================================================== */
.pager-wrap {
  display: flex; align-items: center;
  justify-content: space-between; padding: 10px 0;
  gap: 12px; flex-wrap: wrap;
}
.pager-info { font-size: 12px; color: var(--text-muted); }
.pagination { display: flex; gap: 4px; list-style: none; padding: 0; margin: 0; }
.pagination .page-item .page-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border: 1px solid var(--card-border);
  border-radius: var(--radius-xs); font-size: 12px; color: var(--text);
  background: var(--card-bg); cursor: pointer;
  transition: all var(--transition);
}
.pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .page-item.disabled .page-link { opacity: .4; cursor: not-allowed; }

/* =====================================================================
   TOAST NOTIFICATIONS
   ===================================================================== */
#toasts {
  position: fixed; top: 16px; right: 16px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
  max-width: 340px;
}
.toast-item {
  background: var(--card-bg); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); padding: 12px 16px;
  display: flex; align-items: flex-start; gap: 10px;
  border-left: 4px solid;
  font-size: 13px; color: var(--text);
  animation: slideIn .28s ease;
}
.toast-item.success { border-color: var(--success); }
.toast-item.error   { border-color: var(--danger); }
.toast-item.warning { border-color: var(--warning); }
.toast-item.info    { border-color: var(--info); }
@keyframes slideIn { from{ transform:translateX(110%);opacity:0; } to{ transform:translateX(0);opacity:1; } }

/* =====================================================================
   SPINNER
   ===================================================================== */
.spinner-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 9998;
}
[data-theme="dark"] .spinner-overlay { background: rgba(0,0,0,.5); }
.spin {
  width: 36px; height: 36px;
  border: 4px solid var(--card-border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spinning .8s linear infinite;
}
@keyframes spinning { to { transform: rotate(360deg); } }

/* =====================================================================
   MODAL
   ===================================================================== */
.modal-content {
  background: var(--card-bg); border: none;
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.modal-header {
  background: var(--bg); border-bottom: 1px solid var(--card-border);
  border-radius: var(--radius) var(--radius) 0 0; padding: 14px 18px;
}
.modal-title { font-size: 15px; font-weight: 700; color: var(--text); }
.modal-footer { background: var(--bg); border-top: 1px solid var(--card-border); padding: 12px 18px; }
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer { background: #12192a; }
[data-theme="dark"] .modal-content { background: var(--card-bg); }

/* =====================================================================
   ALERTS
   ===================================================================== */
.alert {
  padding: 10px 14px; border-radius: var(--radius-xs);
  margin-bottom: 14px; font-size: 13px;
  display: flex; align-items: flex-start; gap: 8px;
}
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.alert-danger  { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }
[data-theme="dark"] .alert-success { background:#052e16; border-color:#166534; color:#4ade80; }
[data-theme="dark"] .alert-danger  { background:#450a0a; border-color:#991b1b; color:#f87171; }
[data-theme="dark"] .alert-warning { background:#431407; border-color:#92400e; color:#fbbf24; }
[data-theme="dark"] .alert-info    { background:#0c1a35; border-color:#1e40af; color:#93c5fd; }

/* =====================================================================
   EMPTY STATE
   ===================================================================== */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state .ei { font-size: 48px; margin-bottom: 12px; opacity: .4; }
.empty-state h4  { font-size: 15px; font-weight: 600; color: var(--text); }

/* =====================================================================
   FOOTER BAR (bottom status bar like in image)
   ===================================================================== */
.footer-bar {
  background: #1a1f2e; color: #9ba8c0;
  display: flex; align-items: center; gap: 0;
  font-size: 11px; padding: 0;
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.footer-bar-item {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-right: 1px solid rgba(255,255,255,.07);
}
.footer-bar-item i { font-size: 13px; }
.footer-bar-item.online { color: var(--success); margin-left: auto; }
[data-theme="dark"] .footer-bar { background: #090d13; }

/* =====================================================================
   LOGIN PAGE
   ===================================================================== */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg,#1a1f2e 0%,#243347 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--card-bg); border-radius: 16px;
  padding: 36px; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .li {
  width: 56px; height: 56px;
  background: linear-gradient(135deg,#f59e0b,#d97706);
  border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 26px; margin-bottom: 10px;
}
.login-logo h1 { font-size: 18px; font-weight: 700; color: var(--text); }
.login-logo p  { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media(max-width:768px){
  .sidebar { transform: translateX(-100%); }
  .sidebar.mob-open { transform: translateX(0); }
  .main-wrap { margin-left: 0 !important; }
  .page-content { padding: 14px; }
  .stat-cards { grid-template-columns: repeat(2,1fr); }
  .hdr-search { max-width: 160px; }
  .btn-scan, .btn-quick-sale { display: none; }
}
@media(max-width:480px){
  .stat-cards { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: repeat(2,1fr); }
}

/* =====================================================================
   SMOOTH TRANSITIONS (all elements)
   ===================================================================== */
*, *::before, *::after {
  transition: background-color .2s ease, color .15s ease,
              border-color .2s ease, box-shadow .2s ease;
}
.spin, .toast-item, .stat-card, .qa-btn { transition: none; }
.stat-card { transition: transform .22s ease, box-shadow .22s ease; }
.qa-btn    { transition: transform .22s ease, box-shadow .22s ease; }


/* =================================================================

/* ===================================================================
   MOBILE RESPONSIVE — App Style
   Desktop (> 768px) : Zero changes
   Mobile  (≤ 768px) : Left drawer sidebar + bottom nav bar
   =================================================================== */

/* ── Force desktop layout above 768px ─────────────────────────────── */
@media (min-width: 769px) {
    .sidebar           { display: flex   !important; transform: none !important; box-shadow: none !important; }
    #mobileNav         { display: none   !important; }
    .mob-sidebar-backdrop { display: none !important; }
    .footer-bar        { display: flex   !important; }
}

/* ── Bottom Nav Bar ─────────────────────────────────────────────────── */
#mobileNav {
    display:         none;
    position:        fixed;
    bottom:          0; left: 0; right: 0;
    height:          60px;
    background:      #1a1f2e;
    border-top:      1px solid rgba(255,255,255,.08);
    z-index:         1050;
    align-items:     center;
    justify-content: space-around;
    padding:         0;
    box-shadow:      0 -4px 20px rgba(0,0,0,.3);
}
.mbn-btn {
    display:        flex;
    flex-direction: column;
    align-items:    center;
    justify-content:center;
    gap:            2px;
    color:          #7a8aaa;
    font-size:      10px;
    font-weight:    600;
    padding:        8px 12px;
    min-width:      54px;
    cursor:         pointer;
    background:     none;
    border:         none;
    text-decoration:none;
    border-radius:  0;
    transition:     color .15s;
    position:       relative;
}
.mbn-btn i          { font-size: 20px; }
.mbn-btn span       { font-size: 10px; font-weight: 600; }
.mbn-btn.active     { color: #3b82f6; }
.mbn-btn.active::before {
    content:    '';
    position:   absolute;
    top:        0; left: 20%; right: 20%;
    height:     3px;
    background: #3b82f6;
    border-radius: 0 0 3px 3px;
}
.mbn-btn:hover      { color: #fff; text-decoration: none; }

/* ── Sidebar Backdrop ───────────────────────────────────────────────── */
.mob-sidebar-backdrop {
    display:    none;
    position:   fixed;
    inset:      0;
    z-index:    1099;
    background: rgba(0,0,0,.5);
    /* NO backdrop-filter — it blurs everything including the panel */
}

/* ── More Menu (slide up panel) ─────────────────────────────────────── */
.mob-more-panel {
    display:    none;
    position:   fixed;
    bottom:     60px; left: 0; right: 0;
    background: #1a1f2e;
    border-top: 1px solid rgba(255,255,255,.08);
    border-radius: 16px 16px 0 0;
    z-index:    1150;    /* ABOVE backdrop (1099) so clicks work */
    max-height: 72vh;
    overflow-y: auto;
    padding:    8px 0 16px;
    box-shadow: 0 -8px 32px rgba(0,0,0,.4);
    animation:  panelSlideUp .24s cubic-bezier(.4,0,.2,1);
}
@keyframes panelSlideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
.mmp-handle {
    width: 36px; height: 4px;
    background: rgba(255,255,255,.2);
    border-radius: 2px;
    margin: 6px auto 10px;
}
.mmp-section {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .08em;
    color: #3d4f6e;
    padding: 8px 20px 3px;
}
.mmp-item {
    display:    flex;
    align-items:center;
    gap:        14px;
    padding:    11px 20px;
    color:      #9ba8c0;
    font-size:  13.5px;
    font-weight:500;
    cursor:     pointer;
    text-decoration: none;
    transition: background .1s, color .1s;
    border:     none;
    background: none;
    width:      100%;
    text-align: left;
}
.mmp-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.mmp-item i     { font-size: 18px; width: 24px; text-align: center; }
.mmp-item .mmp-badge {
    margin-left: auto;
    background:  rgba(59,130,246,.2);
    color:       #3b82f6;
    font-size:   10px; font-weight: 700;
    padding:     1px 7px; border-radius: 10px;
}
.mmp-divider { height: 1px; background: rgba(255,255,255,.06); margin: 4px 20px; }

/* ═══════════════════════════════════════════════════════════════════
   MOBILE ONLY (≤ 768px)
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* ── Show bottom nav ──────────────────────────────────────────── */
    #mobileNav  { display: flex !important; }
    .footer-bar { display: none !important; }

    /* ── Sidebar: LEFT DRAWER ──────────────────────────────────────── */
    .sidebar {
        display:    flex      !important;
        position:   fixed     !important;
        top:        0 !important;
        left:       0 !important;
        height:     100vh     !important;
        width:      280px     !important;
        transform:  translateX(-100%);
        transition: transform .28s cubic-bezier(.4,0,.2,1);
        z-index:    1100      !important;
        box-shadow: none;
        overflow-y: auto;
    }
    /* Sidebar open */
    .sidebar.mob-open {
        transform:  translateX(0) !important;
        box-shadow: 8px 0 40px rgba(0,0,0,.5) !important;
    }
    /* Ensure sidebar not collapsed on mobile */
    .sidebar.collapsed { width: 280px !important; }
    .sidebar.collapsed .sb-brand        { padding: 14px 16px !important; justify-content: flex-start !important; }
    .sidebar.collapsed .sb-brand-text   { display: block !important; }
    .sidebar.collapsed .sb-user         { padding: 12px 16px !important; justify-content: flex-start !important; }
    .sidebar.collapsed .sb-user-name,
    .sidebar.collapsed .sb-user-role    { display: block !important; }
    .sidebar.collapsed .sb-nav-link     { padding: 10px 16px !important; justify-content: flex-start !important; }
    .sidebar.collapsed .sb-nav-link .sb-nav-text  { opacity: 1 !important; width: auto !important; }
    .sidebar.collapsed .sb-nav-link .sb-nav-arrow { opacity: 1 !important; width: auto !important; }
    .sidebar.collapsed .sb-nav-link .sb-nav-icon  { width: 22px !important; text-align: center !important; }
    .sidebar.collapsed .sb-section-label { opacity: 1 !important; height: auto !important; padding: 12px 16px 4px !important; }
    .sidebar.collapsed .sb-help   { display: block !important; }
    .sidebar.collapsed .sb-footer { display: block !important; }
    .sidebar.collapsed .sb-nav-link::after { display: none !important; }

    /* ── Main content ──────────────────────────────────────────────── */
    .main-wrap,
    .main-wrap.expanded {
        margin-left:    0 !important;
        padding-bottom: 70px !important;
    }

    /* ── Top header compact ────────────────────────────────────────── */
    .top-header {
        height:  52px !important;
        padding: 0 12px !important;
        gap:     8px !important;
    }
    .hdr-search      { display: none !important; }
    .btn-scan        { display: none !important; }
    .btn-quick-sale  { display: none !important; }
    .fy-select       { display: none !important; }
    .hdr-user-name   { display: none !important; }
    .theme-toggle span:last-child { display: none !important; }

    /* ── Page content ──────────────────────────────────────────────── */
    .page-content { padding: 12px 12px 72px !important; }

    /* ── Stat cards 2 col ──────────────────────────────────────────── */
    .stat-cards-row {
        grid-template-columns: repeat(2,1fr) !important;
        gap: 8px !important;
    }
    .sc           { padding: 12px 14px !important; }
    .sc-value     { font-size: 20px !important; }

    /* ── Dashboard rows stack ──────────────────────────────────────── */
    .mid-row, .bot-row { grid-template-columns: 1fr !important; }

    /* ── Tables ────────────────────────────────────────────────────── */
    .data-table          { font-size: 12px !important; }
    .data-table thead th { padding: 8px 8px !important; font-size: 10px !important; }
    .data-table tbody td { padding: 8px 8px !important; }

    /* ── Filter bar stack ──────────────────────────────────────────── */
    .filter-bar {
        flex-direction: column !important;
        align-items:    stretch !important;
        gap:            8px !important;
        padding:        12px !important;
    }
    .filter-bar input,
    .filter-bar select,
    .filter-bar button { width: 100% !important; min-width: unset !important; }

    /* ── Forms full width ──────────────────────────────────────────── */
    .row > [class*="col-md-"] {
        flex:      0 0 100% !important;
        max-width: 100%     !important;
    }

    /* ── Page header ───────────────────────────────────────────────── */
    .page-hdr              { flex-wrap: wrap; gap: 8px; }
    .page-hdr .d-flex      { gap: 6px; width: 100%; }
    .page-hdr .d-flex .btn { flex: 1; }

    /* ── Modals ────────────────────────────────────────────────────── */
    .modal-dialog,
    .modal-dialog.modal-xl,
    .modal-dialog.modal-lg {
        margin:    6px !important;
        max-width: calc(100vw - 12px) !important;
    }
    .modal-body { padding: 14px !important; max-height: 68vh; overflow-y: auto; }

    /* ── Quick actions ─────────────────────────────────────────────── */
    .qa-grid { grid-template-columns: repeat(3,1fr) !important; gap: 8px !important; }
    .qab     { padding: 10px 4px !important; font-size: 10.5px !important; }
    .qab i   { font-size: 16px !important; }

    /* ── Search dropdowns ──────────────────────────────────────────── */
    #purchDropdown, #prodDropdown, #invDropdown {
        left:      8px !important;
        right:     8px !important;
        width:     calc(100vw - 16px) !important;
        min-width: unset !important;
    }

    /* ── Login ─────────────────────────────────────────────────────── */
    .login-card    { padding: 28px 20px !important; }
    .login-logo h1 { font-size: 17px !important; }
}

/* ── Very small screens (< 400px) ─────────────────────────────────── */
@media (max-width: 400px) {
    .stat-cards-row { grid-template-columns: 1fr 1fr !important; }
    .sc-value       { font-size: 18px !important; }
    .mbn-btn        { min-width: 44px !important; padding: 8px 6px !important; }
}
