/* public/css/style.css */
:root {
  --bg: #0b0f17;
  --surface: #131a26;
  --surface-2: #1b2435;
  --border: #253147;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --accent-soft: rgba(245, 158, 11, 0.14);
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.14);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --info: #38bdf8;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #d97706;
  --accent-hover: #b45309;
  --accent-soft: rgba(217, 119, 6, 0.12);
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.mono { font-family: 'JetBrains Mono', monospace; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.text-xs { font-size: 0.78rem; }
.text-sm { font-size: 0.875rem; }
.text-center { text-align: center; }
.mt-6 { margin-top: 6px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.max-w-720 { max-width: 720px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ===== FORM & BUTTONS ===== */
input, select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font: inherit;
  font-size: 0.94rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input-sm { padding: 8px 11px; font-size: 0.86rem; width: auto; min-width: 120px; }
.input-lg { padding: 14px 16px; font-size: 1.25rem; font-weight: 700; }

label { display: block; font-size: 0.83rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.checkbox-inline { display: inline-flex; align-items: center; gap: 8px; color: var(--text); cursor: pointer; margin: 0; font-size: 0.88rem; }
.checkbox-inline input { width: 17px; height: 17px; accent-color: var(--accent); }

.password-wrap { position: relative; display: flex; align-items: center; }
.password-wrap input { padding-right: 44px; }
.pw-eye-btn {
  position: absolute; right: 6px;
  background: transparent; border: none; color: var(--muted);
  width: 34px; height: 34px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.pw-eye-btn:hover { color: var(--text); background: var(--surface); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 16px; font: inherit; font-weight: 600; font-size: 0.9rem;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #0b0f17; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-success { background: var(--success); color: #04130d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-ghost { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { border-color: var(--accent); }
.btn-ghost.active-toggle { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn-lg { padding: 13px 18px; font-size: 0.98rem; }
.btn-sm { padding: 7px 12px; font-size: 0.83rem; }
.btn-xs { padding: 5px 9px; font-size: 0.77rem; }
.btn-full { width: 100%; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}

.alert-error {
  background: var(--danger-soft); color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 0.86rem; font-weight: 500;
}
.info-box {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; font-size: 0.88rem; color: var(--muted);
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(circle at top right, rgba(245, 158, 11, 0.12), transparent 45%), var(--bg);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 32px 26px; box-shadow: var(--shadow);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.brand-logo-box {
  width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 16px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.brand-logo-box img { width: 100%; height: 100%; object-fit: cover; }
.login-brand h1 { font-size: 1.4rem; font-weight: 800; }

/* ===== APP SHELL & SIDEBAR ===== */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 256px; flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 40;
}
.sidebar-header {
  padding: 18px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; }
.brand-logo-sm {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  background: var(--accent); color: #0b0f17; font-weight: 800; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.brand-logo-sm img { width: 100%; height: 100%; object-fit: cover; }
.brand-title { font-weight: 800; font-size: 0.96rem; line-height: 1.2; }
.shift-pill {
  display: inline-block; font-size: 0.7rem; font-weight: 700;
  padding: 2px 7px; border-radius: 99px; margin-top: 3px;
}
.shift-pill.open { background: var(--success-soft); color: var(--success); }
.shift-pill.closed { background: var(--danger-soft); color: var(--danger); }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.nav-divider {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); font-weight: 700; padding: 14px 12px 6px;
}
.nav-item {
  width: 100%; border: none; background: transparent; color: var(--muted);
  display: flex; align-items: center; gap: 11px; padding: 11px 12px;
  border-radius: var(--radius-sm); font: inherit; font-weight: 600; font-size: 0.9rem;
  cursor: pointer; text-align: left; transition: all 0.15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.user-profile-box { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--border); display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--accent);
}
.user-name { font-weight: 700; font-size: 0.88rem; line-height: 1.2; }
.user-role { font-size: 0.74rem; color: var(--muted); text-transform: uppercase; }
.sidebar-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 20px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 25;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-title { font-size: 1.08rem; font-weight: 800; }

.content-area { flex: 1; padding: 18px 20px; }
.view-section { display: none; }
.view-section.active { display: block; }
.mobile-only { display: none; }
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 35; }

/* ===== POS LAYOUT ===== */
.pos-layout { display: grid; grid-template-columns: 1fr 370px; gap: 18px; align-items: start; }
.shift-banner {
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 0.86rem;
}
.pos-toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.search-box {
  flex: 1; min-width: 180px; position: relative; display: flex; align-items: center;
}
.search-box svg { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search-box input { padding-left: 38px; }

.category-tabs {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 8px;
  scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar { display: none; }
.cat-pill {
  padding: 8px 15px; border-radius: 99px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font-weight: 600; font-size: 0.85rem;
  cursor: pointer; white-space: nowrap; transition: all 0.15s;
}
.cat-pill.active { background: var(--accent); color: #0b0f17; border-color: var(--accent); }

.product-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 12px;
}
.product-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 8px;
  transition: transform 0.12s, border-color 0.15s; position: relative;
}
.product-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.product-card.unavailable { opacity: 0.52; }
.product-thumb {
  height: 92px; border-radius: 10px; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  color: var(--muted); font-weight: 800; font-size: 1.35rem;
}
.product-thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-name { font-weight: 700; font-size: 0.9rem; line-height: 1.3; }
.product-price { font-weight: 800; color: var(--accent); font-size: 0.95rem; }
.product-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; }
.badge-soft {
  display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 0.72rem; font-weight: 700;
  background: var(--surface-2); color: var(--muted);
}
.badge-warn { background: var(--accent-soft); color: var(--accent); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-pill {
  background: var(--accent); color: #0b0f17; font-size: 0.72rem; font-weight: 800;
  padding: 1px 6px; border-radius: 99px;
}

/* Cart Panel */
.cart-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  position: sticky; top: 78px; max-height: calc(100vh - 96px);
  display: flex; flex-direction: column; overflow: hidden;
}
.cart-header {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.cart-header-title { display: flex; align-items: center; gap: 8px; }
.cart-header-actions { display: flex; align-items: center; gap: 6px; }
.cart-items { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; min-height: 160px; }
.cart-item {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px; display: flex; flex-direction: column; gap: 6px;
}
.cart-item-top { display: flex; justify-content: space-between; gap: 8px; }
.cart-item-name { font-weight: 700; font-size: 0.88rem; }
.cart-item-meta { font-size: 0.76rem; color: var(--muted); }
.cart-item-bottom { display: flex; align-items: center; justify-content: space-between; }
.qty-inline { display: inline-flex; align-items: center; gap: 6px; }
.qty-btn {
  width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 700; cursor: pointer;
}
.cart-footer { padding: 12px 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.cart-meta-inputs { display: flex; flex-direction: column; gap: 8px; }
.cart-meta-inputs .input-sm { width: 100%; }
.discount-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cart-totals { display: flex; flex-direction: column; gap: 5px; font-size: 0.88rem; }
.total-row { display: flex; justify-content: space-between; }
.grand-total { font-size: 1.12rem; font-weight: 800; padding-top: 6px; border-top: 1px dashed var(--border); color: var(--accent); }
.cart-cta-grid { display: grid; grid-template-columns: 110px 1fr; gap: 8px; }

.mobile-cart-bar {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 30;
  background: var(--surface); border: 1px solid var(--accent);
  border-radius: 14px; padding: 10px 14px; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: space-between;
}
.mcb-info { display: flex; flex-direction: column; }
.mcb-badge { font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.mcb-total { font-size: 1.05rem; font-weight: 800; color: var(--accent); }

/* ===== CARDS, TABLES & DASHBOARD ===== */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.card-header {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-body { padding: 18px; }
.wrap-gap { flex-wrap: wrap; gap: 10px; }
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grid-2-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-dashboard { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
.stack-col { display: flex; flex-direction: column; gap: 16px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(195px, 1fr)); gap: 12px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 4px;
}
.kpi-label { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 1.3rem; font-weight: 800; }
.kpi-sub { font-size: 0.76rem; color: var(--muted); }
.kpi-card.accent .kpi-value { color: var(--accent); }
.kpi-card.success .kpi-value { color: var(--success); }

.chart-wrap { position: relative; height: 300px; }
.list-stack { display: flex; flex-direction: column; gap: 10px; }
.rank-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; background: var(--surface-2); border-radius: 10px;
}

.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
.data-table th, .data-table td {
  padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table th { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--surface-2); }
.data-table tr:last-child td { border-bottom: none; }
.actions-cell { display: flex; gap: 6px; }

.subtab-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.subtab-btn {
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font: inherit; font-weight: 700; cursor: pointer;
}
.subtab-btn.active { background: var(--accent); color: #0b0f17; border-color: var(--accent); }

.empty-state-sm { text-align: center; color: var(--muted); padding: 28px 14px; font-size: 0.88rem; }

/* ===== MODALS ===== */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-dialog {
  width: 100%; max-width: 560px; max-height: 92vh;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-sm { max-width: 420px; }
.modal-header {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-body { padding: 18px; overflow-y: auto; }
.modal-footer {
  padding: 12px 18px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
}

.variant-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.var-chip {
  padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 0.86rem;
  font-weight: 600; cursor: pointer;
}
.var-chip.selected { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.qty-stepper { display: grid; grid-template-columns: 48px 1fr 48px; gap: 8px; }
.qty-stepper input { text-align: center; font-weight: 700; }

.checkout-total-banner {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; display: flex; justify-content: space-between; align-items: center;
}
.checkout-total-banner strong { font-size: 1.45rem; color: var(--accent); }
.pay-method-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-tab {
  padding: 11px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--muted); font: inherit; font-weight: 700; cursor: pointer;
}
.pay-tab.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.quick-money-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.change-box {
  background: var(--success-soft); color: var(--success); border-radius: 10px;
  padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; font-weight: 700;
}
.change-box strong { font-size: 1.2rem; }

.qris-preview-img { max-width: 220px; width: 100%; border-radius: 12px; border: 1px solid var(--border); background: #fff; padding: 6px; }
.qris-full-img { width: 100%; max-width: 320px; margin: 0 auto; border-radius: 14px; background: #fff; padding: 10px; }
.qris-full-amount { background: var(--accent-soft); color: var(--accent); padding: 10px; border-radius: 10px; display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.qris-full-amount strong { font-size: 1.25rem; }

.upload-preview { margin-top: 8px; }
.upload-preview img { max-height: 120px; border-radius: 10px; border: 1px solid var(--border); background: #fff; padding: 4px; }
.variant-edit-row { display: grid; grid-template-columns: 1fr 110px 36px; gap: 6px; align-items: center; }

/* Receipt Paper Preview */
.receipt-paper {
  background: #ffffff; color: #111827; padding: 18px 14px; border-radius: 8px;
  font-family: 'JetBrains Mono', monospace; font-size: 12px; line-height: 1.45;
}
.rc-center { text-align: center; }
.rc-title { font-size: 14px; font-weight: 700; }
.rc-hr { border-top: 1px dashed #9ca3af; margin: 8px 0; }
.rc-row { display: flex; justify-content: space-between; gap: 8px; }
.rc-bold { font-weight: 700; }

/* Toast */
.toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 90;
  display: flex; flex-direction: column; gap: 8px; max-width: 340px;
}
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  color: var(--text); padding: 12px 14px; border-radius: 10px; box-shadow: var(--shadow);
  font-size: 0.87rem; font-weight: 600; animation: slideIn 0.2s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== RESPONSIVE (MOBILE & TABLET) ===== */
@media (max-width: 960px) {
  .mobile-only { display: inline-flex; }
  .sidebar {
    position: fixed; left: -270px; top: 0; bottom: 0; transition: left 0.22s ease;
  }
  .sidebar.open { left: 0; }
  .pos-layout { grid-template-columns: 1fr; padding-bottom: 72px; }
  .cart-panel {
    position: fixed; left: 0; right: 0; bottom: 0; top: 12vh; max-height: 88vh;
    z-index: 50; border-radius: 20px 20px 0 0;
    transform: translateY(105%); transition: transform 0.24s ease;
  }
  .cart-panel.drawer-open { transform: translateY(0); }
  .grid-2-col, .grid-dashboard { grid-template-columns: 1fr; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .content-area { padding: 14px; }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

/* ===== THERMAL PRINT 58mm ===== */
.thermal-print-area { display: none; }
@media print {
  body * { visibility: hidden !important; }
  #thermal-print-area, #thermal-print-area * { visibility: visible !important; }
  #thermal-print-area {
    display: block !important;
    position: fixed; left: 0; top: 0; width: 58mm;
    background: #fff; color: #000;
    font-family: 'JetBrains Mono', monospace; font-size: 11px; line-height: 1.35;
    padding: 2mm;
  }
  @page { margin: 0; size: 58mm auto; }
}