:root {
  --header-bg: rgba(8,10,26,0.88);
  --bg: #080A1A;
  --bg-2: #0D1128;
  --bg-3: #141830;
  --surface: #111428;
  --surface-2: #1C2040;
  --border: #252A50;
  --border-2: #333A66;
  --text: #E8EAFF;
  --text-2: #A0A8D8;
  --text-3: #5C6490;
  --accent: #5C6BC0;
  --accent-dim: #5C6BC033;
  --accent-bg: #1A237E33;
  --nav-h: 0px;
  --safe-bottom: env(safe-area-inset-bottom, 20px);
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: #080A1A;
  color: var(--text);
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
body.light-theme { background-color: #ECEEF5; }

.app-container {
  max-width: 390px;
  margin: 0 auto;
  position: relative;
  min-height: 100vh;
  background: var(--bg);
  box-shadow: 0 0 40px rgba(92,107,192,0.15);
  border-left: 1px solid var(--surface-2);
  border-right: 1px solid var(--surface-2);
  display: flex;
  flex-direction: column;
}
img { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }
.serif { font-family: 'Instrument Serif', serif; }

/* ─── Pages ─── */
.page { display: none; flex-direction: column; min-height: 100vh; }
.page.active { display: flex; }

/* ─── Header ─── */
.app-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid var(--border);
  min-height: 46px;
}
.header-logo { font-family: 'Instrument Serif', serif; font-size: 19px; color: var(--text); letter-spacing: -0.5px; }
.header-logo span { color: var(--accent); }
.header-actions { display: flex; gap: 4px; }
.header-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  transition: all 0.2s;
}
.header-btn:hover { background: var(--surface-2); color: var(--text); }

/* ─── Category Tabs ─── */
.category-bar {
  display: flex;
  gap: 6px;
  padding: 8px 12px 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: sticky;
  top: 46px;
  z-index: 97;
  background: var(--surface);
}
.cat-tab {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all 0.2s;
  white-space: nowrap;
}
.cat-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
  font-weight: 600;
}
.cat-tab:active { transform: scale(0.94); }

/* ─── Grid Catalog ─── */
.produk-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px 12px calc(var(--safe-bottom) + 32px);
  align-items: flex-start;
  background: var(--surface);
}
.produk-card {
  position: relative;
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.produk-card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--surface-2);
  overflow: hidden;
}
.produk-card-img-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.produk-card:hover .produk-card-img-wrap img { transform: scale(1.05); }
.produk-card:active .produk-card-img-wrap img { transform: scale(1.02); }

.produk-card-info {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.produk-card-name {
  font-size: 12px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: none;
}
.produk-card-price {
  font-size: 13px;
  color: var(--text);
  font-weight: 700;
  text-shadow: none;
}
.produk-card-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-top: 2px;
}
.produk-card-rating {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-3);
}
.produk-card-rating svg { width: 12px; height: 12px; fill: #F5A623; }
.produk-card-sold {
  font-size: 10px;
  color: var(--text-3);
  margin-left: auto;
}



.produk-card-badge {
  position: absolute;
  top: 6px; right: 6px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 9px;
  font-weight: 600;
  color: #fff;
  z-index: 2;
}

.produk-card.sold-out { opacity: 0.6; }
.produk-card.sold-out .produk-card-badge { background: #f28b82; color: #fff; }

/* ─── Editorial Picks ─── */
.editorial-section {
  padding: 16px 0 14px;
  background: var(--surface);
  margin-bottom: 6px;
}
.editorial-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 12px;
}
.editorial-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.editorial-subtitle {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 400;
}
.editorial-track {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0 8px 8px;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 8px;
  align-items: flex-start;
}
.editorial-track::after {
  content: '';
  flex: 0 0 0px;
}
.editorial-track::-webkit-scrollbar { display: none; }
.editorial-card {
  flex: 0 0 130px;
  scroll-snap-align: start;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.editorial-card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--surface-2);
  overflow: hidden;
}
.editorial-card-img-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.editorial-card:active .editorial-card-img-wrap img { transform: scale(1.04); }
.editorial-card-info {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.editorial-card-name {
  font-size: 12px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: none;
}
.editorial-card-price {
  font-size: 13px;
  color: var(--text);
  font-weight: 700;
  text-shadow: none;
}
.editorial-card-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-top: 2px;
}
.editorial-card-sold {
  font-size: 10px;
  color: var(--text-3);
  margin-left: auto;
}

/* ─── Skeleton Loading ─── */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card {
  aspect-ratio: 1;
  border-radius: 0;
}

/* ─── Modal ─── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  z-index: 300;
  display: none;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
}
.modal-backdrop.open {
  display: flex;
  opacity: 1;
}
.modal-sheet {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  overflow: hidden;
  position: relative;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 90dvh;
  overflow-y: auto;
  scrollbar-width: none;
}
.modal-sheet::-webkit-scrollbar { display: none; }
.modal-backdrop.open .modal-sheet { transform: translateY(0); }
.modal-drag-handle {
  position: absolute;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  width: 32px; height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.6);
  z-index: 10;
}
.modal-img { 
  width: 100%; 
  aspect-ratio: 1 / 1; 
  object-fit: cover; 
  background: var(--surface-2);
}
.modal-body { padding: 14px 16px 24px; }

/* ─── Variasi Chips ─── */
.chip-variasi {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.chip-variasi:hover {
  background: var(--surface-2);
}
.chip-variasi.selected {
  background: rgba(10, 132, 255, 0.08);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.chip-variasi.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--surface-2);
  text-decoration: line-through;
  color: var(--text-3);
}

.modal-name {
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  margin-bottom: 2px;
  font-weight: 500;
}
.modal-price {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}
.modal-desc {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 0;
}
.modal-kategori {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--bg);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 0;
}

/* ─── Buttons ─── */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
  width: 100%;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; pointer-events: none; }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-wa {
  background: #FFFFFF;
  color: #000000;
}
.btn-wa:hover { background: #EAEAEA; transform: scale(0.98); }

/* ─── Checkout Page ─── */
.checkout-wrap {
  padding: 14px 14px;
  flex: 1;
  padding-bottom: calc(var(--safe-bottom) + 30px);
}
.co-product {
  display: flex; gap: 12px; align-items: center;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.co-img { width: 52px; height: 52px; border-radius: var(--radius-md); object-fit: cover; }
.co-title { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.co-price { font-size: 13px; color: var(--accent); }

.checkout-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}
.form-group { margin-bottom: 12px; }
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
}
.form-input {
  width: 100%;
  padding: 10px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-3); }

.map-pick-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 10px 13px;
  background: var(--surface);
  border: 1px dashed var(--border-2);
  border-radius: var(--radius-md);
  color: var(--text-2);
  font-size: 13px;
  transition: all 0.2s;
}
.map-pick-btn:active { background: var(--surface-2); }
.map-pick-btn svg { color: var(--accent); flex-shrink: 0; }

.co-summary {
  margin: 16px 0;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 12px;
}
.co-row { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 13px; color: var(--text-2); }
.co-row:last-child { margin-bottom: 0; padding-top: 8px; border-top: 1px dashed var(--border-2); font-size: 14px; font-weight: 700; color: var(--text); }
.co-row.error { color: #E8706A; justify-content: center; text-align: center; font-size: 12px; }

/* ─── Map Modal ─── */
#map-container { width: 100%; height: 300px; border-radius: var(--radius-md); overflow: hidden; }
.leaflet-container { background: var(--bg-3) !important; }

/* ─── Empty State ─── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 60px 20px;
  gap: 12px;
  color: var(--text-3);
}
.empty-state svg { opacity: 0.3; }
.empty-state p { font-size: 14px; text-align: center; }

/* ─── Spinner ─── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Toast ─── */
.toast {
  position: fixed;
  top: 70px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: 14px;
  color: var(--text);
  z-index: 999;
  max-width: 90%;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── Responsive ─── */
@media (min-width: 390px) {
  .app-header { width: 100%; max-width: 390px; }
  .modal-backdrop { left: 50%; right: auto; transform: translateX(-50%); width: 100%; max-width: 390px; }
}

/* ─── LIGHT MODE (AUTO) ─── */
/* ─── LIGHT MODE CLASS (TOGGLEABLE) ─── */
body.light-theme {
  --header-bg: rgba(255,255,255,0.92);
  --bg: #F5F6FA;
  --bg-2: #ECEEF5;
  --bg-3: #E2E5F0;
  --surface: #FFFFFF;
  --surface-2: #EEF0F8;
  --border: #DDE0EC;
  --border-2: #C8CCE0;
  --text: #0F1535;
  --text-2: #3D4466;
  --text-3: #8A90B0;
  --accent: #1A237E;
  --accent-dim: rgba(26, 35, 126, 0.13);
  --accent-bg: #E8EAF6;
}
body.light-theme .app-container { box-shadow: 0 0 40px rgba(26,35,126,0.08); }
body.light-theme .modal-backdrop, body.light-theme .drawer-backdrop { background: rgba(255, 255, 255, 0.8); }

/* Theme Toggle Button */
.btn-icon {
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}
.btn-icon:hover { background: var(--surface-2); }

/* ─── HERO SLIDER ─── */
.hero-slider {
  position: relative;
  width: 100%;
  margin-bottom: 6px;
  overflow: hidden;
  background: var(--surface);
}
.hero-slides {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.hero-slides::-webkit-scrollbar {
  display: none;
}
.hero-slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
  position: relative;
  padding: 0;
}
.hero-slide img {
  width: 100%;
  border-radius: 0;
  aspect-ratio: 2/1;
  object-fit: cover;
  display: block;
}
.hero-dots {
  position: absolute;
  bottom: 12px;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 6px;
  z-index: 10;
}
.hero-dot {
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.4);
  transition: all 0.3s ease;
}
.hero-dot.active {
  width: 16px;
  background: #fff;
}
