/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: var(--space-4);
  position: relative;
  overflow: hidden;
}
.login-bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
}
.login-bg-orb-1 {
  width: 400px; height: 400px;
  background: rgba(59,130,246,0.08);
  top: -100px; left: -100px;
}
.login-bg-orb-2 {
  width: 300px; height: 300px;
  background: rgba(168,85,247,0.06);
  bottom: -80px; right: -80px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: var(--space-10) var(--space-8);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: 1;
}
.login-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}
.login-logo-icon {
  width: 44px;
  height: 44px;
  background: var(--accent-blue);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-blue);
}
.login-logo-icon svg { width: 24px; height: 24px; color: #fff; }
.login-logo-text h1 {
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.login-logo-text span {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 500;
  display: block;
}
.login-heading {
  font-size: var(--text-2xl);
  font-weight: 800;
  margin-bottom: var(--space-1);
  letter-spacing: -0.02em;
}
.login-subheading {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-8);
}
.login-form { display: flex; flex-direction: column; gap: var(--space-4); }
.login-submit-btn {
  width: 100%;
  padding: 14px;
  font-size: var(--text-md);
  font-weight: 700;
  margin-top: var(--space-2);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 20px var(--space-5);
  border-bottom: 1px solid var(--border);
}
.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-blue);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-blue);
}
.sidebar-logo-icon svg { width: 20px; height: 20px; color: #fff; }
.sidebar-logo-text {
  font-size: var(--text-md);
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-3) 0;
  overflow-y: auto;
}
.sidebar-nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-disabled);
  padding: var(--space-4) var(--space-5) var(--space-2);
}
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-5);
  margin: 1px var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  position: relative;
}
.sidebar-nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-nav-item:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
}
.sidebar-nav-item.active {
  background: rgba(59,130,246,0.1);
  color: var(--accent-blue);
}
.sidebar-nav-item.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--accent-blue);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.sidebar-nav-item .nav-badge {
  margin-left: auto;
  background: var(--accent-red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.sidebar-logout-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: 9px var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}
.sidebar-logout-btn svg { width: 15px; height: 15px; }
.sidebar-logout-btn:hover {
  color: var(--accent-red);
  border-color: rgba(239,68,68,0.3);
  background: rgba(239,68,68,0.06);
}

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  height: 60px;
  min-height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: var(--space-3); }
.topbar-title {
  font-size: var(--text-md);
  font-weight: 700;
}
.topbar-right { display: flex; align-items: center; gap: var(--space-3); }
.topbar-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--card);
}
.topbar-branch {
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--card);
  font-weight: 500;
}
.topbar-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}

/* ============================================================
   BOTTOM NAV (mobile)
   ============================================================ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(17,17,24,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-inner {
  display: flex;
  height: 56px;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text-disabled);
  transition: color var(--transition-fast);
  position: relative;
  padding: var(--space-2) 0;
}
.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item span { font-size: 9px; font-weight: 600; }
.bottom-nav-item.active { color: var(--accent-blue); }
.bottom-nav-item .nav-dot {
  position: absolute;
  top: 8px;
  right: calc(50% - 14px);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-red);
}

/* ============================================================
   POS LAYOUT
   ============================================================ */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--space-5);
  height: 100%;
  min-height: 0;
}
.pos-left {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-height: 0;
  overflow: hidden;
}
.pos-products-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  overflow-y: auto;
  padding-bottom: var(--space-2);
}
.pos-right {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.pos-cart-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pos-cart-header-title {
  font-size: var(--text-md);
  font-weight: 700;
}
.pos-cart-items {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) var(--space-5);
}
.pos-cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: var(--space-3);
  color: var(--text-disabled);
}
.pos-cart-empty svg { width: 40px; height: 40px; }
.pos-cart-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
}
.pos-cart-totals { margin-bottom: var(--space-4); }
.pos-cart-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.pos-cart-total-row.grand {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--text-primary);
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
  margin-top: var(--space-2);
}
.pos-cart-total-row.grand .pos-total-amount {
  color: var(--accent-blue);
}
.pos-charge-btn {
  width: 100%;
  padding: 16px;
  font-size: var(--text-lg);
  font-weight: 800;
  border-radius: var(--radius);
  letter-spacing: -0.01em;
}

/* ============================================================
   GRID LAYOUTS
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }

/* ============================================================
   RESPONSIVE — TABLET
   ============================================================ */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .pos-products-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   RESPONSIVE — MOBILE (<768px)
   ============================================================ */
@media (max-width: 767px) {
  body { overflow: hidden; }

  .sidebar { display: none; }
  .bottom-nav { display: block; }

  .topbar { padding: 0 var(--space-4); height: 56px; }
  .topbar-branch, .topbar-time { display: none; }

  .page-content {
    padding: var(--space-4);
    padding-bottom: 80px;
  }

  /* POS: stacked layout on mobile */
  .pos-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    gap: var(--space-3);
    height: auto;
  }
  .pos-right {
    border-radius: var(--radius);
    max-height: 60vh;
  }
  .pos-products-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-2 { grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }

  /* KPI cards — big Apple Stocks style numbers */
  .kpi-card-value { font-size: var(--text-2xl); }
  .kpi-card { padding: var(--space-4); }

  /* Tables → hidden on mobile (show list rows instead) */
  .hide-mobile { display: none !important; }
  .show-mobile { display: flex !important; }

  .modal { max-width: 100%; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }

  .section-title { font-size: var(--text-lg); }

  .form-row { grid-template-columns: 1fr; }

  .payment-method-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 768px) {
  .show-mobile { display: none !important; }
}
