/* =====================================================================
   POS Lite — design-v3.css
   Faithful port of new_design.html visual language on top of app.css.
   Loads AFTER app.css so it wins the cascade.
   Values copied 1:1 from the mockup (palette, borders, radii, type).
   RTL + Urdu Nastaliq mirrored via inline-start/end.
   ===================================================================== */

/* ---------- theme variables (1:1 from new_design.html) ---------- */
:root, [data-theme="light"] {
  --bg: #f8f9fa;            /* bg-base */
  --surface: #ffffff;       /* bg-surface */
  --surface-2: #f3f4f6;     /* surface-hover */
  --surface-active: #e5e7eb;/* surface-active */
  --border: #e5e7eb;        /* border-row */
  --text: #111827;          /* text-main */
  --text-2: #6b7280;        /* text-sub */
  --muted: #9ca3af;
  --primary: #111827;       /* text-main used as primary */
  --primary-2: #111827;
  --primary-soft: #e5e7eb;
  --on-primary: #ffffff;    /* bg-surface on primary */
  --on-danger: #ffffff;
  --success: #16a34a;  --success-soft: #e8f6ee;
  --danger: #dc2626;   --danger-soft: #fdecec;
  --warn: #b45309;     --warn-soft: #fdf1e0;
  --info: #0369a1;     --info-soft: #e7f2fa;
  --chip-bg: #e5e7eb;  --chip-hover: #d1d5db;  --chip-text: #111827;
  --input-bg: #f3f4f6;
  --shadow: 0 1px 3px rgba(0,0,0,.02);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.08);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 250px;
  --topbar-h: 56px;
}

[data-theme="dark"] {
  --bg: #0f0f0f;            /* bg-base */
  --surface: #181818;       /* bg-surface */
  --surface-2: #272727;     /* surface-hover */
  --surface-active: #3f3f3f;/* surface-active */
  --border: #2f2f2f;        /* border-row */
  --text: #f9fafb;          /* text-main */
  --text-2: #9ca3af;        /* text-sub */
  --muted: #8f949d;
  --primary: #f9fafb;       /* text-main used as primary */
  --primary-2: #f9fafb;
  --primary-soft: #2f2f2f;
  --on-primary: #181818;    /* bg-surface on primary */
  --on-danger: #1a1a1a;
  --success: #34d399;  --success-soft: #143227;
  --danger: #f87171;   --danger-soft: #3c1f26;
  --warn: #fbbf24;     --warn-soft: #3a2f17;
  --info: #38bdf8;     --info-soft: #132f45;
  --chip-bg: #272727;  --chip-hover: #3f3f3f;  --chip-text: #f9fafb;
  --input-bg: #212121;
  --shadow: 0 1px 3px rgba(0,0,0,.40);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.55);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 250px;
  --topbar-h: 56px;
}

/* ---------- typography (13px base, Segoe UI, keep Urdu Nastaliq) ---------- */
body {
  font-family: "Segoe UI Variable", "Segoe UI", "Noto Nastaliq Urdu", system-ui, sans-serif;
  font-size: 13px;
  letter-spacing: 0;
  background-color: var(--bg);
}
[dir="rtl"] body, [dir="rtl"] .urdu, [lang="ur"] .urdu {
  font-family: "Noto Nastaliq Urdu", "Segoe UI", "Inter", serif;
}
.input, .select, .textarea { font-size: 13px; }

/* ---------- flat app backdrop (no gradient, per design) ---------- */
/* ---------- flat app backdrop (no gradient, per design) ---------- */
.dash-body, [data-theme="dark"] .dash-body { background: var(--bg); background-attachment: fixed; }
.dash { background: transparent; }

/* ---------- sidebar (250px, surface, no border) ---------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border: 0 !important;
  box-shadow: none;
}
.sidebar-brand {
  height: var(--topbar-h);
  padding: 0 20px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.5px;
  border: 0;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-brand .brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--primary);
  color: var(--on-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand .brand-mark svg { width: 15px; height: 15px; }
.sidebar-brand b {
  background: var(--primary);
  color: var(--on-primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  letter-spacing: 0;
  font-weight: 700;
}
.side-nav { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; }
.active-dept-badge {
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: 9999px;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-2);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.active-dept-badge #bizName { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 10px 14px;
  color: var(--text-2);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}
.side-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.active { background: var(--surface-active); color: var(--text); font-weight: 700; border-radius: 9999px; }

/* collapsed sidebar (desktop collapse via appbar burger) */
.sidebar.collapsed { display: none; }
body.sidebar-collapsed .dash-main { margin-left: 0; }
[dir="rtl"] body.sidebar-collapsed .dash-main { margin-right: 0; }
@media (max-width: 900px) {
  .sidebar.collapsed { display: flex; }
}

.sidebar-foot { padding: 16px 12px; background: var(--surface); border: 0; }
.btn-switch-dept {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: var(--on-primary);
  border: 0;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-switch-dept:hover { opacity: .85; }
.btn-switch-dept svg { width: 16px; height: 16px; }

/* ---------- topbar / appbar (56px, no border) ---------- */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 0 24px;
  gap: 16px;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 70;
}
.appbar-left { display: flex; align-items: center; gap: 16px; min-width: 0; }
.topbar-title h1 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.3px; line-height: 1.2; }
.burger { display: inline-flex; }

.topbar-actions { display: flex; align-items: center; gap: 12px; margin-inline-start: 0; }
.topbar-actions .icon-btn {
  width: auto;
  min-width: 36px;
  height: 34px;
  padding: 0 12px;
  font-size: 12.5px;
  font-weight: 700;
  border-radius: 9999px;
}
.theme-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--chip-bg);
  color: var(--chip-text);
  border: 0;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.theme-pill:hover { background: var(--chip-hover); }
.theme-pill svg { width: 15px; height: 15px; }

.user-menu { position: relative; }
.user-avatar {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  border: 0;
  cursor: pointer;
}
.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  min-width: 180px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  z-index: 80;
}
.user-menu.open .user-dropdown { display: flex; flex-direction: column; }
.user-dropdown button, .user-dropdown a {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 6px;
  padding: 9px 11px;
  background: transparent;
  color: var(--text-2);
  text-align: start;
  font: inherit;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}
.user-dropdown button:hover, .user-dropdown a:hover { background: var(--surface-2); color: var(--text); }

/* ---------- content area (fluid, 20px gaps) ---------- */
.content {
  max-width: none;
  padding: 0 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.tab-sec { display: flex; flex-direction: column; gap: 20px; }
.section-title { font-size: 15px; font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; }

/* sticky quick actions chip bar */
.page-quick-actions {
  position: sticky;
  top: var(--topbar-h);
  z-index: 15;
  background: var(--bg);
  min-height: 52px;
  padding: 12px 8px 4px;
  display: flex;
  gap: 10px;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  margin-inline: -8px;
}

/* scrollbar rail (track) and thumb */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: var(--surface-active); }

/* Firefox */
* { scrollbar-color: var(--surface-2) var(--surface); scrollbar-width: thin; }
.page-quick-actions .chip {
  background: var(--chip-bg);
  color: var(--chip-text);
  padding: 8px 18px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
}
.page-quick-actions .chip:hover { background: var(--chip-hover); }
.page-quick-actions .chip svg { width: 14px; height: 14px; flex-shrink: 0; }

/* report type tabs become the same sticky pill bar as .page-quick-actions */
.report-tabs {
  position: sticky;
  top: var(--topbar-h);
  z-index: 15;
  background: var(--bg);
  min-height: 52px;
  padding: 12px 8px 4px;
  display: flex;
  gap: 10px;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  flex-wrap: nowrap;
  margin-inline: -8px;
  margin-bottom: 0;
}
.report-tabs .chip-btn { white-space: nowrap; flex-shrink: 0; }

/* ---------- panels (surface, radius 12, NO border/shadow) ---------- */
.panel {
  background: var(--surface);
  border-radius: 12px;
  padding: 16px;
  border: 0;
  box-shadow: none;
  margin-bottom: 0;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 0 0 12px;
  border-bottom: 0;
}
.panel-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.panel-body { padding: 0; }

/* ---------- KPI strip (single surface, divider-separated cards) ---------- */
.stat-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  row-gap: 12px;
  background: var(--surface);
  border-radius: 12px;
  padding: 16px 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.02);
}
.stat-card {
  flex: 1 1 200px;
  min-width: 0;
  padding: 4px 20px;
  background: transparent;
  border: 0;
  border-inline-end: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
}
.stat-card:last-child { border-inline-end: 0; }
.stat-card .k { font-size: 11px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.stat-card .v { font-size: 26px; font-weight: 800; margin-bottom: 2px; }
.stat-card .s { font-size: 11px; color: var(--text-2); }
.stat-card .ic { margin-bottom: 8px; border-radius: 10px; }

/* ---------- tables (uppercase 10px heads, 2px head rule) ---------- */
.table th {
  padding: 8px 10px;
  color: var(--text-2);
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 2px solid var(--border);
}
.table td { padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 12px; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }

/* ---------- buttons / chips / pills ---------- */
.btn { border-radius: 9999px; font-size: 12.5px; }
.btn-sm { font-size: 12px; }
.btn-xs { font-size: 11.5px; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: none; }
.btn-primary:hover { background: var(--primary); opacity: .9; box-shadow: none; }
.btn-danger { background: var(--danger); color: var(--on-danger); }
.btn-ghost { background: var(--surface); }
.icon-btn { border-radius: 9999px; }
.chip-btn {
  border: 0;
  background: var(--chip-bg);
  color: var(--chip-text);
  padding: 8px 18px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
}
.chip-btn:hover { background: var(--chip-hover); color: var(--chip-text); }
.chip-btn.active { background: var(--primary); color: var(--on-primary); }

/* filters / table-controls become pill inputs */
.filters .input, .filters .select,
.table-controls input, .table-controls select {
  border-radius: 9999px;
  background: var(--input-bg);
  border: 0;
}

/* ---------- inputs / form labels ---------- */
.input, .select, .textarea {
  background: var(--input-bg);
  border: 0;
  border-radius: 8px;
}
.input:focus, .select:focus, .textarea:focus { box-shadow: 0 0 0 2px var(--primary-soft); outline: none; }
.field label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
  display: block;
}

/* ---------- auth screens (same visual language) ---------- */
.auth-wrap { background: var(--bg); }
.auth-card {
  border: 0;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}
.auth-corner .icon-btn {
  width: auto;
  min-width: 36px;
  height: 34px;
  padding: 0 12px;
  font-size: 12.5px;
  font-weight: 700;
  border-radius: 9999px;
}

/* ---------- pagination ---------- */
.pager { padding: 12px 0 0; border-top: 0; font-size: 11px; color: var(--text-2); }
.pager .btn {
  background: var(--chip-bg);
  color: var(--text);
  border: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 9999px;
}
.pager .btn:hover { background: var(--chip-hover); }

/* ---------- modal ---------- */
.modal { border-radius: 12px; }
.modal-backdrop { background: rgba(0,0,0,.4); backdrop-filter: blur(2px); }

/* ---------- bill modal ---------- */
.modal.bill-modal {
  width: min(1240px, 100%); max-width: none;
  height: min(900px, calc(100vh - 32px)); max-height: none;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.bill-modal .modal-head { padding: 18px 26px; background: color-mix(in srgb, var(--surface) 92%, var(--surface-2)); }
.bill-modal .modal-head h3 { font-size: 20px; }
.bill-modal .modal-body { padding: 20px 26px; }
.bill-modal .modal-foot { padding: 14px 26px; }
.bill-modal .bill-layout { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 22px; }
.bill-modal .bill-items { background: transparent; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; align-content: start; }
.bill-modal .bill-items .empty-box { grid-column: 1 / -1; }
.bill-modal .bill-cart { min-height: 220px; padding: 8px 14px; background: var(--surface-2); border-radius: 8px; }
.bill-modal .cart-total { font-size: 18px; padding: 16px 2px 0; }

/* ---------- misc ---------- */
.avatar { color: var(--on-primary); }
.bc-add, .bc-qty { color: var(--on-primary); }
.section-enter { animation: sectionEnter .2s ease both; }
@keyframes sectionEnter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- responsive (mirrors mockup breakpoints) ---------- */
@media (max-width: 1024px) {
  .stat-grid { flex-wrap: wrap; }
  .stat-card { flex: 1 1 45%; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
}
@media (max-width: 900px) {
  .content { padding: 0 14px 24px; }
  .topbar { padding: 0 14px; }
  .sidebar { width: min(286px, 86vw); }
  .sidebar.open { background: var(--surface); }
}
@media (max-width: 520px) {
  .content { padding: 0 10px 20px; }
  .topbar-actions .theme-pill span { display: none; }
  .panel-head h3 { flex: 1 1 100%; }
  .filters { width: 100%; margin-inline-start: 0; }
  .filters .input, .filters .select { flex: 1 1 120px; min-width: 0; }
  .filters .btn { flex: 1 1 auto; }
  .stat-card { flex: 1 1 100%; }
  .stat-card .v { font-size: 20px; }
  .modal.bill-modal { width: 100%; height: 100%; border-radius: 0; }
  .bill-modal .modal-head, .bill-modal .modal-body, .bill-modal .modal-foot { padding-inline: 16px; }
  .bill-modal .bill-layout { grid-template-columns: 1fr; gap: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
