/* ═══════════════════════════════════════════════
   OSEMFLOW POS — Stylesheet
   ═══════════════════════════════════════════════ */

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

:root {
  --bg:          #0d1117;
  --surface:     #111827;
  --card:        #1a1f2e;
  --border:      #1e2436;
  --border2:     #2a3045;
  --text:        #f0f4ff;
  --text2:       #c9d1e8;
  --muted:       #8892b0;
  --faint:       #6b7490;
  --accent:      #6366f1;
  --accent2:     #8b5cf6;
  --green:       #10b981;
  --orange:      #f97316;
  --red:         #f87171;
  --yellow:      #f59e0b;
  --sidebar-w:   220px;
  --topbar-h:    56px;
  --radius:      10px;
  --radius-lg:   14px;
}

html, body { height: 100%; font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* ─── SCROLLBAR ────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* ─── LAYOUT ────────────────────────────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ─── SIDEBAR ───────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width .25s ease;
  overflow: hidden;
}
#sidebar.collapsed { width: 60px; }
#sidebar.collapsed .logo-text,
#sidebar.collapsed span,
#sidebar.collapsed .nav-badge,
#sidebar.collapsed .sidebar-business { display: none; }

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 14px; border-bottom: 1px solid var(--border);
  min-height: 60px;
}
.logo-icon {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif; font-weight: 900; font-size: 17px; color: #fff;
}
.logo-name { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 15px; color: var(--text); white-space: nowrap; }
.logo-tag  { font-size: 9px; color: var(--accent); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 10px 8px; overflow-y: auto; }

.nav-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px 10px; border-radius: var(--radius); border: none;
  background: none; color: var(--muted); cursor: pointer;
  transition: all .15s; margin-bottom: 2px; white-space: nowrap;
  font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 500;
  position: relative;
}
.nav-btn:hover { background: #ffffff08; color: var(--text2); }
.nav-btn.active { background: #6366f120; color: #818cf8; font-weight: 700; }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-badge { margin-left: auto; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px; }
.nav-dot { position: absolute; right: 10px; top: 10px; width: 7px; height: 7px; background: var(--orange); border-radius: 50%; }

.sidebar-business { padding: 12px 14px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sidebar-toggle { background: none; border: none; border-top: 1px solid var(--border); padding: 10px; color: var(--faint); cursor: pointer; font-size: 16px; width: 100%; }

/* ─── MAIN ──────────────────────────────────────── */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

#topbar {
  height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; justify-content: space-between; flex-shrink: 0;
}
#topbar-title { font-size: 13px; color: var(--muted); font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.stock-alert-btn {
  background: #f9731620; border: 1px solid #f9731640; border-radius: 8px;
  padding: 4px 10px; color: var(--orange); font-size: 11px; font-weight: 700; cursor: pointer;
}
.topbar-avatar {
  width: 32px; height: 32px; border-radius: 9px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif; font-weight: 800; font-size: 13px; color: #fff;
}

#content { flex: 1; overflow-y: auto; padding: 24px; }

/* ─── LOADER ─────────────────────────────────────── */
.loader { display: flex; justify-content: center; align-items: center; height: 200px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── TYPOGRAPHY ─────────────────────────────────── */
.page-title { font-family: 'Syne', sans-serif; font-size: 22px; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.page-subtitle { font-size: 13px; color: var(--muted); margin-bottom: 20px; }

/* ─── CARDS ──────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--border2); border-radius: var(--radius-lg); padding: 20px; }
.card-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }

/* ─── STAT CARDS ─────────────────────────────────── */
.stats-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.stat-card { background: var(--card); border: 1px solid var(--border2); border-radius: var(--radius-lg); padding: 18px 20px; flex: 1; min-width: 140px; }
.stat-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.stat-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stat-value { font-family: 'Syne', sans-serif; font-size: 20px; font-weight: 800; color: var(--text); margin-bottom: 2px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-sub   { font-size: 11px; color: var(--faint); margin-top: 2px; }

/* ─── GRID ───────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }

/* ─── TABLE ──────────────────────────────────────── */
.table-wrap { background: var(--card); border: 1px solid var(--border2); border-radius: var(--radius-lg); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 14px; text-align: left; font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border2); }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
tr:last-child td { border-bottom: none; }
.table-empty { text-align: center; padding: 40px; color: var(--faint); }

/* ─── BUTTONS ────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: var(--radius); border: none; font-size: 13px; font-weight: 600; cursor: pointer; font-family: 'DM Sans', sans-serif; white-space: nowrap; transition: opacity .15s; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:hover:not(:disabled) { opacity: .88; }
.btn-icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; }
.btn-success { background: linear-gradient(135deg, #10b981, #059669); color: #fff; }
.btn-danger  { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn-ghost   { background: transparent; color: var(--muted); border: 1px solid var(--border2); }
.btn-orange  { background: linear-gradient(135deg, #f97316, #ea580c); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ─── FORM ───────────────────────────────────────── */
.form-group { margin-bottom: 15px; }
.form-label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.form-label .req { color: var(--orange); }
.form-input, .form-select {
  width: 100%; background: var(--bg); border: 1px solid var(--border2);
  border-radius: 8px; padding: 9px 12px; color: var(--text); font-size: 14px;
  outline: none; font-family: 'DM Sans', sans-serif; transition: border-color .15s;
}
.form-input:focus, .form-select:focus { border-color: var(--accent); }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.form-full   { grid-column: 1 / -1; }

/* ─── BADGE ──────────────────────────────────────── */
.badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 20px; letter-spacing: .04em; text-transform: uppercase; }

/* ─── TOGGLE ─────────────────────────────────────── */
.toggle-wrap { display: flex; align-items: center; gap: 10px; cursor: pointer; margin-bottom: 15px; }
.toggle { width: 42px; height: 24px; border-radius: 12px; background: var(--border2); position: relative; transition: background .2s; cursor: pointer; border: none; flex-shrink: 0; }
.toggle.on { background: var(--accent); }
.toggle::after { content: ''; width: 18px; height: 18px; border-radius: 9px; background: #fff; position: absolute; top: 3px; left: 3px; transition: left .2s; }
.toggle.on::after { left: 21px; }
.toggle-label { font-size: 14px; color: var(--text2); }

/* ─── MODAL ──────────────────────────────────────── */
#modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal-overlay.hidden { display: none; }
#modal-box { background: var(--card); border: 1px solid var(--border2); border-radius: 16px; padding: 26px; width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; }
#modal-box.wide { max-width: 780px; }
#modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
#modal-title { font-family: 'Syne', sans-serif; font-size: 17px; font-weight: 700; color: var(--text); }
#modal-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 18px; padding: 4px 8px; border-radius: 6px; }
#modal-close:hover { background: var(--border); color: var(--text); }

/* ─── TOAST ──────────────────────────────────────── */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--card); border: 1px solid var(--border2); border-radius: 10px;
  padding: 12px 18px; font-size: 13px; font-weight: 600; color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: slideIn .25s ease;
  display: flex; align-items: center; gap: 8px; min-width: 220px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--accent); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ─── PRODUCT GRID (POS) ─────────────────────────── */
.product-card {
  background: var(--card); border: 1px solid var(--border2); border-radius: 12px;
  padding: 12px; cursor: pointer; transition: border-color .15s, transform .1s;
  text-align: left;
}
.product-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.product-card.in-cart { border-color: var(--accent); background: #6366f108; }
.product-card.out-of-stock { opacity: .45; cursor: not-allowed; }
.product-emoji { font-size: 28px; margin-bottom: 6px; display: block; }
.product-name  { font-size: 11px; color: var(--text2); font-weight: 600; margin-bottom: 3px; line-height: 1.3; }
.product-price { font-size: 13px; color: var(--green); font-weight: 800; }
.product-stock { font-size: 10px; margin-top: 3px; }

/* ─── CART ───────────────────────────────────────── */
.cart-panel { background: var(--card); border: 1px solid var(--border2); border-radius: var(--radius-lg); padding: 16px; }
.cart-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.cart-item:last-child { border-bottom: none; }
.qty-btn { width: 24px; height: 24px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border2); color: var(--text2); cursor: pointer; font-size: 15px; display: flex; align-items: center; justify-content: center; }
.qty-btn:hover { border-color: var(--accent); color: var(--accent); }
.payment-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.payment-btn { padding: 8px; border-radius: 8px; border: 1px solid var(--border2); background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; text-transform: capitalize; transition: all .15s; }
.payment-btn.selected { background: #6366f115; border-color: var(--accent); color: #818cf8; }

/* ─── CATEGORY PILLS ─────────────────────────────── */
.cat-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.cat-pill { background: var(--card); border: 1px solid var(--border2); border-radius: 20px; padding: 4px 13px; font-size: 11px; font-weight: 600; color: var(--muted); cursor: pointer; transition: all .15s; }
.cat-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.cat-pill:hover:not(.active) { border-color: var(--muted); color: var(--text2); }

/* ─── SEARCH BAR ─────────────────────────────────── */
.search-wrap { position: relative; }
.search-wrap .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search-wrap input { padding-left: 34px; }

/* ─── RECEIPT ─────────────────────────────────────── */
.receipt-box { max-width: 360px; margin: 0 auto; text-align: center; }
.receipt-icon { font-size: 48px; margin-bottom: 8px; }
.receipt-line { display: flex; justify-content: space-between; margin-bottom: 6px; }

/* ─── POS LAYOUT ─────────────────────────────────── */
.pos-layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }

/* ─── TOP BAR FLEX ───────────────────────────────── */
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.flex-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ─── PROGRESS BAR ───────────────────────────────── */
.progress-bar { height: 6px; background: var(--bg); border-radius: 4px; overflow: hidden; margin-top: 5px; }
.progress-fill { height: 100%; border-radius: 4px; }

/* ─── CUSTOMER CARD ──────────────────────────────── */
.customer-card { background: var(--card); border: 1px solid var(--border2); border-radius: var(--radius-lg); padding: 18px; }
.customer-avatar { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, var(--accent), var(--accent2)); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; color: #fff; flex-shrink: 0; }

/* ─── SETTINGS TABS ──────────────────────────────── */
.settings-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border2); margin-bottom: 24px; }
.settings-tab { background: none; border: none; border-bottom: 2px solid transparent; padding: 8px 14px; color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer; text-transform: capitalize; font-family: 'DM Sans', sans-serif; transition: all .15s; }
.settings-tab.active { color: #818cf8; border-bottom-color: var(--accent); font-weight: 700; }
.settings-tab:hover:not(.active) { color: var(--text2); }

/* ─── REPORT BARS ─────────────────────────────────── */
.report-item { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.report-rank { width: 24px; height: 24px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; flex-shrink: 0; }

/* ─── DANGER ZONE ────────────────────────────────── */
.danger-zone { background: var(--bg); border: 1px solid #f8717133; border-radius: 12px; padding: 16px; margin-top: 20px; }

/* ─── RESPONSIVE ─────────────────────────────────── */
@media (max-width: 900px) {
  .pos-layout   { grid-template-columns: 1fr; }
  .grid-2       { grid-template-columns: 1fr; }
  .form-grid-2  { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  #content { padding: 14px; }
  .stats-row { flex-direction: column; }
}
