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

:root {
  --bg: #111827;
  --card: #1f2937;
  --card2: #111827;
  --border: #374151;
  --accent: #3b82f6;
  --accent2: #60a5fa;
  --text: #f9fafb;
  --text2: #9ca3af;
  --text3: #6b7280;
  --sale: #ef4444;
  --star: #fbbf24;
  --green: #10b981;
  --radius: 12px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; }

#app { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

/* Loading */
.loading-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; gap: 16px; color: var(--text2); }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Header */
.header { background: var(--bg); padding: 12px 16px 0; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.header-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.header-title { font-size: 18px; font-weight: 700; }
.cart-btn { position: relative; background: var(--card); border: none; color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 18px; display: flex; align-items: center; gap: 6px; }
.cart-count { background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 10px; }

/* Category tabs */
.cat-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab { flex-shrink: 0; padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border); background: transparent; color: var(--text2); font-size: 13px; cursor: pointer; white-space: nowrap; transition: all 0.15s; }
.cat-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* Search bar */
.search-wrap { padding: 10px 16px; flex-shrink: 0; }
.search-input { width: 100%; background: var(--card); border: 1px solid var(--border); color: var(--text); padding: 10px 14px; border-radius: 10px; font-size: 14px; outline: none; }
.search-input::placeholder { color: var(--text3); }

/* Product grid */
.product-grid { flex: 1; overflow-y: auto; padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-content: start; }
.product-card { background: var(--card); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: transform 0.15s; active: transform 0.1s; }
.product-card:active { transform: scale(0.97); }
.card-img-wrap { position: relative; aspect-ratio: 1; background: #0f172a; overflow: hidden; }
.card-img-wrap img { width: 100%; height: 100%; object-fit: cover; }
.card-img-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 40px; }
.sale-badge { position: absolute; top: 8px; left: 8px; background: var(--sale); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; }
.brand-label { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,0.7); color: var(--accent2); font-size: 10px; padding: 2px 6px; border-radius: 4px; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-body { padding: 10px; }
.card-name { font-size: 13px; font-weight: 600; line-height: 1.3; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { font-size: 11px; color: var(--text2); margin-bottom: 6px; }
.card-bottom { display: flex; align-items: center; justify-content: space-between; }
.card-price { font-size: 14px; font-weight: 700; color: var(--accent2); }
.card-options { font-size: 11px; color: var(--text3); }

/* Product detail */
.product-detail { flex: 1; overflow-y: auto; padding-bottom: 80px; }
.detail-img-wrap { background: #0f172a; aspect-ratio: 1; max-height: 260px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.detail-img-wrap img { width: 100%; height: 100%; object-fit: cover; }
.detail-img-placeholder { font-size: 80px; }
.detail-body { padding: 16px; }
.detail-brand { color: var(--accent2); font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.detail-name { font-size: 20px; font-weight: 700; margin-bottom: 12px; }
.detail-price-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.detail-price { background: #fff; color: #111; font-size: 18px; font-weight: 700; padding: 8px 18px; border-radius: 24px; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.detail-tag { background: var(--card); border: 1px solid var(--border); color: var(--text2); font-size: 11px; padding: 4px 10px; border-radius: 16px; }

/* Variant selector */
.variant-section { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.variant-label { font-size: 12px; color: var(--text2); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.variant-select { width: 100%; background: var(--bg); border: 2px solid var(--accent); color: var(--text); padding: 12px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; appearance: none; -webkit-appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.variant-select option { background: var(--card); }

/* Quantity */
.qty-section { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.qty-label { font-size: 12px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; flex: 1; }
.qty-controls { display: flex; align-items: center; gap: 0; background: var(--card); border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.qty-btn { background: none; border: none; color: var(--text); width: 40px; height: 40px; font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.qty-btn:active { background: var(--border); }
.qty-val { min-width: 40px; text-align: center; font-size: 16px; font-weight: 700; }

/* Detail desc */
.detail-desc { font-size: 13px; color: var(--text2); line-height: 1.6; }

/* Add to cart bar (fixed bottom) */
.add-bar { position: fixed; bottom: 0; left: 0; right: 0; padding: 12px 16px; background: var(--bg); border-top: 1px solid var(--border); display: flex; gap: 10px; }
.btn-add { flex: 1; background: var(--card); border: 2px solid var(--accent); color: var(--accent2); padding: 14px; border-radius: 12px; font-size: 15px; font-weight: 700; cursor: pointer; }
.btn-buy { flex: 1; background: var(--accent); border: none; color: #fff; padding: 14px; border-radius: 12px; font-size: 15px; font-weight: 700; cursor: pointer; }
.btn-add:active, .btn-buy:active { opacity: 0.8; }

/* Cart screen */
.cart-screen { flex: 1; overflow-y: auto; padding: 16px; padding-bottom: 100px; }
.cart-empty { text-align: center; padding: 60px 20px; color: var(--text2); }
.cart-empty-icon { font-size: 60px; margin-bottom: 16px; }
.cart-item { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 12px; }
.cart-item-img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: #0f172a; flex-shrink: 0; }
.cart-item-img-placeholder { width: 56px; height: 56px; border-radius: 8px; background: #0f172a; display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item-price { font-size: 13px; color: var(--accent2); font-weight: 700; }
.cart-item-qty { font-size: 12px; color: var(--text2); }
.cart-remove { background: none; border: none; color: var(--text3); font-size: 20px; cursor: pointer; padding: 4px; }
.cart-remove:active { color: var(--sale); }
.cart-total-bar { background: var(--card); border-radius: var(--radius); padding: 16px; margin-top: 6px; display: flex; justify-content: space-between; align-items: center; }
.cart-total-label { font-size: 15px; color: var(--text2); }
.cart-total-val { font-size: 20px; font-weight: 700; color: var(--accent2); }
.btn-checkout { width: 100%; background: var(--accent); color: #fff; border: none; padding: 16px; border-radius: 12px; font-size: 16px; font-weight: 700; cursor: pointer; margin-top: 12px; }
.btn-checkout:active { opacity: 0.8; }

/* Checkout screen */
.checkout-screen { flex: 1; overflow-y: auto; padding: 16px; padding-bottom: 100px; }
.checkout-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.checkout-total { color: var(--accent2); font-size: 15px; margin-bottom: 24px; }
.form-group { margin-bottom: 16px; }
.form-label { font-size: 12px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; display: block; }
.form-input { width: 100%; background: var(--card); border: 1px solid var(--border); color: var(--text); padding: 14px; border-radius: 10px; font-size: 15px; outline: none; transition: border-color 0.15s; }
.form-input:focus { border-color: var(--accent); }
.form-input.error { border-color: var(--sale); }
.form-error { color: var(--sale); font-size: 12px; margin-top: 4px; display: none; }
.form-error.show { display: block; }
.btn-place { width: 100%; background: var(--green); color: #fff; border: none; padding: 16px; border-radius: 12px; font-size: 16px; font-weight: 700; cursor: pointer; margin-top: 8px; }
.btn-place:active { opacity: 0.8; }
.btn-place:disabled { opacity: 0.5; cursor: not-allowed; }

/* Orders screen */
.orders-screen { flex: 1; overflow-y: auto; padding: 16px; }
.order-card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 10px; }
.order-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.order-id { font-size: 15px; font-weight: 700; }
.order-status { font-size: 12px; padding: 4px 10px; border-radius: 12px; font-weight: 600; }
.status-pending    { background: #78350f; color: #fde68a; }
.status-confirmed  { background: #064e3b; color: #6ee7b7; }
.status-preparing  { background: #1e3a5f; color: #93c5fd; }
.status-out_for_delivery { background: #312e81; color: #c4b5fd; }
.status-delivered  { background: #064e3b; color: #6ee7b7; }
.status-cancelled  { background: #450a0a; color: #fca5a5; }
.order-total { font-size: 18px; font-weight: 700; color: var(--accent2); }
.order-date { font-size: 12px; color: var(--text3); }

/* Bottom nav */
.bottom-nav { display: flex; background: var(--card); border-top: 1px solid var(--border); flex-shrink: 0; }
.nav-btn { flex: 1; background: none; border: none; color: var(--text3); padding: 10px 4px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; transition: color 0.15s; }
.nav-btn.active { color: var(--accent); }
.nav-btn svg { width: 22px; height: 22px; }

/* Toast */
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px); background: #111; color: #fff; padding: 10px 20px; border-radius: 20px; font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none; transition: all 0.3s; z-index: 999; white-space: nowrap; border: 1px solid var(--border); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
