/* =========================================================
   Design tokens
   ========================================================= */
:root {
  --bg-deep: #0b1220;
  --bg-deep-2: #0f1b2d;
  --panel: rgba(255,255,255,0.06);
  --panel-border: rgba(255,255,255,0.12);
  --ink: #e7edf3;
  --ink-dim: #94a3b8;
  --accent-green: #22c55e;
  --accent-green-dim: #16a34a;
  --accent-gold: #f2b544;
  --accent-blue: #38bdf8;
  --accent-red: #ef4444;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-display: 'Poppins', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

[data-theme="light"] {
  --bg-deep: #eef3f1;
  --bg-deep-2: #f8faf9;
  --panel: rgba(255,255,255,0.85);
  --panel-border: rgba(15,23,42,0.08);
  --ink: #0f172a;
  --ink-dim: #55637a;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--ink);
}

h1, h2, h3, h4, h5, .display-font { font-family: var(--font-display); }
.mono, .money, .qty-badge { font-family: var(--font-mono); }

a { text-decoration: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(148,163,184,.35); border-radius: 8px; }

/* =========================================================
   Auth pages (login / forgot / reset)
   ========================================================= */
.auth-body {
  min-height: 100vh;
  background: radial-gradient(circle at 15% 10%, #123a2e 0%, #0b1220 45%, #070c15 100%);
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden; padding: 2rem 1rem;
}
.auth-bg-shape {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: .35; z-index: 0;
}
.shape-a { width: 420px; height: 420px; background: var(--accent-green); top: -120px; left: -100px; }
.shape-b { width: 380px; height: 380px; background: var(--accent-blue); bottom: -120px; right: -80px; }

.glass-card {
  background: var(--panel);
  backdrop-filter: blur(20px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 70px rgba(0,0,0,.45);
}

.auth-wrapper { position: relative; z-index: 1; width: 100%; max-width: 420px; }
.auth-card { padding: 2.5rem 2.25rem; color: var(--ink); }
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-logo { width: 64px; height: 64px; border-radius: 16px; object-fit: cover; margin-bottom: .75rem; }
.auth-logo-fallback {
  width: 64px; height: 64px; border-radius: 16px; margin: 0 auto .75rem;
  background: linear-gradient(135deg, var(--accent-green), var(--accent-blue));
  display: flex; align-items: center; justify-content: center; font-size: 1.6rem; color: #fff;
}
.auth-brand h1 { font-size: 1.35rem; font-weight: 700; margin-bottom: .25rem; }
.auth-datetime { color: var(--ink-dim); font-size: .8rem; }

.input-icon-group { position: relative; }
.input-icon-group i.fa-solid:first-child {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-dim); font-size: .85rem;
}
.input-icon-group .form-control { padding-left: 2.4rem; }
.toggle-pass {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--ink-dim); cursor: pointer;
}
.forgot-link { color: var(--accent-blue); }

.btn-signin {
  background: linear-gradient(135deg, var(--accent-green), #0ea5e9);
  color: #fff; font-weight: 600; padding: .7rem; border: none; border-radius: var(--radius-sm);
  transition: filter .15s ease, transform .15s ease;
}
.btn-signin:hover { filter: brightness(1.1); transform: translateY(-1px); color:#fff; }
.auth-footer-note { text-align: center; color: var(--ink-dim); font-size: .75rem; margin-top: 1.25rem; }

[data-theme] .form-control,
.auth-body .form-control {
  background: rgba(255,255,255,0.05); border: 1px solid var(--panel-border); color: var(--ink);
}
.auth-body .form-control:focus {
  background: rgba(255,255,255,0.09); color: var(--ink); border-color: var(--accent-green);
  box-shadow: 0 0 0 .25rem rgba(34,197,94,.15);
}
.auth-body .form-control::placeholder { color: var(--ink-dim); }

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

.sidebar {
  width: 250px; flex-shrink: 0;
  background: var(--bg-deep-2);
  border-right: 1px solid var(--panel-border);
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 1030;
  display: flex; flex-direction: column;
  transition: transform .25s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .6rem; padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--panel-border);
}
.sidebar-brand .brand-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-green), var(--accent-blue));
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.sidebar-brand span { font-family: var(--font-display); font-weight: 700; color: var(--ink); font-size: 1.05rem; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem .75rem; }
.sidebar-nav .nav-section-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-dim);
  padding: .75rem .75rem .3rem;
}
.sidebar-nav a.nav-link {
  display: flex; align-items: center; gap: .75rem; color: var(--ink-dim);
  padding: .65rem .85rem; border-radius: var(--radius-sm); font-size: .9rem; font-weight: 500;
  margin-bottom: 2px; transition: background .15s ease, color .15s ease;
}
.sidebar-nav a.nav-link i { width: 18px; text-align: center; }
.sidebar-nav a.nav-link:hover { background: rgba(255,255,255,.06); color: var(--ink); }
.sidebar-nav a.nav-link.active {
  background: linear-gradient(135deg, rgba(34,197,94,.18), rgba(56,189,248,.12));
  color: var(--ink); box-shadow: inset 3px 0 0 var(--accent-green);
}
.sidebar-foot { padding: 1rem; border-top: 1px solid var(--panel-border); }

.main-col { margin-left: 250px; flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 66px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; border-bottom: 1px solid var(--panel-border);
  background: var(--bg-deep); position: sticky; top: 0; z-index: 1020;
}
.topbar .btn-icon {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--panel-border);
  background: var(--panel); color: var(--ink); display: flex; align-items: center; justify-content: center;
  position: relative;
}
.topbar .btn-icon .badge-dot {
  position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-red);
}
.sidebar-toggle-btn { display: none; }

.page-content { padding: 1.75rem; flex: 1; }

.card-glass {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius-md);
  backdrop-filter: blur(10px);
}

.stat-card { padding: 1.35rem; border-radius: var(--radius-md); position: relative; overflow: hidden; }
.stat-card .stat-icon {
  width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; color: #fff; margin-bottom: .85rem;
}
.stat-card .stat-value { font-family: var(--font-mono); font-size: 1.55rem; font-weight: 700; }
.stat-card .stat-label { color: var(--ink-dim); font-size: .8rem; }
.stat-card .stat-trend { font-size: .75rem; margin-top: .35rem; }

.btn-brand {
  background: linear-gradient(135deg, var(--accent-green), var(--accent-green-dim));
  border: none; color: #fff; font-weight: 600;
}
.btn-brand:hover { filter: brightness(1.08); color: #fff; }

/* Bootstrap's .btn-outline-light is hardcoded near-white text/border, which
   disappears against the light theme's light backgrounds. Every "Edit"
   button in the app uses this class, so tie it to the theme's ink color
   instead — keeps the same look on dark theme, fixes visibility on light. */
.btn-outline-light {
  color: var(--accent-blue);
  border: 1.5px solid var(--accent-blue);
  background-color: transparent;
  font-weight: 600;
}
.btn-outline-light:hover,
.btn-outline-light:focus,
.btn-outline-light:active {
  color: #fff;
  background-color: var(--accent-blue);
  border-color: var(--accent-blue);
}

.table-glass {
  /* Bootstrap paints every cell's background from --bs-table-bg, which
     defaults to Bootstrap's own white root variable. It ignores our dark
     theme entirely unless we override it here, which is why table rows
     were showing solid white regardless of theme. */
  --bs-table-bg: transparent;
  --bs-table-color: var(--ink);
  color: var(--ink);
}
.table-glass thead th { color: var(--ink-dim); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--panel-border); font-weight: 700; }
.table-glass td, .table-glass th { border-color: var(--panel-border); vertical-align: middle; background-color: transparent; }

.badge-stock-ok { background: rgba(34,197,94,.15); color: var(--accent-green); }
.badge-stock-low { background: rgba(242,181,68,.18); color: var(--accent-gold); }
.badge-stock-out { background: rgba(239,68,68,.18); color: var(--accent-red); }

.touch-btn { min-height: 52px; font-size: 1rem; border-radius: var(--radius-sm); font-weight: 600; }

/* POS specific */
.pos-grid { display: grid; grid-template-columns: 1fr 380px; gap: 1.25rem; align-items: start; }
@media (max-width: 992px) { .pos-grid { grid-template-columns: 1fr; } }

.product-tile {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius-md);
  padding: .9rem; cursor: pointer; transition: transform .12s ease, border-color .12s ease; text-align: left;
}
.product-tile:hover { transform: translateY(-3px); border-color: var(--accent-green); }
.product-tile .p-name { font-weight: 600; font-size: .88rem; }
.product-tile .p-price { color: var(--accent-green); font-family: var(--font-mono); font-weight: 700; }
.product-tile .p-stock { font-size: .7rem; color: var(--ink-dim); }

.cart-panel { position: sticky; top: 82px; }
.cart-item { display: flex; align-items: center; gap: .6rem; padding: .55rem 0; border-bottom: 1px dashed var(--panel-border); }
.cart-item .ci-name { font-size: .85rem; font-weight: 600; flex: 1; }
.cart-item .ci-qty input { width: 56px; text-align: center; }

/* AI assistant widget */
.ai-fab {
  position: fixed; bottom: 24px; right: 24px; width: 58px; height: 58px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-green), var(--accent-blue)); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
  box-shadow: 0 12px 30px rgba(0,0,0,.35); z-index: 1050; border: none; cursor: pointer;
  animation: pulse-glow 2.4s infinite;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 12px 30px rgba(0,0,0,.35), 0 0 0 0 rgba(34,197,94,.4); }
  50% { box-shadow: 0 12px 30px rgba(0,0,0,.35), 0 0 0 10px rgba(34,197,94,0); }
}
.ai-panel {
  position: fixed; bottom: 96px; right: 24px; width: 340px; max-height: 460px;
  background: var(--bg-deep-2); border: 1px solid var(--panel-border); border-radius: var(--radius-md);
  box-shadow: 0 25px 60px rgba(0,0,0,.5); z-index: 1050; display: none; flex-direction: column; overflow: hidden;
}
.ai-panel.open { display: flex; }
.ai-panel-head { padding: .85rem 1rem; border-bottom: 1px solid var(--panel-border); display: flex; justify-content: space-between; align-items: center; }
.ai-panel-body { padding: .85rem 1rem; overflow-y: auto; flex: 1; font-size: .85rem; }
.ai-msg { margin-bottom: .6rem; padding: .55rem .75rem; border-radius: 10px; max-width: 90%; }
.ai-msg.from-user { background: rgba(56,189,248,.15); margin-left: auto; }
.ai-msg.from-bot { background: rgba(255,255,255,.06); }
.ai-panel-foot { padding: .65rem; border-top: 1px solid var(--panel-border); }

/* Responsive */
@media (max-width: 992px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-col { margin-left: 0; }
  .sidebar-toggle-btn { display: flex; }
  .cart-panel { position: static; }
}

.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1025;
}
.sidebar-overlay.show { display: block; }

.fade-in { animation: fadeIn .35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
