/* ================================================================
   Hardware Shop Management System — Main Stylesheet
   ================================================================ */

/* ── CSS Variables ─────────────────────────────────────────────── */
:root {
  --primary:        #f97316;
  --primary-dark:   #ea580c;
  --primary-light:  #fed7aa;
  --secondary:      #1e293b;
  --accent:         #10b981;
  --danger:         #ef4444;
  --warning:        #f59e0b;
  --info:           #3b82f6;
  --purple:         #8b5cf6;

  --bg:             #f1f5f9;
  --white:          #ffffff;
  --text:           #1e293b;
  --text-muted:     #64748b;
  --border:         #e2e8f0;
  --border-light:   #f1f5f9;

  --sidebar-w:      260px;
  --sidebar-bg:     #1e293b;
  --sidebar-hover:  #334155;
  --sidebar-active: rgba(249,115,22,0.15);
  --header-h:       64px;

  --radius:         8px;
  --radius-lg:      12px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08);
  --shadow:         0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:      0 10px 40px rgba(0,0,0,.16);

  --transition:     .2s ease;
  --font:           -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }
ul, ol { list-style: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── App Layout ────────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: width var(--transition), transform var(--transition);
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

.sidebar.collapsed { width: 68px; }
.sidebar.collapsed .sidebar-logo span,
.sidebar.collapsed .nav-section,
.sidebar.collapsed .user-info,
.sidebar.collapsed .sidebar-nav a span { display: none; }
.sidebar.collapsed .sidebar-nav a { justify-content: center; }
.sidebar.collapsed .sidebar-nav a i { margin-right: 0; }
.sidebar.collapsed .sidebar-footer { padding: 12px 0; justify-content: center; }
.sidebar.collapsed .sidebar-user { justify-content: center; }
.sidebar.collapsed .logout-btn { display: none; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  min-height: var(--header-h);
  flex-shrink: 0;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-logo i { color: var(--primary); font-size: 1.3rem; flex-shrink: 0; }
.sidebar-toggle-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1rem;
  padding: 6px;
  border-radius: 4px;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover { color: #fff; background: rgba(255,255,255,.08); }

/* Nav */
.sidebar-nav { flex: 1; padding: 8px 0; }
.sidebar-nav ul { padding: 0 10px; }
.sidebar-nav li + li { margin-top: 1px; }
.nav-section {
  padding: 14px 10px 4px;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: #94a3b8;
  font-size: .88rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition: color var(--transition), background var(--transition);
}
.sidebar-nav a i {
  width: 18px;
  text-align: center;
  font-size: .95rem;
  flex-shrink: 0;
  transition: color var(--transition);
}
.sidebar-nav a:hover { color: #fff; background: var(--sidebar-hover); }
.sidebar-nav a.active { color: var(--primary); background: var(--sidebar-active); font-weight: 600; }
.sidebar-nav a.active i { color: var(--primary); }

/* Sidebar footer */
.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
  gap: 8px;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.user-avatar {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; color: #fff;
  flex-shrink: 0;
}
.user-info { overflow: hidden; }
.user-name { color: #fff; font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: #64748b; font-size: .72rem; text-transform: capitalize; }
.logout-btn {
  color: #64748b;
  font-size: 1.1rem;
  padding: 6px;
  border-radius: 4px;
  transition: color var(--transition);
  flex-shrink: 0;
}
.logout-btn:hover { color: var(--danger); }

/* ── Main Content ──────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}
.sidebar.collapsed ~ .main-content { margin-left: 68px; }

/* ── Top Bar ───────────────────────────────────────────────────── */
.top-bar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.top-bar-left { display: flex; align-items: center; gap: 14px; }
.page-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.top-bar-right { display: flex; align-items: center; gap: 10px; }
.mobile-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  padding: 6px;
}
.notif-btn {
  position: relative;
  color: var(--text-muted);
  font-size: 1.15rem;
  padding: 8px;
  border-radius: 8px;
  transition: color var(--transition), background var(--transition);
}
.notif-btn:hover { color: var(--warning); background: #fef3c7; }
.notif-btn .badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 16px; height: 16px;
  background: var(--danger);
  color: #fff;
  border-radius: 8px;
  font-size: .62rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}

/* ── Page Content ──────────────────────────────────────────────── */
.page-content { padding: 24px; flex: 1; }

/* ── Alerts / Flash ────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: .88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-success { background: #dcfce7; color: #166534; border-left: 4px solid var(--accent); }
.alert-error   { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--danger); }
.alert-warning { background: #fef9c3; color: #854d0e; border-left: 4px solid var(--warning); }
.alert-info    { background: #dbeafe; color: #1e40af; border-left: 4px solid var(--info); }

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header h2, .card-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-header h2 i, .card-header h3 i { color: var(--primary); }
.card-body { padding: 20px; }

/* ── Stat Cards ────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card-danger { border-left: 3px solid var(--danger); }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-icon.orange { background: #fff7ed; color: var(--primary); }
.stat-icon.green  { background: #f0fdf4; color: var(--accent); }
.stat-icon.blue   { background: #eff6ff; color: var(--info); }
.stat-icon.red    { background: #fef2f2; color: var(--danger); }
.stat-icon.purple { background: #f5f3ff; color: var(--purple); }
.stat-icon.amber  { background: #fffbeb; color: var(--warning); }
.stat-label { font-size: .8rem; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 1.55rem; font-weight: 800; color: var(--text); line-height: 1.1; }
.stat-sub   { font-size: .76rem; color: var(--text-muted); margin-top: 4px; }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: .88rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: #334155; color: #fff; }
.btn-success   { background: var(--accent); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; color: #fff; }
.btn-info      { background: var(--info); color: #fff; }
.btn-info:hover { background: #2563eb; color: #fff; }
.btn-outline   { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm  { padding: 6px 12px; font-size: .8rem; }
.btn-lg  { padding: 12px 24px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; pointer-events: none; }

/* ── Forms ─────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  color: var(--text);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(249,115,22,.12);
}
.form-control::placeholder { color: #94a3b8; }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M7 7l3-3 3 3m0 6l-3 3-3-3' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 36px; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-text { font-size: .76rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: .76rem; color: var(--danger); margin-top: 4px; }
.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .btn { border-radius: 0 var(--radius) var(--radius) 0; }
.input-group-text {
  display: flex; align-items: center; justify-content: center;
  padding: 0 12px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-left: none; border-radius: 0 var(--radius) var(--radius) 0;
  font-size: .82rem; color: var(--text-muted);
}

/* ── Tables ────────────────────────────────────────────────────── */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  background: #f8fafc;
  padding: 11px 14px;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  color: var(--text);
}
tbody tr:hover { background: #fafafa; }
tbody tr:last-child td { border-bottom: none; }
.table-actions { display: flex; gap: 6px; align-items: center; }

/* ── Badges ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-success  { background: #dcfce7; color: #166534; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-warning  { background: #fef9c3; color: #854d0e; }
.badge-info     { background: #dbeafe; color: #1e40af; }
.badge-secondary{ background: #f1f5f9; color: #64748b; }
.badge-purple   { background: #f5f3ff; color: #5b21b6; }
.badge-orange   { background: #fff7ed; color: #9a3412; }

/* ── Page Header ───────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-header h2 { font-size: 1.2rem; font-weight: 700; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Search / Filter Bar ───────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-bar .form-control { max-width: 260px; }
.search-input-wrapper { position: relative; flex: 1; max-width: 320px; }
.search-input-wrapper i {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: .9rem; pointer-events: none;
}
.search-input-wrapper .form-control { padding-left: 34px; }

/* ── Modals ────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-sm { max-width: 420px; }
.modal-md { max-width: 600px; }
.modal-lg { max-width: 800px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none; border: none;
  font-size: 1.2rem; color: var(--text-muted);
  width: 30px; height: 30px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--bg); color: var(--danger); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ── Dashboard specific ────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.dashboard-grid .card.full { grid-column: 1 / -1; }

/* ── POS Layout ────────────────────────────────────────────────── */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
  height: calc(100vh - var(--header-h) - 48px);
}
.pos-products { display: flex; flex-direction: column; overflow: hidden; }
.pos-cart     { display: flex; flex-direction: column; overflow: hidden; }

.pos-search {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.pos-search .search-wrapper {
  flex: 1;
  position: relative;
}
.pos-search .search-wrapper i {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
.pos-search input {
  width: 100%;
  padding: 10px 10px 10px 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .92rem;
  background: var(--white);
  transition: border-color var(--transition);
}
.pos-search input:focus { outline: none; border-color: var(--primary); }

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  overflow-y: auto;
  flex: 1;
  padding-bottom: 8px;
}
.product-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}
.product-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(249,115,22,.18);
  transform: translateY(-2px);
}
.product-card:active { transform: translateY(0); }
.product-card .pc-name { font-size: .83rem; font-weight: 600; color: var(--text); margin-bottom: 4px; line-height: 1.3; }
.product-card .pc-price { font-size: .92rem; font-weight: 800; color: var(--primary); }
.product-card .pc-stock { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }
.product-card.low-stock { border-color: #fde68a; }
.product-card.out-of-stock { opacity: .5; pointer-events: none; }

/* Cart */
.cart-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  height: 100%;
}
.cart-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cart-header h3 { font-size: .95rem; font-weight: 700; }
.cart-items { flex: 1; overflow-y: auto; padding: 8px; }
.cart-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--border-light);
}
.cart-item:last-child { border-bottom: none; }
.cart-item-info { flex: 1; overflow: hidden; }
.cart-item-name { font-size: .83rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item-price { font-size: .78rem; color: var(--text-muted); }
.cart-item-qty {
  display: flex; align-items: center; gap: 4px;
}
.qty-btn {
  width: 24px; height: 24px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  border-radius: 4px;
  font-size: .75rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background var(--transition);
}
.qty-btn:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.qty-input {
  width: 44px; text-align: center;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  font-size: .82rem;
  padding: 3px 4px;
  font-weight: 600;
}
.cart-item-total { font-size: .85rem; font-weight: 700; color: var(--primary); min-width: 80px; text-align: right; }
.cart-remove-btn { background: none; border: none; color: var(--danger); font-size: .85rem; padding: 4px; cursor: pointer; }
.cart-empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.cart-empty i { font-size: 2.5rem; margin-bottom: 10px; opacity: .3; }

.cart-summary {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .85rem;
  padding: 3px 0;
  color: var(--text-muted);
}
.summary-row.total {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  border-top: 2px solid var(--border);
  padding-top: 8px;
  margin-top: 4px;
}
.summary-row.total span:last-child { color: var(--primary); }

.cart-actions { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }

/* Payment modal */
.payment-methods { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.payment-method-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 12px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--transition);
}
.payment-method-btn i { font-size: 1.3rem; }
.payment-method-btn:hover { border-color: var(--primary); color: var(--primary); }
.payment-method-btn.selected { border-color: var(--primary); background: #fff7ed; color: var(--primary); }

/* Receipt */
@media print {
  .no-print { display: none !important; }
  .receipt { font-family: 'Courier New', monospace; max-width: 300px; }
}
.receipt {
  font-family: 'Courier New', monospace;
  max-width: 320px;
  margin: 0 auto;
  font-size: .82rem;
  line-height: 1.5;
}
.receipt-header { text-align: center; margin-bottom: 12px; }
.receipt-header h2 { font-size: 1rem; }
.receipt-divider { border: none; border-top: 1px dashed #ccc; margin: 8px 0; }
.receipt-items th, .receipt-items td { padding: 2px 4px; }
.receipt-items th { text-align: left; font-weight: 600; }
.receipt-items td.right { text-align: right; }

/* ── Pagination ────────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; padding: 16px 0;
}
.page-link {
  display: flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .85rem; font-weight: 600;
  color: var(--text-muted);
  transition: all var(--transition);
}
.page-link:hover { border-color: var(--primary); color: var(--primary); }
.page-link.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Sidebar overlay (mobile) ──────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
}

/* ── Stock Indicator ───────────────────────────────────────────── */
.stock-bar { height: 6px; background: var(--border); border-radius: 3px; margin-top: 4px; overflow: hidden; }
.stock-bar-fill { height: 100%; border-radius: 3px; transition: width .5s ease; }
.stock-bar-fill.high   { background: var(--accent); }
.stock-bar-fill.medium { background: var(--warning); }
.stock-bar-fill.low    { background: var(--danger); }

/* ── Tabs ──────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 18px;
  background: none; border: none;
  font-size: .88rem; font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Color dots ────────────────────────────────────────────────── */
.color-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

/* ── Misc utilities ────────────────────────────────────────────── */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--accent); }
.text-accent  { color: var(--accent); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-bold      { font-weight: 700; }
.fw-600       { font-weight: 600; }
.fs-sm        { font-size: .82rem; }
.mt-1 { margin-top: 4px; }  .mt-2 { margin-top: 8px; }  .mt-3 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; }
.p-0 { padding: 0; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 16px; }
.w-100 { width: 100%; }
.text-truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ── Loading spinner ───────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(0,0,0,.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── PWA Install Banner ────────────────────────────────────────── */
.pwa-install-banner {
  display: none;
  align-items: center;
  gap: 12px;
  background: var(--secondary);
  color: #fff;
  padding: 12px 16px;
  border-bottom: 2px solid var(--primary);
  font-size: .85rem;
  position: sticky;
  top: 0;
  z-index: 9999;
}
.pwa-install-banner .pwa-icon { font-size: 1.5rem; }
.pwa-install-banner .pwa-text { flex: 1; }
.pwa-install-banner .pwa-text strong { display: block; font-size: .9rem; }
.pwa-install-banner .pwa-text span   { color: #94a3b8; font-size: .78rem; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .pos-layout { grid-template-columns: 1fr 340px; }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 240px; }

  /* Sidebar slide-in on mobile */
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.mobile-open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.4); }
  .sidebar-overlay { display: block; }
  .sidebar-overlay.active { pointer-events: auto; }
  .main-content { margin-left: 0 !important; }
  .mobile-toggle { display: flex !important; }
  .sidebar-toggle-btn { display: none; }

  /* POS layout stacks vertically on mobile */
  .pos-layout { grid-template-columns: 1fr; grid-template-rows: 1fr auto; height: auto; }
  .pos-products { min-height: 50vh; }
  .pos-cart { height: auto; }

  /* Forms */
  .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }

  /* Stats */
  .stats-grid { grid-template-columns: 1fr 1fr; }

  /* Page layout */
  .page-content { padding: 12px; }
  .top-bar { padding: 0 12px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-header-actions { width: 100%; display: flex; flex-wrap: wrap; gap: 6px; }
  .page-header-actions .btn { flex: 1; min-width: 0; justify-content: center; }

  /* Tables — horizontal scroll on mobile */
  .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-container table { min-width: 600px; }

  /* Cards */
  .card { border-radius: 10px; }

  /* Modal sizing */
  .modal { width: 95vw !important; max-width: 95vw !important; max-height: 90vh; overflow-y: auto; }
  .modal-lg { width: 95vw !important; }

  /* Top bar actions — hide some on mobile */
  .top-bar-right .btn span { display: none; }
  .top-bar-right .btn { padding: 6px 10px; }

  /* Two-column grid layouts collapse */
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"] { display: block !important; }
  [style*="grid-template-columns:1fr 320px"],
  [style*="grid-template-columns: 1fr 320px"] { display: block !important; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .page-content { padding: 10px; }
  .top-bar { padding: 0 10px; }
  h1.page-title { font-size: .95rem; }

  /* Buttons on small phones */
  .btn { font-size: .8rem; padding: 7px 12px; }
  .btn-sm { font-size: .72rem; padding: 4px 8px; }

  /* Tabs stack on mobile */
  .tab-nav { flex-wrap: wrap; }
  .tab-nav a { flex: 1; text-align: center; min-width: 0; font-size: .75rem; }

  /* Filter bars */
  .filter-bar { flex-direction: column; }
  .filter-bar .form-control { width: 100% !important; }

  /* POS specific */
  .pos-topbar { padding: 0 10px; gap: 8px; }
  .pos-topbar .logo span { display: none; }
}

/* ── Safe area insets (iOS notch) ───────────────────────────────── */
@supports (padding-top: env(safe-area-inset-top)) {
  .top-bar { padding-top: max(8px, env(safe-area-inset-top)); }
  .sidebar { padding-bottom: env(safe-area-inset-bottom); }
  .main-content { padding-bottom: env(safe-area-inset-bottom); }
}

/* ── PWA standalone mode overrides ─────────────────────────────── */
@media (display-mode: standalone) {
  .top-bar { padding-top: max(12px, env(safe-area-inset-top, 12px)); }
}

/* ── Login Page ────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #1e293b 100%);
  padding: 20px;
}
.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo i {
  font-size: 2.5rem;
  color: var(--primary);
  display: block;
  margin-bottom: 10px;
}
.login-logo h1 { font-size: 1.4rem; font-weight: 800; }
.login-logo p  { font-size: .82rem; color: var(--text-muted); margin-top: 4px; }

/* ── Install Page ──────────────────────────────────────────────── */
.install-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.install-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 560px;
}

/* ── Charts (canvas) ───────────────────────────────────────────── */
.chart-wrapper { position: relative; height: 220px; }

/* ── Category color chips ──────────────────────────────────────── */
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  background: var(--bg);
}

/* ── Empty state ───────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 3rem; opacity: .25; display: block; margin-bottom: 12px; }
.empty-state h3 { font-size: 1rem; margin-bottom: 6px; color: var(--text); }
.empty-state p  { font-size: .85rem; }

/* ================================================================
   PRINT STYLES
   ================================================================ */
@media print {
  @page {
    size: A4 portrait;
    margin: 12mm 14mm;
  }

  /* Hide UI chrome */
  #sidebar,
  .sidebar,
  #sidebarOverlay,
  .top-bar,
  .page-header-actions,
  .filter-bar,
  .pagination,
  .btn,
  .table-actions,
  .alert,
  .stat-icon,
  canvas,
  .chart-wrapper,
  nav,
  .no-print {
    display: none !important;
  }

  /* Reset layout — full width single column */
  html, body {
    background: #fff !important;
    color: #000 !important;
    font-family: Arial, sans-serif;
    font-size: 11pt;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  /* Override sidebar-driven left margin on .main-content */
  .app-wrapper {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .main-content {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;           /* kills the 260px sidebar offset */
    padding: 0 !important;
    min-height: unset !important;
  }
  .page-content {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 8pt 0 !important;
  }

  /* Page header */
  .page-header {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #000;
    padding-bottom: 6pt;
    margin-bottom: 12pt;
  }
  .page-header h2 {
    font-size: 16pt;
    margin: 0;
    color: #000 !important;
  }

  /* Cards */
  .card {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    margin-bottom: 12pt;
  }
  .card-header {
    background: #f0f0f0 !important;
    color: #000 !important;
    padding: 6pt 10pt !important;
    border-bottom: 1px solid #ccc !important;
  }
  .card-header h3 { font-size: 11pt; margin: 0; }

  /* Tables */
  .table-container { overflow: visible !important; }
  table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 9pt;
    page-break-inside: auto;
  }
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }
  tr    { page-break-inside: avoid; page-break-after: auto; }
  th {
    background: #e8e8e8 !important;
    color: #000 !important;
    border: 1px solid #aaa !important;
    padding: 4pt 6pt !important;
    font-size: 9pt;
  }
  td {
    border: 1px solid #ccc !important;
    padding: 3pt 6pt !important;
    color: #000 !important;
  }
  tr:nth-child(even) td { background: #fafafa !important; }

  /* Badges — show as plain text */
  .badge {
    background: none !important;
    color: #000 !important;
    border: 1px solid #999 !important;
    padding: 1pt 4pt !important;
    border-radius: 2pt;
    font-size: 8pt;
  }

  /* Stats grid — horizontal row */
  .stats-grid {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8pt;
    margin-bottom: 12pt;
  }
  .stat-card {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    padding: 8pt !important;
    flex: 1 1 120pt;
    page-break-inside: avoid;
  }
  .stat-label { font-size: 8pt; color: #555 !important; }
  .stat-value { font-size: 11pt; font-weight: bold; color: #000 !important; }
  .stat-sub   { font-size: 8pt; color: #666 !important; }

  /* Dashboard grid — stack cards vertically */
  .dashboard-grid {
    display: block !important;
  }

  /* Links — show URL only for external links */
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; color: #555; }
  a { color: #000 !important; text-decoration: none !important; }

  /* Color utilities — normalise for black & white print */
  .text-primary,
  .text-success,
  .text-danger,
  .text-warning,
  .text-muted {
    color: #000 !important;
  }
  .fw-600 { font-weight: 700 !important; }

  /* Page breaks */
  .card.full { page-break-before: auto; }
  h2, h3     { page-break-after: avoid; }

  /* Stock bars — hide visual bar, keep number */
  .stock-bar { display: none !important; }

  /* Print header watermark (shop name, date) */
  body::before {
    content: "Printed: " attr(data-print-date);
    display: block;
    text-align: right;
    font-size: 8pt;
    color: #888;
    margin-bottom: 4pt;
  }
}
