/* ============================================================
   PrimeMart — Supermart Management System (web)
   Theme: deep navy + gold (matches PrimeMart brand).
   ============================================================ */

:root {
  --navy: #0f1e3d;
  --navy-dark: #0a1429;
  --navy-light: #1a2b5c;
  --gold: #d4a017;
  --gold-dark: #b3860f;
  --gold-light: #fef3c7;
  --blue: #2563eb;
  --blue-light: #dbeafe;
  --ink: #1e293b;
  --muted: #64748b;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --red: #dc2626;
  --red-light: #fee2e2;
  --green: #16a34a;
  --green-light: #dcfce7;
  --amber: #d97706;
  --amber-light: #fef3c7;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

/* ================= LOGIN SCREEN ================= */
.login-screen {
  min-height: 100vh;
  display: flex;
}
.login-left {
  flex: 1.2;
  background: linear-gradient(160deg, var(--navy-dark) 0%, var(--navy) 55%, var(--navy-light) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.login-left::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 120%, rgba(212, 160, 23, 0.18), transparent 60%);
}
.login-left > * { position: relative; z-index: 1; }
.verse-ar {
  font-size: 34px;
  color: var(--gold);
  margin-bottom: 10px;
  font-family: "Traditional Arabic", "Scheherazade New", serif;
}
.verse-ur {
  font-size: 16px;
  opacity: 0.9;
  margin-bottom: 6px;
}
.verse-ref {
  font-size: 12px;
  letter-spacing: 3px;
  opacity: 0.55;
  margin-bottom: 34px;
}
.login-logo {
  width: 110px; height: 110px;
  border-radius: 50%;
  background: var(--navy-dark);
  border: 3px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 52px;
  margin-bottom: 18px;
  box-shadow: 0 8px 32px rgba(212, 160, 23, 0.35);
}
.login-brand {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 8px;
}
.login-brand .gold { color: var(--gold); }
.login-tag {
  font-size: 13px;
  opacity: 0.65;
  letter-spacing: 2px;
  margin-top: 6px;
}
.login-right {
  flex: 1;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
.login-box { width: 100%; max-width: 380px; }
.login-box h2 { font-size: 28px; margin-bottom: 6px; }
.login-box .sub { color: var(--muted); font-size: 14px; margin-bottom: 26px; }
.login-err {
  display: none;
  background: var(--red-light);
  color: var(--red);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 16px;
}
.login-hint {
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--gold-light);
  border: 1px dashed var(--gold);
  border-radius: 8px;
  padding: 10px 12px;
}

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

.sidebar {
  width: 244px;
  background: linear-gradient(180deg, var(--navy-dark), var(--navy));
  color: #fff;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.25s ease;
}
.brand {
  padding: 20px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(212, 160, 23, 0.25);
}
.brand .logo {
  width: 42px; height: 42px;
  background: var(--gold);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.brand h1 { font-size: 17px; line-height: 1.2; }
.brand h1 .gold { color: var(--gold); }
.brand small { font-size: 11px; opacity: 0.7; font-weight: normal; }

.nav { padding: 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav a {
  color: #c9d4f2;
  text-decoration: none;
  padding: 11px 14px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14.5px;
  cursor: pointer;
  transition: background 0.15s;
}
.nav a:hover { background: rgba(255, 255, 255, 0.08); }
.nav a.active { background: var(--gold); color: var(--navy-dark); font-weight: 700; }
.nav a .icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar .foot {
  margin-top: auto;
  padding: 14px 18px;
  font-size: 12px;
  opacity: 0.7;
  border-top: 1px solid rgba(212, 160, 23, 0.2);
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid rgba(212, 160, 23, 0.2);
  font-size: 13px;
}
.user-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--gold); color: var(--navy-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.user-chip button {
  margin-left: auto;
  background: none; border: 1px solid rgba(255,255,255,0.3);
  color: #fff; border-radius: 6px; padding: 4px 10px;
  cursor: pointer; font-size: 12px;
}
.user-chip button:hover { background: rgba(255,255,255,0.12); }

/* Main area */
.main { margin-left: 244px; flex: 1; min-width: 0; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar h2 { font-size: 20px; }
.topbar .date { margin-left: auto; color: var(--muted); font-size: 13.5px; }

.menu-btn {
  display: none;
  background: none; border: none;
  font-size: 24px; cursor: pointer; color: var(--ink);
}

.content { padding: 24px; max-width: 1200px; margin: 0 auto; }

section.page { display: none; }
section.page.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Cards & stats ---------- */
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 20px; }

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-left: 4px solid var(--gold);
}
.stat-card.blue { border-left-color: var(--blue); }
.stat-card.green { border-left-color: var(--green); }
.stat-card.red { border-left-color: var(--red); }
.stat-card .s-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
}
.stat-card .s-icon.gold { background: var(--gold-light); }
.stat-card .s-icon.blue { background: var(--blue-light); }
.stat-card .s-icon.green { background: var(--green-light); }
.stat-card .s-icon.red { background: var(--red-light); }
.stat-card .s-num { font-size: 26px; font-weight: 700; }
.stat-card .s-label { font-size: 13px; color: var(--muted); }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card h3 { font-size: 16px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }

.two-col { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.4px; }
tr:hover td { background: #f8fafc; }

/* ---------- Buttons & badges ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--gold);
  color: var(--navy-dark); border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.btn:hover { background: var(--gold-dark); color: #fff; }
.btn.blue { background: var(--blue); color: #fff; }
.btn.blue:hover { background: #1d4ed8; }
.btn.gray { background: #e2e8f0; color: var(--ink); }
.btn.gray:hover { background: #cbd5e1; }
.btn.red { background: var(--red); color: #fff; }
.btn.red:hover { background: #b91c1c; }
.btn.green { background: var(--green); color: #fff; }
.btn.green:hover { background: #15803d; }
.btn.small { padding: 6px 12px; font-size: 13px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge.green { background: var(--green-light); color: var(--green); }
.badge.amber { background: var(--amber-light); color: var(--amber); }
.badge.red { background: var(--red-light); color: var(--red); }
.badge.blue { background: var(--blue-light); color: var(--blue); }
.badge.gold { background: var(--gold-light); color: var(--gold-dark); }
.badge.gray { background: #e2e8f0; color: var(--muted); }

/* ---------- Forms ---------- */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar .spacer { flex: 1; }

input, select, textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--gold-light);
  border-color: var(--gold);
}
.search { max-width: 280px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--muted); }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 20, 41, 0.55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 200;
  padding: 30px 16px;
  overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 620px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  animation: fadeIn 0.2s ease;
}
.modal.wide { max-width: 860px; }
.modal h3 { margin-bottom: 16px; font-size: 18px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ---------- Activity feed ---------- */
.activity { list-style: none; }
.activity li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.activity li:last-child { border-bottom: none; }
.activity .a-time { color: var(--muted); font-size: 12px; white-space: nowrap; margin-left: auto; }

/* ---------- POS ---------- */
.pos-layout { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
@media (max-width: 900px) { .pos-layout { grid-template-columns: 1fr; } }
.pos-results { max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.pos-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.pos-item:hover { background: var(--gold-light); }
.pos-item .p-name { font-weight: 600; }
.pos-item .p-price { margin-left: auto; color: var(--muted); font-size: 13px; }
.cart-row { display: grid; grid-template-columns: 1fr 70px 90px 90px 30px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.cart-row.head { font-weight: 700; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.cart-totals .row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.cart-totals .grand { font-weight: 700; font-size: 18px; border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 8px; }

/* ---------- Receipt print ---------- */
.receipt-box { border: 1px solid var(--border); border-radius: 10px; padding: 24px; max-width: 420px; margin: 0 auto; }
.receipt-box .r-center { text-align: center; }
.receipt-box h2 { color: var(--navy); }
.receipt-line { display: flex; justify-content: space-between; font-size: 14px; padding: 3px 0; }
.receipt-total { font-weight: 700; font-size: 16px; border-top: 2px dashed var(--ink); margin-top: 8px; padding-top: 8px; }

/* Line-item editor (purchases) */
.line-item { display: grid; grid-template-columns: 2fr 1fr 1fr 40px; gap: 8px; margin-bottom: 8px; align-items: center; }
.line-item .rm { background: var(--red-light); color: var(--red); border: none; border-radius: 6px; cursor: pointer; font-size: 16px; padding: 8px; }
@media (max-width: 600px) { .line-item { grid-template-columns: 1fr 1fr; } }

/* ---------- Responsive ---------- */
.overlay { display: none; }

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-btn { display: block; }
  .overlay.show {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 90;
  }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .topbar .date { display: none; }
  .login-screen { flex-direction: column; }
  .login-left { padding: 32px 20px; }
  .login-brand { font-size: 32px; }
}

/* Print: only the receipt */
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { position: absolute; left: 0; top: 0; width: 100%; }
  .no-print { display: none !important; }
}

/* ---------- Auth screens + Settings ---------- */
.hidden { display: none !important; }
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: linear-gradient(135deg, #0f172a, #0d9488);
}
.auth-card {
  background: #fff; border-radius: 16px; padding: 32px; width: 100%; max-width: 460px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.auth-logo { font-size: 44px; text-align: center; }
.auth-card h2 { text-align: center; margin: 8px 0 6px; font-size: 22px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.auth-card label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.auth-card label input, .auth-card label select { margin-top: 5px; }
.auth-btn { width: 100%; margin-top: 8px; }
.auth-error { color: var(--red); font-size: 13px; min-height: 18px; margin: 4px 0 8px; }
.auth-check { display: flex !important; align-items: center; gap: 8px; font-weight: 400 !important; }
.auth-check input { width: auto !important; margin: 0 !important; }
.auth-alt { text-align: center; font-size: 13px; margin-top: 14px; }
.auth-alt a { color: var(--blue); }
#page-settings label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 12px; }
#page-settings label input, #page-settings label select { margin-top: 5px; }
