/* ============================================
   DAZIE EMS — Main Stylesheet
   Dark industrial theme with teal accent
   Fonts: Syne (display) + DM Sans (body) + DM Mono (data)
   ============================================ */

:root {
  --bg-0: #0d1117;
  --bg-1: #161b22;
  --bg-2: #1c2230;
  --bg-3: #242c3a;
  --bg-4: #2d3748;
  --border: rgba(255,255,255,0.08);
  --border-md: rgba(255,255,255,0.14);
  --teal: #22c5a0;
  --teal-dim: #1a9e82;
  --teal-bg: rgba(34,197,160,0.1);
  --teal-bg-hover: rgba(34,197,160,0.18);
  --amber: #f0a855;
  --amber-bg: rgba(240,168,85,0.12);
  --red: #f07070;
  --red-bg: rgba(240,112,112,0.12);
  --blue: #60a5fa;
  --blue-bg: rgba(96,165,250,0.12);
  --text-1: #e6edf3;
  --text-2: #8b949e;
  --text-3: #6e7681;
  --sidebar-w: 220px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-0);
  color: var(--text-1);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.brand-text { display: flex; flex-direction: column; }
.brand-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--teal);
  line-height: 1.1;
}
.brand-sub { font-size: 10px; color: var(--text-3); letter-spacing: 0.04em; }

.sidebar-nav { flex: 1; padding: 12px 10px; }

.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 14px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 400;
  transition: all 0.15s;
  margin-bottom: 1px;
}
.nav-item:hover { background: var(--bg-3); color: var(--text-1); }
.nav-item.active { background: var(--teal-bg); color: var(--teal); font-weight: 500; }
.nav-item.active .ni { color: var(--teal); }
.ni { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.75; }
.nav-item:hover .ni, .nav-item.active .ni { opacity: 1; }

.sidebar-footer {
  padding: 12px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-chip { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.user-av {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--teal);
  color: #0d1117;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role-tag { font-size: 10px; color: var(--text-3); }
.logout-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; color: var(--text-3);
  text-decoration: none;
  transition: all 0.15s;
  flex-shrink: 0;
}
.logout-btn:hover { background: var(--red-bg); color: var(--red); }

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

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  z-index: 50;
}
.menu-btn {
  display: none;
  background: none; border: none; color: var(--text-2);
  cursor: pointer; padding: 4px;
}
.page-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--text-1);
  flex: 1;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }

.content-body { padding: 24px; }

/* ── Messages ── */
.msg-stack { padding: 12px 24px 0; display: flex; flex-direction: column; gap: 6px; }
.msg {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13.5px; gap: 12px;
}
.msg-success { background: rgba(34,197,160,0.15); color: var(--teal); border: 1px solid rgba(34,197,160,0.25); }
.msg-error { background: var(--red-bg); color: var(--red); border: 1px solid rgba(240,112,112,0.25); }
.msg-warning { background: var(--amber-bg); color: var(--amber); border: 1px solid rgba(240,168,85,0.25); }
.msg-close { background: none; border: none; color: inherit; cursor: pointer; font-size: 18px; line-height: 1; opacity: 0.7; }
.msg-close:hover { opacity: 1; }

/* ── Stat cards ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
}
.stat-card.teal::before { background: var(--teal); }
.stat-card.amber::before { background: var(--amber); }
.stat-card.red::before { background: var(--red); }
.stat-card.blue::before { background: var(--blue); }
.stat-label { font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 6px; }
.stat-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--text-1); line-height: 1.1; }
.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ── Cards ── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-family: var(--font-display);
  font-size: 14px; font-weight: 600; color: var(--text-1);
}
.card-body { padding: 20px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left; padding: 10px 14px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text-1); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.data-table .mono { font-family: var(--font-mono); font-size: 12.5px; color: var(--blue); }
.data-table .amount { font-family: var(--font-mono); }
.data-table .amount.owed { color: var(--amber); }
.data-table .amount.positive { color: var(--teal); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 500; line-height: 1.6;
  white-space: nowrap;
}
.badge-teal { background: var(--teal-bg); color: var(--teal); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-gray { background: var(--bg-4); color: var(--text-2); }
.badge-class-A { background: rgba(34,197,160,0.15); color: var(--teal); border: 1px solid rgba(34,197,160,0.3); }
.badge-class-B { background: rgba(240,168,85,0.15); color: var(--amber); border: 1px solid rgba(240,168,85,0.3); }
.badge-class-C { background: rgba(110,118,129,0.15); color: var(--text-2); border: 1px solid rgba(110,118,129,0.25); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer;
  text-decoration: none; transition: all 0.15s; line-height: 1;
}
.btn-primary { background: var(--teal); color: #0d1117; border-color: var(--teal); }
.btn-primary:hover { background: var(--teal-dim); border-color: var(--teal-dim); }
.btn-secondary { background: var(--bg-3); color: var(--text-1); border-color: var(--border-md); }
.btn-secondary:hover { background: var(--bg-4); border-color: var(--border-md); }
.btn-danger { background: var(--red-bg); color: var(--red); border-color: rgba(240,112,112,0.3); }
.btn-danger:hover { background: rgba(240,112,112,0.2); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-icon { padding: 7px; border-radius: var(--radius-sm); }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 500; letter-spacing: 0.04em; color: var(--text-2); margin-bottom: 5px; text-transform: uppercase; }
.form-control, .form-select {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  padding: 9px 12px;
  font-family: var(--font-body);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(34,197,160,0.15);
  background: var(--bg-2);
}
.form-control::placeholder { color: var(--text-3); }
.form-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236e7681'%3E%3Cpath d='M5 8l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 32px; cursor: pointer; }
.form-hint { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--red); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Page header ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-header-left h2 { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.page-header-left p { font-size: 13px; color: var(--text-3); margin-top: 2px; }

/* ── Filter bar ── */
.filter-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.filter-bar .form-control, .filter-bar .form-select { max-width: 200px; }
.search-input { flex: 1; min-width: 180px; max-width: 320px !important; }

/* ── POS specific ── */
.pos-layout { display: grid; grid-template-columns: 1fr 360px; gap: 20px; min-height: calc(100vh - 120px); }
.pos-left { display: flex; flex-direction: column; gap: 16px; }
.pos-right { position: sticky; top: 80px; align-self: start; display: flex; flex-direction: column; gap: 12px; }

.pos-search-wrap { position: relative; }
.pos-search { width: 100%; font-size: 16px; padding: 12px 16px 12px 44px; }
.pos-search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.product-suggestions {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 200;
  background: var(--bg-2); border: 1px solid var(--border-md);
  border-radius: var(--radius); margin-top: 4px;
  box-shadow: var(--shadow); max-height: 280px; overflow-y: auto;
}
.product-suggestion-item {
  padding: 10px 14px; cursor: pointer; display: flex;
  align-items: center; justify-content: space-between;
  transition: background 0.1s;
}
.product-suggestion-item:hover { background: var(--bg-3); }
.sug-name { font-weight: 500; font-size: 13.5px; }
.sug-stock { font-size: 12px; color: var(--text-3); }

.cart-table { width: 100%; border-collapse: collapse; }
.cart-table th { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.cart-table td { padding: 8px 8px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
.cart-table tr:last-child td { border-bottom: none; }
.qty-input { width: 60px; background: var(--bg-3); border: 1px solid var(--border-md); color: var(--text-1); border-radius: 4px; padding: 4px 6px; font-family: var(--font-mono); font-size: 13px; text-align: center; }
.qty-input:focus { outline: none; border-color: var(--teal); }
.price-display { font-family: var(--font-mono); font-size: 13px; }
.tier-badge { font-size: 10px; color: var(--teal); display: block; }
.remove-item { background: none; border: none; color: var(--red); cursor: pointer; padding: 2px 6px; border-radius: 4px; font-size: 16px; }
.remove-item:hover { background: var(--red-bg); }

.cart-total-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 4px; border-top: 1px solid var(--border-md); }
.cart-total-label { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
.cart-total-value { font-family: var(--font-display); font-size: 24px; font-weight: 700; color: var(--teal); }

/* ── Receipt ── */
.receipt-wrap { max-width: 420px; margin: 0 auto; }
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
  .receipt-paper { border: none !important; box-shadow: none !important; background: #fff !important; }
}
.receipt-paper { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px 28px; }
.receipt-header { text-align: center; margin-bottom: 20px; border-bottom: 1px dashed var(--border-md); padding-bottom: 16px; }
.receipt-co { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--teal); letter-spacing: 0.05em; }
.receipt-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.receipt-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); margin-bottom: 16px; }
.receipt-items { width: 100%; border-collapse: collapse; font-size: 13px; }
.receipt-items th { text-align: left; padding: 6px 0; font-size: 11px; color: var(--text-3); border-bottom: 1px solid var(--border); }
.receipt-items td { padding: 7px 0; border-bottom: 1px solid var(--border); }
.receipt-items tr:last-child td { border-bottom: none; }
.receipt-total { display: flex; justify-content: space-between; padding: 14px 0 0; font-family: var(--font-display); font-size: 18px; font-weight: 700; border-top: 2px solid var(--border-md); margin-top: 8px; }
.receipt-footer { text-align: center; font-size: 11px; color: var(--text-3); margin-top: 20px; padding-top: 12px; border-top: 1px dashed var(--border-md); }

/* ── Dashboard ── */
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.segment-bars { display: flex; gap: 8px; margin-top: 10px; }
.seg-bar { flex: 1; text-align: center; }
.seg-label { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.seg-value { font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.seg-bar.a .seg-value { color: var(--teal); }
.seg-bar.b .seg-value { color: var(--amber); }
.seg-bar.c .seg-value { color: var(--text-2); }

/* ── Utility ── */
.text-teal { color: var(--teal); }
.text-amber { color: var(--amber); }
.text-red { color: var(--red); }
.text-muted { color: var(--text-3); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mono { font-family: var(--font-mono); }
.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; } .mb-3 { margin-bottom: 24px; }
.gap-2 { gap: 12px; }
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty-state p { font-size: 14px; margin-top: 8px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Auth page ── */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-0);
}
.auth-brand {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
  flex-direction: column; gap: 24px;
}
.auth-brand-logo { display: flex; align-items: center; gap: 14px; }
.auth-brand-name { font-family: var(--font-display); font-size: 36px; font-weight: 700; color: var(--teal); letter-spacing: 0.06em; }
.auth-brand-tagline { font-size: 14px; color: var(--text-3); text-align: center; max-width: 280px; line-height: 1.7; }
.auth-form-side {
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.auth-box { width: 100%; max-width: 380px; }
.auth-title { font-family: var(--font-display); font-size: 26px; font-weight: 600; margin-bottom: 6px; }
.auth-subtitle { font-size: 13.5px; color: var(--text-3); margin-bottom: 28px; }
.auth-box .btn-primary { width: 100%; justify-content: center; padding: 11px; font-size: 15px; margin-top: 4px; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-btn { display: flex; }
  .pos-layout { grid-template-columns: 1fr; }
  .pos-right { position: static; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .content-body { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
