/* ============================================================
   assets/css/app.css — Mobile-first POS stylesheet
   Design: Industrial/Utilitarian — clean, high-contrast, fast
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg:         #0f1117;
  --surface:    #1a1d27;
  --surface2:   #252836;
  --border:     #2e3245;
  --accent:     #4f8ef7;
  --accent-dk:  #3a6fd8;
  --success:    #22c55e;
  --danger:     #ef4444;
  --warning:    #f59e0b;
  --text:       #e8eaf0;
  --text-muted: #8b90a7;
  --radius:     10px;
  --shadow:     0 2px 12px rgba(0,0,0,.35);
  --header-h:   56px;
  --footer-h:   56px;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Typography ─────────────────────────────────────────────── */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }
p  { line-height: 1.6; }

/* ── Header ─────────────────────────────────────────────────── */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
}
.app-header .logo {
  font-size: 1.1rem; font-weight: 800; color: var(--accent);
  letter-spacing: -.5px; white-space: nowrap;
}
.app-header .nav-toggle {
  background: none; border: none; color: var(--text); cursor: pointer;
  font-size: 1.4rem; padding: 4px;
}
.header-actions { display: flex; align-items: center; gap: 10px; }
.user-badge {
  font-size: .8rem; color: var(--text-muted);
  white-space: nowrap;
}
.role-pill {
  display: inline-block; font-size: .7rem; font-weight: 700;
  padding: 2px 8px; border-radius: 99px; text-transform: uppercase;
  background: var(--accent); color: #fff; margin-left: 4px;
}
.role-pill.sr { background: var(--warning); color: #000; }

/* ── Side Nav ───────────────────────────────────────────────── */
/* ── Side Nav Base (Always Hidden) ── */
/* Ensure the toggle button is ALWAYS visible */
#navToggle {
  display: flex; /* or block, depending on your layout */
  cursor: pointer;
  z-index: 100;
}

/* Force the Side Nav to stay hidden regardless of screen size */
.side-nav {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: 240px;
  background: var(--surface);
  z-index: 90;
  display: none;
  overflow-y: auto;

  scrollbar-width: none;
  -ms-overflow-style: none;


/* Start hidden: Move the bar 100% of its width to the left */
  transform: translateX(-100%);
  
  /* The Animation: 0.3 seconds, "ease" for a natural feel */
  transition: transform 0.3s ease-in-out;
}
.side-nav::-webkit-scrollbar {
  width: 0;
  height: 0;
}
  
/* Only shows when JS adds the 'open' class */
.side-nav.open {
  transform: translateX(0);
  display: block; /* Ensure it becomes visible when open */
  box-shadow: var(--shadow);
  animation: var(--animation) .25s ease-in-out;
}

/* Hide the overlay by default on all screens */
.nav-overlay {
position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9;
  
  /* Use opacity and visibility for the fade effect */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s;
}

.nav-overlay.open {
 opacity: 1;
  visibility: visible;
}

/* ── Nav Items ──────────────────────────────────────────────── */
.nav-section { margin-bottom: 8px; }
.nav-section-label {
  font-size: .65rem; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); padding: 8px 12px 4px; letter-spacing: .08em;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius);
  color: var(--text); font-size: .9rem; font-weight: 500;
  
}
.nav-link:hover, .nav-link.active {
  background: var(--surface2); color: var(--accent); text-decoration: none;
}
.nav-link .icon { font-size: 1rem; width: 20px; text-align: center; }

/* ── Main content ───────────────────────────────────────────── */
.app-main {
  margin-top: var(--header-h);
  padding: 16px;
  flex: 1;
}
@media (min-width: 768px) {
  .side-nav { transform: translateX(0); }
  /* .nav-toggle, .nav-overlay { display: none !important; } */
  .app-main { margin-left: 0px; }
}

/* ── Footer ─────────────────────────────────────────────────── */
.app-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: .78rem;
  color: var(--text-muted);
  padding: 12px 16px;
}
/* @media (min-width: 768px) {
  .app-footer { margin-left: 240px; }
} */

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 1rem; font-weight: 700;
  margin-bottom: 16px; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}

/* ── Stat Cards ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (min-width: 640px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-card .stat-label { font-size: .75rem; color: var(--text-muted); margin-bottom: 4px; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 800; }
.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.danger  .stat-value { color: var(--danger); }
.stat-card.warning .stat-value { color: var(--warning); }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; font-size: .82rem; font-weight: 600;
  color: var(--text-muted); margin-bottom: 6px;
}
.form-control {
  width: 100%; padding: 10px 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: .95rem;
  transition: border-color .15s;
}
.form-control:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,142,247,.2);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
  display: grid; gap: 12px;
  grid-template-columns: 1fr;
}
@media (min-width: 480px) {
  .form-row.cols-2 { grid-template-columns: 1fr 1fr; }
  .form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 10px 18px;
  border: none; border-radius: var(--radius);
  font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dk); }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-ghost   { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface2); }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-icon { padding: 8px; aspect-ratio: 1; }
.btn-block { width: 100%; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  background: var(--surface2); text-align: left;
  padding: 10px 12px; font-weight: 700; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tbody tr:hover { background: var(--surface2); }
tbody tr:last-child td { border-bottom: none; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-block; font-size: .72rem; font-weight: 700;
  padding: 2px 8px; border-radius: 99px; text-transform: uppercase;
}
.badge-success { background: rgba(34,197,94,.15); color: var(--success); }
.badge-danger  { background: rgba(239,68,68,.15);  color: var(--danger); }
.badge-warning { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-info    { background: rgba(79,142,247,.15); color: var(--accent); }
.badge-grey    { background: var(--surface2); color: var(--text-muted); }

/* ── Flash messages ─────────────────────────────────────────── */
.flash {
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 16px; font-size: .9rem; font-weight: 500;
}
.flash-success { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.3); color: var(--success); }
.flash-error   { background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.3);  color: var(--danger); }
.flash-info    { background: rgba(79,142,247,.1); border: 1px solid rgba(79,142,247,.3); color: var(--accent); }

/* ── Order summary rows (invoice viewer's on-screen preview; POS
   defines its own local .summary-row for the checkout panel) ──── */
.summary-row {
  display: flex; justify-content: space-between;
  font-size: .88rem; margin-bottom: 6px;
}
.summary-row.total {
  font-size: 1.2rem; font-weight: 800;
  color: var(--success); margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ── Modal ──────────────────────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.7); z-index: 200;
  align-items: center; justify-content: center;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slideUp .2s ease;
}
.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1.05rem; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1.3rem; padding: 2px 6px; border-radius: 6px;
}
.modal-close:hover { background: var(--surface2); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ── Print: flip the dark theme's CSS variables to light ─────
   Every card/table/stat-box below reads its colors from these same
   custom properties (--bg, --surface, --text, etc.), so overriding them
   here — instead of fighting each component individually — makes every
   ordinary page (Reports, Sales, Finance, Requisition, Z-report, Backup...)
   print on a white background automatically. Invoice/thermal/label prints
   are unaffected — they use their own hardcoded light print CSS, not these
   variables, by design. */
@media print {
  :root {
    --bg:         #ffffff;
    --surface:    #ffffff;
    --surface2:   #f3f4f6;
    --border:     #cccccc;
    --text:       #000000;
    --text-muted: #555555;
    --shadow:     none;
  }
  .no-print { display: none !important; }
  .app-header, .app-footer, .side-nav, .nav-overlay { display: none !important; }
  .app-main { margin: 0 !important; padding: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
  * { box-shadow: none !important; text-shadow: none !important; }
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Utility ─────────────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top:  8px; }  .mt-2 { margin-top: 16px; }  .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.d-flex { display: flex; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }
.hidden { display: none; }

/* ── Search bar ──────────────────────────────────────────────── */
.search-bar {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.search-bar .form-control { flex: 1; }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 16px; justify-content: center;
}
.page-btn {
  padding: 6px 12px; border-radius: 7px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; font-size: .85rem;
  text-decoration: none;
}
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:hover:not(.active) { background: var(--surface2); }

/* ── Payment method multi-select ─────────────────────────────── */
.pay-opt-wrap {
  transition: border-color .15s, background .15s;
}
.pay-opt-wrap.pay-selected,
.pay-opt-wrap:has(.pay-check:checked) {
  border-color: var(--accent) !important;
  background: rgba(79,142,247,.1);
}
