/* ===== QalbiiPos CSS ===== */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f0ebe0;
  --bg2: #e8e2d5;
  --card-bg: #f5f2eb;
  --card-border: rgba(255,255,255,0.8);
  --text: #1a1a1a;
  --text-muted: #6b6560;
  --green: #3d7a5a;
  --green-bg: #e8f5ee;
  --green-icon: #2d6b4a;
  --purple: #6c5ce7;
  --purple-bg: #ede9ff;
  --teal: #00897b;
  --teal-bg: #e0f5f3;
  --orange: #e67e22;
  --orange-bg: #fff3e0;
  --nav-h: 68px;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.06);
  --accent: #3d7a5a;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

#app { height: 100vh; height: 100dvh; overflow: hidden; position: relative; }

/* ===== SPLASH ===== */
#splash {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
#splash.fade-out { opacity: 0; transform: scale(1.05); pointer-events: none; }
.splash-logo { text-align: center; }
.splash-icon { font-size: 64px; margin-bottom: 12px; animation: bounce 1s ease infinite alternate; }
.splash-logo h1 { font-size: 28px; font-weight: 800; color: var(--green); }
.splash-logo p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
@keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-8px); } }

/* ===== MAIN APP ===== */
#main-app {
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
#main-app.hidden { display: none; }

/* ===== PAGE ===== */
.page { display: none; flex: 1; overflow: hidden; }
.page.active { display: flex; flex-direction: column; }
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px calc(var(--nav-h) + 16px) 16px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.page-content::-webkit-scrollbar { display: none; }

/* ===== HEADER ===== */
.app-header {
  padding: 20px 0 8px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-menu {
  background: none; border: none; font-size: 20px;
  cursor: pointer; padding: 4px;
  color: var(--text);
}
.app-header h2 {
  font-size: 22px; font-weight: 800;
  color: var(--text); line-height: 1.2;
}
.app-header p { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.header-info { flex: 1; }

/* ===== PERIOD BAR ===== */
.period-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0;
  gap: 8px;
}
.period-tabs {
  display: flex;
  background: rgba(255,255,255,0.5);
  border-radius: 50px;
  padding: 3px;
  gap: 2px;
  flex: 1;
  border: 1.5px solid rgba(255,255,255,0.8);
}
.tab {
  flex: 1;
  padding: 7px 10px;
  border: none;
  background: none;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  transition: all 0.2s;
}
.tab.active {
  background: var(--green);
  color: white;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(61,122,90,0.3);
}
.kasir-pill {
  background: rgba(255,255,255,0.6);
  border: 1.5px solid rgba(255,255,255,0.9);
  border-radius: 50px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  font-family: inherit;
  color: var(--text);
  white-space: nowrap;
  backdrop-filter: blur(10px);
  transition: all 0.2s;
}
.kasir-pill:active { transform: scale(0.97); }

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  border-radius: var(--radius);
  padding: 16px;
  border: 1.5px solid rgba(255,255,255,0.7);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-card);
  transition: transform 0.15s;
}
.stat-card:active { transform: scale(0.98); }
.stat-card.green { background: linear-gradient(135deg, #e8f5ee 0%, #d4eddf 100%); }
.stat-card.purple { background: linear-gradient(135deg, #ede9ff 0%, #ddd5ff 100%); }
.stat-card.teal { background: linear-gradient(135deg, #e0f5f3 0%, #cceee9 100%); }
.stat-card.orange { background: linear-gradient(135deg, #fff3e0 0%, #ffe8c0 100%); }

.stat-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.stat-icon {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
}
.green-icon { background: var(--green); color: white; }
.purple-icon { background: var(--purple); color: white; font-size: 16px; }
.teal-icon { background: var(--teal); color: white; font-size: 16px; }
.orange-icon { background: var(--orange); color: white; font-size: 16px; }

.stat-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 50px;
}
.stat-badge.up { background: rgba(61,122,90,0.15); color: var(--green); }
.purple-badge.up { background: rgba(108,92,231,0.15); color: var(--purple); }
.orange-badge.up { background: rgba(230,126,34,0.15); color: var(--orange); }

.stat-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.stat-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}

/* ===== CARDS ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  border: 1.5px solid rgba(255,255,255,0.8);
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}
.card h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

/* ===== CHART ===== */
.chart-card { }
.chart-wrap { position: relative; height: 160px; }

/* ===== BOTTOM ROW ===== */
.bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 8px;
}
.bestseller-card, .produksi-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px;
  border: 1.5px solid rgba(255,255,255,0.8);
  box-shadow: var(--shadow-card);
}
.bestseller-card h3, .produksi-card h3 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}
.bestseller-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.bestseller-item:last-child { border-bottom: none; }
.bestseller-emoji { font-size: 28px; }
.bestseller-rank { font-size: 10px; color: var(--text-muted); }
.bestseller-name { font-size: 12px; font-weight: 600; }

.produksi-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.produksi-item:last-child { border-bottom: none; }
.produksi-emoji { font-size: 22px; }
.produksi-info { flex: 1; }
.produksi-name { font-size: 11px; font-weight: 600; }
.produksi-harga { font-size: 10px; color: var(--green); font-weight: 600; }

.empty-state { color: var(--text-muted); font-size: 12px; text-align: center; padding: 12px 0; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(245,242,235,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
}
.nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 8px 4px;
  background: none; border: none; cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.nav-icon { font-size: 20px; transition: transform 0.2s; }
.nav-icon-dashboard {
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  background: var(--green);
  border-radius: 14px;
  color: white;
  box-shadow: 0 4px 12px rgba(61,122,90,0.35);
  transform: translateY(-4px);
  font-size: 18px;
}
.nav-label { font-size: 10px; font-weight: 500; color: var(--text-muted); }
.nav-item.active .nav-label { color: var(--green); font-weight: 700; }
.nav-item.active .nav-icon:not(.nav-icon-dashboard) { transform: scale(1.15); }

/* ===== KASIR ===== */
.search-bar { margin: 12px 0; }
.search-bar input {
  width: 100%; padding: 12px 16px;
  border-radius: 14px;
  border: 1.5px solid rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.7);
  font-size: 14px; font-family: inherit;
  outline: none;
}
.produk-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding-bottom: 200px;
}
.produk-card-kasir {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 14px;
  border: 1.5px solid rgba(255,255,255,0.8);
  box-shadow: var(--shadow-card);
  cursor: pointer; transition: transform 0.15s;
  text-align: center;
}
.produk-card-kasir:active { transform: scale(0.96); }
.produk-emoji { font-size: 36px; margin-bottom: 6px; }
.produk-nama { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.produk-harga { font-size: 13px; font-weight: 700; color: var(--green); }
.produk-stok { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.stok-habis { opacity: 0.4; cursor: not-allowed; }

/* ===== CART ===== */
.cart-panel {
  position: fixed;
  bottom: var(--nav-h); left: 0; right: 0;
  background: white;
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.12);
  z-index: 50;
  max-height: 50vh;
  display: flex; flex-direction: column;
  transition: transform 0.3s ease;
}
.cart-panel.empty { transform: translateY(calc(100% - 56px)); }
.cart-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  font-weight: 600; font-size: 14px;
  cursor: pointer;
}
.cart-count {
  background: var(--green);
  color: white;
  border-radius: 50px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
}
.cart-items { flex: 1; overflow-y: auto; padding: 8px 16px; }
.cart-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  font-size: 13px;
}
.cart-item-name { flex: 1; font-weight: 500; }
.cart-item-qty {
  display: flex; align-items: center; gap: 8px;
  margin: 0 8px;
}
.qty-btn {
  width: 24px; height: 24px;
  border-radius: 50%; border: 1.5px solid var(--green);
  background: none; cursor: pointer; font-size: 14px; font-weight: 700;
  color: var(--green); display: flex; align-items: center; justify-content: center;
}
.cart-item-harga { font-weight: 600; color: var(--green); }
.cart-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(0,0,0,0.06);
  display: flex; align-items: center; gap: 12px;
}
.cart-total { flex: 1; }
.cart-total span { font-size: 12px; color: var(--text-muted); }
.cart-total strong { display: block; font-size: 18px; font-weight: 800; color: var(--text); }
.btn-bayar {
  background: var(--green);
  color: white;
  border: none; border-radius: 14px;
  padding: 12px 24px;
  font-size: 14px; font-weight: 700; font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(61,122,90,0.3);
}

/* ===== PRODUK MANAGE ===== */
.btn-primary {
  width: 100%; padding: 14px;
  background: var(--green); color: white;
  border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 700; font-family: inherit;
  cursor: pointer; margin: 12px 0;
}
.produk-manage-list { padding-bottom: 80px; }
.produk-manage-item {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  border: 1.5px solid rgba(255,255,255,0.8);
  display: flex; align-items: center; gap: 12px;
}
.produk-manage-emoji { font-size: 32px; }
.produk-manage-info { flex: 1; }
.produk-manage-nama { font-size: 14px; font-weight: 600; }
.produk-manage-detail { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.produk-manage-price { font-size: 14px; font-weight: 700; color: var(--green); }
.produk-manage-actions { display: flex; gap: 6px; }
.btn-edit, .btn-del {
  border: none; border-radius: 8px;
  padding: 6px 10px; font-size: 12px;
  cursor: pointer; font-family: inherit;
}
.btn-edit { background: var(--purple-bg); color: var(--purple); }
.btn-del { background: #ffe0e0; color: #c0392b; }

/* ===== TRANSAKSI ===== */
.transaksi-list { padding-bottom: 80px; }
.transaksi-item {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  border: 1.5px solid rgba(255,255,255,0.8);
}
.transaksi-header { display: flex; justify-content: space-between; margin-bottom: 6px; }
.transaksi-id { font-size: 11px; color: var(--text-muted); }
.transaksi-time { font-size: 11px; color: var(--text-muted); }
.transaksi-items { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.transaksi-total { font-size: 16px; font-weight: 700; color: var(--green); }

/* ===== LAPORAN ===== */
.laporan-grid { padding-bottom: 80px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--card-bg);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; max-width: 500px;
  max-height: 85vh;
  display: flex; flex-direction: column;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-header button {
  background: rgba(0,0,0,0.08); border: none;
  width: 28px; height: 28px; border-radius: 50%;
  cursor: pointer; font-size: 14px;
}
.modal-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.modal-body label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin: 12px 0 4px; }
.modal-body input {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid rgba(0,0,0,0.1);
  border-radius: 10px;
  font-size: 14px; font-family: inherit;
  background: white; outline: none;
}
.modal-body input:focus { border-color: var(--green); }
.modal-footer {
  display: flex; gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid rgba(0,0,0,0.08);
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.btn-cancel, .btn-save {
  flex: 1; padding: 13px;
  border: none; border-radius: 12px;
  font-size: 14px; font-weight: 700; font-family: inherit;
  cursor: pointer;
}
.btn-cancel { background: rgba(0,0,0,0.07); color: var(--text); }
.btn-save { background: var(--green); color: white; box-shadow: 0 4px 12px rgba(61,122,90,0.25); }

/* Modal Bayar */
.total-display {
  background: var(--green);
  color: white;
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
  display: flex; justify-content: space-between; align-items: center;
}
.total-display span { font-size: 13px; opacity: 0.9; }
.total-display strong { font-size: 24px; font-weight: 800; }
.kembalian-display {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px;
  background: rgba(61,122,90,0.1);
  border-radius: 10px;
  margin-top: 10px;
}
.kembalian-display span { font-size: 13px; color: var(--text-muted); }
.kembalian-display strong { font-size: 18px; font-weight: 700; color: var(--green); }
.quick-cash {
  display: flex; gap: 8px; margin-top: 12px;
}
.quick-cash button {
  flex: 1; padding: 8px 6px;
  background: rgba(0,0,0,0.06);
  border: none; border-radius: 8px;
  font-size: 12px; font-weight: 600; font-family: inherit;
  cursor: pointer;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  left: 50%; transform: translateX(-50%);
  background: #1a1a1a;
  color: white;
  padding: 10px 20px;
  border-radius: 50px;
  font-size: 13px; font-weight: 500;
  z-index: 500;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  transition: opacity 0.3s, transform 0.3s;
}
.toast.hidden { opacity: 0; transform: translateX(-50%) translateY(8px); pointer-events: none; }
.toast.success { background: var(--green); }
.toast.error { background: #c0392b; }

/* ===== SIDEBAR ===== */
.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 300;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.hidden { display: none; }
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 260px;
  background: var(--card-bg);
  z-index: 301;
  box-shadow: 4px 0 30px rgba(0,0,0,0.12);
  display: flex; flex-direction: column;
  transform: translateX(0);
  transition: transform 0.3s ease;
}
.sidebar.hidden { transform: translateX(-100%); }
.sidebar-header {
  display: flex; align-items: center; gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.sidebar-logo { font-size: 36px; }
.sidebar-header strong { font-size: 16px; font-weight: 700; }
.sidebar-header p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.sidebar-menu { flex: 1; padding: 12px 12px; }
.sidebar-menu button {
  width: 100%; text-align: left;
  padding: 13px 14px;
  border: none; background: none;
  font-size: 14px; font-weight: 500; font-family: inherit;
  cursor: pointer; border-radius: 10px; color: var(--text);
  display: flex; gap: 10px;
  transition: background 0.15s;
}
.sidebar-menu button:hover { background: rgba(0,0,0,0.05); }
.sidebar-footer { padding: 16px 12px; border-top: 1px solid rgba(0,0,0,0.08); }
.sidebar-footer button {
  width: 100%; text-align: left;
  padding: 12px 14px;
  border: none; background: none;
  font-size: 14px; font-family: inherit;
  cursor: pointer; border-radius: 10px; color: var(--text-muted);
}

/* ===== HIDDEN ===== */
.hidden { display: none !important; }

/* ===== OFFLINE BANNER ===== */
#offline-banner {
  position: fixed; top: 0; left: 0; right: 0;
  background: #e74c3c; color: white;
  text-align: center; font-size: 12px; font-weight: 600;
  padding: 6px;
  z-index: 9998;
  transform: translateY(-100%);
  transition: transform 0.3s;
}
#offline-banner.show { transform: translateY(0); }

/* ===== PWA INSTALL PROMPT ===== */
#install-prompt {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  left: 16px; right: 16px;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1.5px solid rgba(255,255,255,0.9);
  z-index: 400;
  display: flex; align-items: center; gap: 12px;
}
#install-prompt.hidden { display: none; }
#install-prompt .install-info { flex: 1; }
#install-prompt h4 { font-size: 13px; font-weight: 700; }
#install-prompt p { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.btn-install { background: var(--green); color: white; border: none; border-radius: 10px; padding: 8px 14px; font-size: 12px; font-weight: 700; cursor: pointer; }
.btn-install-dismiss { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); }
