/* ═══════════════════════════════════════════════
   QuMart v3 — Shopee-Style Design System
   ═══════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Design Tokens ── */
:root {
  --primary: #EE4D2D;
  --primary-dark: #D23F1F;
  --primary-light: #FFF0EC;
  --green: #26AA99;
  --gold: #FFD700;
  --red: #FF424E;

  --bg: #F5F5F5;
  --white: #FFFFFF;
  --text: #222222;
  --text-secondary: #757575;
  --text-light: #999999;
  --border: #E8E8E8;
  --divider: #F0F0F0;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.10);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);

  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --header-h: 56px;
  --bottom-nav-h: 56px;

  --font: 'Inter', -apple-system, sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding-top: var(--header-h);
  padding-bottom: calc(var(--bottom-nav-h) + 16px);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; outline: none; font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; outline: none; }

/* ── Animations ── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideDown { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes shimmer { 0% { background-position: -200px 0; } 100% { background-position: calc(200px + 100%) 0; } }
@keyframes toastIn { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes badgePop { 0% { transform: scale(0); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }

/* ── Skeleton Loading ── */
.skeleton {
  background: linear-gradient(90deg, #eee 0%, #f5f5f5 40%, #eee 80%);
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

/* ═══════════════════════════════════════════════
   HEADER BAR (Shopee Orange)
   ═══════════════════════════════════════════════ */
#top-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  box-shadow: var(--shadow-md);
}
#top-header .header-logo {
  height: 32px; flex-shrink: 0;
}
.header-search {
  flex: 1; display: flex; align-items: center;
  background: rgba(255,255,255,0.25); border-radius: 20px;
  height: 36px; padding: 0 12px; gap: 6px;
  backdrop-filter: blur(4px);
}
.header-search input {
  flex: 1; background: none; border: none; color: #fff;
  font-size: 13px; height: 100%;
}
.header-search input::placeholder { color: rgba(255,255,255,0.7); }
.header-search .search-btn {
  background: none; color: #fff; font-size: 18px;
  display: flex; align-items: center;
}
.header-cart {
  position: relative; color: #fff; font-size: 22px;
  display: flex; align-items: center; flex-shrink: 0;
  padding: 4px;
}
.header-cart .cart-badge {
  position: absolute; top: -2px; right: -4px;
  background: #fff; color: var(--primary);
  font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: none; align-items: center; justify-content: center;
  animation: badgePop 0.3s ease;
}
.header-cart .cart-badge.show { display: flex; }

/* ── Logged-in header style ── */
#top-header.logged-in .header-search { display: none; }
#top-header.logged-in .header-greeting {
  flex: 1; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#top-header.logged-in .header-menu {
  color: #fff; font-size: 20px; display: flex; align-items: center; padding: 4px;
}

/* ═══════════════════════════════════════════════
   BOTTOM NAVIGATION (5 Tab Shopee)
   ═══════════════════════════════════════════════ */
#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--bottom-nav-h);
  background: var(--white);
  display: flex; align-items: center;
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
}
.nav-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--text-light); font-size: 10px; font-weight: 500;
  transition: color 0.2s; padding: 6px 0; position: relative;
}
.nav-tab .nav-icon { font-size: 20px; line-height: 1; }
.nav-tab.active { color: var(--primary); font-weight: 600; }
.nav-tab.active::after {
  content: ''; position: absolute; top: 0; left: 25%; right: 25%;
  height: 2px; background: var(--primary); border-radius: 0 0 2px 2px;
}
.nav-tab .cart-dot {
  position: absolute; top: 4px; right: calc(50% - 24px);
  width: 8px; height: 8px; background: var(--primary); border-radius: 50%;
  display: none;
}
.nav-tab .cart-dot.show { display: block; }

/* ═══════════════════════════════════════════════
   CATEGORY STRIP (Horizontal Scroll)
   ═══════════════════════════════════════════════ */
#category-strip {
  background: var(--white); padding: 12px 0 8px;
  margin-bottom: 8px; box-shadow: var(--shadow-sm);
}
#category-strip .cat-scroll {
  display: flex; gap: 6px; overflow-x: auto; scroll-behavior: smooth;
  padding: 0 12px; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#category-strip .cat-scroll::-webkit-scrollbar { display: none; }
.cat-item {
  flex-shrink: 0; width: 72px; display: flex; flex-direction: column;
  align-items: center; gap: 6px; cursor: pointer; padding: 4px;
  border-radius: var(--radius); transition: background 0.15s;
}
.cat-item:active { background: var(--divider); }
.cat-item.active { background: var(--primary-light); }
.cat-item.active .cat-name { color: var(--primary); font-weight: 600; }
.cat-item .cat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.cat-item:nth-child(1) .cat-icon { background: #FFF3E0; }
.cat-item:nth-child(2) .cat-icon { background: #E8F5E9; }
.cat-item:nth-child(3) .cat-icon { background: #F3E5F5; }
.cat-item:nth-child(4) .cat-icon { background: #E3F2FD; }
.cat-item:nth-child(5) .cat-icon { background: #FFF8E1; }
.cat-item:nth-child(6) .cat-icon { background: #FFEBEE; }
.cat-item:nth-child(7) .cat-icon { background: #E0F7FA; }
.cat-item:nth-child(8) .cat-icon { background: #F9FBE7; }
.cat-item:nth-child(9) .cat-icon { background: #FCE4EC; }
.cat-item:nth-child(10) .cat-icon { background: #EFEBE9; }
.cat-item .cat-name {
  font-size: 11px; font-weight: 500; color: var(--text);
  text-align: center; line-height: 1.2; max-width: 72px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ═══════════════════════════════════════════════
   FLASH SALE SECTION
   ═══════════════════════════════════════════════ */
#flash-sale {
  background: var(--white); margin-bottom: 8px; padding: 12px;
  box-shadow: var(--shadow-sm);
}
.flash-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.flash-header .flash-title {
  font-size: 16px; font-weight: 700; color: var(--primary);
  display: flex; align-items: center; gap: 8px;
}
.flash-countdown {
  display: flex; align-items: center; gap: 4px;
}
.flash-countdown .timer-box {
  background: #222; color: #fff; font-size: 12px; font-weight: 700;
  padding: 2px 5px; border-radius: 3px; min-width: 22px; text-align: center;
}
.flash-countdown .timer-sep {
  color: #222; font-weight: 700; font-size: 11px;
}
.flash-products {
  display: flex; gap: 10px; overflow-x: auto;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.flash-products::-webkit-scrollbar { display: none; }
.flash-card {
  flex-shrink: 0; width: 120px; cursor: pointer;
}
.flash-card .flash-img {
  width: 120px; height: 120px; border-radius: 4px;
  object-fit: cover; background: var(--divider);
}
.flash-card .flash-price {
  font-size: 16px; font-weight: 700; color: var(--primary);
  margin-top: 4px;
}
.flash-card .flash-discount {
  font-size: 10px; color: var(--text-light); text-decoration: line-through;
}
.flash-card .flash-progress {
  margin-top: 6px; height: 14px; background: #FFD1C4;
  border-radius: 7px; position: relative; overflow: hidden;
}
.flash-card .flash-progress .bar {
  height: 100%; background: var(--primary); border-radius: 7px;
  transition: width 0.5s;
}
.flash-card .flash-progress .label {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-size: 9px; font-weight: 700; color: #fff;
}

/* ═══════════════════════════════════════════════
   PRODUCT GRID (2 Kolom ala Shopee)
   ═══════════════════════════════════════════════ */
#product-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 8px; padding: 0 8px;

}
.product-card {
  background: var(--white); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm);
  cursor: pointer; transition: transform 0.15s, box-shadow 0.15s;
  display: flex; flex-direction: column;
}
.product-card:active { transform: scale(0.98); box-shadow: var(--shadow-md); }
.product-card .card-img-wrap {
  position: relative; padding-top: 100%; overflow: hidden; background: #F0F0F0;
}
.product-card .card-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; transition: transform 0.3s;
}
.product-card .card-discount {
  position: absolute; top: 6px; right: 6px;
  background: rgba(0,0,0,0.5); color: var(--gold);
  font-size: 10px; font-weight: 700; padding: 2px 5px;
  border-radius: 2px;
}
.product-card .card-body { padding: 8px 10px 10px; flex: 1; display: flex; flex-direction: column; }
.product-card .card-name {
  font-size: 12px; line-height: 1.3; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: 6px; min-height: 31px;
}
.product-card .card-bottom {
  margin-top: auto; display: flex; align-items: center; justify-content: space-between;
}
.product-card .card-price {
  font-size: 15px; font-weight: 700; color: var(--primary);
}
.product-card .card-sold {
  font-size: 10px; color: var(--text-light);
}

/* ── Full width promo card ── */
.promo-card {
  background: linear-gradient(135deg, #FF6B35 0%, var(--primary) 100%);
  border-radius: var(--radius); padding: 16px; margin: 8px;
  color: #fff; cursor: pointer; position: relative; overflow: hidden;
}
.promo-card::after {
  content: ''; position: absolute; top: -20px; right: -20px;
  width: 100px; height: 100px; background: rgba(255,255,255,0.1);
  border-radius: 50%;
}
.promo-card h3 { font-size: 18px; font-weight: 700; }
.promo-card p { font-size: 13px; opacity: 0.9; margin-top: 4px; }

/* ═══════════════════════════════════════════════
   BOTTOM SHEET MODAL (Shopee Style)
   ═══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.4);
  display: none; align-items: flex-end; justify-content: center;
  animation: fadeIn 0.2s;
}
.modal-overlay.show { display: flex; }
.modal-sheet {
  width: 100%; max-width: 480px; max-height: 85vh;
  background: var(--white); border-radius: 16px 16px 0 0;
  overflow-y: auto; animation: slideUp 0.3s ease;
  display: flex; flex-direction: column;
}
.modal-sheet .sheet-handle {
  width: 36px; height: 4px; background: #D0D0D0; border-radius: 2px;
  margin: 10px auto 6px; flex-shrink: 0;
}
.modal-sheet .sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px 12px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--white); z-index: 1;
}
.modal-sheet .sheet-title { font-size: 16px; font-weight: 700; }
.modal-sheet .sheet-close {
  width: 28px; height: 28px; border-radius: 50%; background: var(--divider);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text-secondary);
}
.modal-sheet .sheet-body { padding: 16px; flex: 1; }
.sheet-body .product-detail-img {
  width: 100%; max-height: 300px; object-fit: contain;
  border-radius: var(--radius); background: var(--divider);
  margin-bottom: 12px;
}
.sheet-body .detail-name { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.sheet-body .detail-price { font-size: 22px; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.sheet-body .detail-stock { font-size: 12px; color: var(--text-secondary); margin-bottom: 12px; }
.sheet-body .detail-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 16px; }
.qty-control {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.qty-control button {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--white); font-size: 16px; display: flex; align-items: center; justify-content: center;
}
.qty-control button:active { background: var(--divider); }
.qty-control .qty-val { font-size: 16px; font-weight: 600; min-width: 24px; text-align: center; }
.btn-add-cart {
  width: 100%; height: 44px; background: linear-gradient(135deg, var(--primary) 0%, #FF6B35 100%);
  color: #fff; font-size: 15px; font-weight: 700; border-radius: var(--radius);
  transition: opacity 0.2s;
}
.btn-add-cart:active { opacity: 0.85; }

/* ═══════════════════════════════════════════════
   LOGIN / REGISTER SHEET
   ═══════════════════════════════════════════════ */
.login-body { display: flex; flex-direction: column; gap: 14px; }
.login-body .input-group { display: flex; flex-direction: column; gap: 4px; }
.login-body .input-group label {
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.login-body .input-group input {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; transition: border-color 0.2s;
}
.login-body .input-group input:focus { border-color: var(--primary); }
.login-body .input-hint { font-size: 11px; color: var(--red); display: none; }
.login-body .input-group.error .input-hint { display: block; }
.login-body .input-group.error input { border-color: var(--red); }
.btn-primary {
  width: 100%; height: 42px; background: var(--primary);
  color: #fff; font-size: 15px; font-weight: 600; border-radius: var(--radius);
  transition: opacity 0.2s;
}
.btn-primary:active { opacity: 0.85; }
.login-footer {
  text-align: center; font-size: 13px; color: var(--text-secondary);
  margin-top: 4px;
}
.login-footer a { color: var(--primary); font-weight: 600; cursor: pointer; }

/* ═══════════════════════════════════════════════
   ACCOUNT PAGE
   ═══════════════════════════════════════════════ */
.account-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 20px 16px; color: #fff; display: flex; align-items: center; gap: 12px;
}
.account-avatar {
  width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.account-info .acct-name { font-size: 16px; font-weight: 600; }
.account-info .acct-phone { font-size: 12px; opacity: 0.8; }
.account-menu {
  background: var(--white); margin: 8px 8px 0; border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.acct-menu-item {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border-bottom: 1px solid var(--divider); cursor: pointer; font-size: 14px;
}
.acct-menu-item:last-child { border-bottom: none; }
.acct-menu-item .menu-icon { font-size: 20px; width: 28px; text-align: center; }
.acct-menu-item .arrow { margin-left: auto; color: var(--text-light); }
.acct-menu-item:active { background: var(--divider); }
.btn-logout {
  width: calc(100% - 16px); height: 42px; margin: 12px 8px;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; font-weight: 600; color: var(--red);
  box-shadow: var(--shadow-sm);
}

/* ═══════════════════════════════════════════════
   ORDER PAGE
   ═══════════════════════════════════════════════ */
.order-tabs {
  display: flex; background: var(--white); border-bottom: 1px solid var(--border);
  position: sticky; top: var(--header-h); z-index: 10;
}
.order-tab {
  flex: 1; padding: 12px 8px; text-align: center; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.order-tab.active { color: var(--primary); border-color: var(--primary); font-weight: 600; }
.order-card {
  background: var(--white); margin: 8px; border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.order-card .order-hdr {
  display: flex; justify-content: space-between; padding: 10px 12px;
  border-bottom: 1px solid var(--divider); font-size: 12px; color: var(--text-secondary);
}
.order-card .order-item { padding: 10px 12px; display: flex; gap: 10px; }
.order-card .order-img {
  width: 64px; height: 64px; border-radius: 4px; object-fit: cover; background: var(--divider);
}
.order-card .order-nfo { flex: 1; font-size: 13px; }
.order-card .order-price { font-weight: 600; color: var(--primary); margin-top: 4px; }
.order-card .order-qty { font-size: 11px; color: var(--text-light); }
.order-card .order-total {
  display: flex; justify-content: flex-end; padding: 8px 12px;
  border-top: 1px solid var(--divider); font-size: 13px; font-weight: 600;
}

/* ═══════════════════════════════════════════════
   CART PAGE
   ═══════════════════════════════════════════════ */
.cart-item {
  display: flex; gap: 10px; padding: 12px;
  background: var(--white); margin: 8px; border-radius: var(--radius);
  box-shadow: var(--shadow-sm); align-items: center;
}
.cart-item .cart-img {
  width: 72px; height: 72px; border-radius: 4px; object-fit: cover; background: var(--divider);
}
.cart-item .cart-info { flex: 1; }
.cart-item .cart-name { font-size: 13px; margin-bottom: 4px; }
.cart-item .cart-price { font-size: 15px; font-weight: 700; color: var(--primary); }
.cart-summary {
  position: fixed; bottom: var(--bottom-nav-h); left: 0; right: 0; z-index: 50;
  background: var(--white); padding: 10px 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
}
.cart-summary .total-label { font-size: 12px; color: var(--text-secondary); }
.cart-summary .total-price { font-size: 18px; font-weight: 700; color: var(--primary); }
.btn-checkout {
  height: 40px; padding: 0 24px; background: var(--primary); color: #fff;
  font-size: 14px; font-weight: 600; border-radius: 20px;
}
.cart-empty {
  text-align: center; padding: 60px 20px; color: var(--text-light);
}
.cart-empty .empty-icon { font-size: 64px; display: block; margin-bottom: 12px; }

/* ═══════════════════════════════════════════════
   TOAST / NOTIFICATION
   ═══════════════════════════════════════════════ */
#toast {
  position: fixed; top: var(--header-h); left: 12px; right: 12px; z-index: 300;
  display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
.toast-item {
  padding: 12px 16px; border-radius: var(--radius); color: #fff;
  font-size: 13px; font-weight: 500; animation: toastIn 0.3s ease;
  box-shadow: var(--shadow-md); pointer-events: auto;
}
.toast-item.success { background: var(--green); }
.toast-item.error { background: var(--red); }
.toast-item.info { background: #2196F3; }

/* ═══════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════ */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text-light);
}
.empty-state .empty-icon { font-size: 56px; margin-bottom: 12px; }
.empty-state .empty-text { font-size: 14px; }
.empty-state .empty-action {
  margin-top: 12px; padding: 10px 24px; background: var(--primary);
  color: #fff; border-radius: 20px; font-weight: 600; font-size: 13px;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */
@media (min-width: 640px) {
  #product-grid { grid-template-columns: repeat(3, 1fr); max-width: 640px; margin: 0 auto; }
  .modal-sheet { max-width: 480px; }
}
@media (min-width: 1024px) {
  #product-grid { grid-template-columns: repeat(4, 1fr); max-width: 960px; }
}

/* ── Hide non-active sections ── */
.page-section { display: none; }
.page-section.active { display: block; animation: fadeIn 0.2s; }
