/* ===== HEADER ===== */
.app-header {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-10) var(--space-16); min-height: 56px;
  background: color-mix(in oklch, var(--bg-primary) 85%, transparent);
  backdrop-filter: blur(16px) saturate(1.5); -webkit-backdrop-filter: blur(16px) saturate(1.5);
  border-bottom: 1px solid var(--border);
}
.header-left { display: flex; align-items: center; gap: var(--space-8); min-width: 44px; }
.header-title { font-size: var(--text-18); font-weight: var(--fw-semibold); color: var(--text-primary); flex: 1; text-align: center; }
.header-right { display: flex; align-items: center; min-width: 44px; justify-content: flex-end; }

/* Icon button */
.icon-btn {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill); transition: background var(--transition-fast), transform var(--transition-fast);
  color: var(--text-primary); position: relative; flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-surface); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn svg { width: 22px; height: 22px; }

/* Cart badge */
.cart-badge {
  position: absolute; top: 4px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--accent); color: #fff; font-size: var(--text-11); font-weight: var(--fw-bold);
  border-radius: var(--radius-pill); display: flex; align-items: center; justify-content: center;
  line-height: 1; pointer-events: none;
}
.cart-badge:empty, .cart-badge[data-count="0"] { display: none; }

/* ===== CATEGORY FILTER ===== */
.category-filters {
  display: flex; overflow-x: auto; gap: var(--space-8);
  padding: var(--space-12) var(--space-16); scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.category-filters::-webkit-scrollbar { display: none; }
.chip {
  padding: var(--space-6) var(--space-16); background: var(--bg-surface);
  color: var(--text-secondary); border-radius: var(--radius-pill); font-size: var(--text-14);
  font-weight: var(--fw-medium); white-space: nowrap; border: 1px solid var(--border);
  transition: all var(--transition-fast); cursor: pointer; user-select: none;
  min-height: 36px; display: inline-flex; align-items: center;
}
.chip:active { transform: scale(0.96); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== PRODUCT GRID ===== */
.product-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: var(--space-12); padding: var(--space-12) var(--space-16) var(--space-32);
}
@media (min-width: 400px) { .product-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); } }

/* ===== PRODUCT CARD ===== */
.product-card {
  display: flex; flex-direction: column; border-radius: var(--radius-12);
  background: var(--bg-surface); overflow: hidden; box-shadow: var(--shadow-xs);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.product-card:active { transform: scale(0.97); }
.product-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.product-img-wrap { width: 100%; aspect-ratio: 3/4; background: var(--bg-surface); position: relative; overflow: hidden; }
.product-img { width: 100%; height: 100%; object-fit: cover; transition: opacity var(--transition-normal); }
.product-img[src=""] { opacity: 0; }
.oos-overlay {
  position: absolute; inset: 0; background: oklch(0 0 0 / 0.55); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: var(--fw-semibold); font-size: var(--text-13); letter-spacing: 0.02em;
}
.discount-badge {
  position: absolute; top: var(--space-8); left: var(--space-8);
  background: var(--error); color: #fff; font-size: var(--text-11); font-weight: var(--fw-bold);
  padding: 2px 8px; border-radius: var(--radius-pill); line-height: 1.4;
}

.product-info { padding: var(--space-10) var(--space-10) var(--space-12); }
.product-name { font-size: var(--text-14); font-weight: var(--fw-medium); color: var(--text-primary); margin-bottom: var(--space-4); }
.product-price-row { display: flex; align-items: baseline; gap: var(--space-6); flex-wrap: wrap; }
.product-price { font-size: var(--text-16); font-weight: var(--fw-bold); color: var(--text-primary); }
.old-price { font-size: var(--text-13); color: var(--text-tertiary); text-decoration: line-through; }
.price-from { font-size: var(--text-12); color: var(--text-secondary); font-weight: var(--fw-regular); }

/* ===== PRODUCT DETAIL ===== */
.product-detail { padding-bottom: calc(80px + env(safe-area-inset-bottom, 16px)); }
.detail-gallery { width: 100%; aspect-ratio: 1/1; position: relative; background: var(--bg-surface); overflow: hidden; }
.gallery-scroll {
  display: flex; width: 100%; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.gallery-scroll::-webkit-scrollbar { display: none; }
.gallery-slide { min-width: 100%; height: 100%; scroll-snap-align: start; }
.gallery-slide img { width: 100%; height: 100%; object-fit: cover; }
.gallery-dots {
  position: absolute; bottom: var(--space-12); left: 50%; transform: translateX(-50%);
  display: flex; gap: var(--space-6);
}
.gallery-dot {
  width: 7px; height: 7px; border-radius: 50%; background: oklch(1 0 0 / 0.45);
  transition: all var(--transition-fast);
}
.gallery-dot.active { background: #fff; width: 20px; border-radius: var(--radius-pill); }
.gallery-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--text-tertiary);
}
.gallery-placeholder svg { width: 64px; height: 64px; opacity: 0.4; }

.detail-body { padding: var(--space-16) var(--space-16) var(--space-24); }
.detail-name { font-size: var(--text-24); font-weight: var(--fw-bold); margin-bottom: var(--space-8); line-height: 1.2; }
.detail-price-row { display: flex; align-items: baseline; gap: var(--space-8); margin-bottom: var(--space-16); }
.detail-price { font-size: var(--text-24); font-weight: var(--fw-bold); color: var(--accent); }
.detail-old-price { font-size: var(--text-16); color: var(--text-tertiary); text-decoration: line-through; }
.detail-description { font-size: var(--text-15); color: var(--text-secondary); line-height: 1.6; margin-bottom: var(--space-20); }

/* Color selector */
.selector-label { font-size: var(--text-13); font-weight: var(--fw-semibold); color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: var(--space-10); }
.color-selector { display: flex; gap: var(--space-10); flex-wrap: wrap; margin-bottom: var(--space-20); }
.color-dot {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid transparent; cursor: pointer;
  transition: all var(--transition-fast); position: relative; padding: 3px;
}
.color-dot::after {
  content: ''; display: block; width: 100%; height: 100%; border-radius: 50%;
  background: var(--dot-color, #ccc);
}
.color-dot.active { border-color: var(--accent); }
.color-dot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Size selector */
.size-selector { display: flex; gap: var(--space-8); flex-wrap: wrap; margin-bottom: var(--space-20); }
.size-pill {
  min-width: 48px; height: 40px; padding: 0 var(--space-16); border-radius: var(--radius-8);
  border: 1.5px solid var(--border); font-size: var(--text-14); font-weight: var(--fw-medium);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: all var(--transition-fast); color: var(--text-primary);
}
.size-pill:hover:not(.disabled) { border-color: var(--accent); }
.size-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.size-pill.disabled { opacity: 0.35; cursor: not-allowed; text-decoration: line-through; }
.size-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.stock-hint { font-size: var(--text-13); color: var(--warning); font-weight: var(--fw-medium); margin-bottom: var(--space-16); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-8);
  padding: 0 var(--space-24); height: 48px; border-radius: var(--radius-12);
  font-weight: var(--fw-semibold); font-size: var(--text-16);
  transition: all var(--transition-fast); width: 100%; position: relative; overflow: hidden;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-secondary { background: var(--bg-surface); color: var(--text-primary); border: 1.5px solid var(--border); }
.btn-secondary:active:not(:disabled) { background: var(--border); }
.btn-ghost { background: transparent; color: var(--accent); }

.btn-loading .btn-text { opacity: 0; }
.btn-loading::after {
  content: ''; position: absolute; width: 20px; height: 20px; border: 2px solid transparent;
  border-top-color: currentColor; border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Fixed bottom bar */
.bottom-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: var(--z-sticky);
  padding: var(--space-12) var(--space-16) calc(var(--space-12) + env(safe-area-inset-bottom, 8px));
  background: color-mix(in oklch, var(--bg-primary) 90%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}

/* ===== QUANTITY SELECTOR ===== */
.qty-selector {
  display: inline-flex; align-items: center; gap: 0; border: 1.5px solid var(--border);
  border-radius: var(--radius-8); overflow: hidden; height: 40px;
}
.qty-btn {
  width: 40px; height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--text-primary); transition: background var(--transition-fast);
}
.qty-btn:hover { background: var(--bg-surface); }
.qty-btn:active { background: var(--border); }
.qty-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.qty-btn svg { width: 16px; height: 16px; }
.qty-value { min-width: 36px; text-align: center; font-weight: var(--fw-semibold); font-size: var(--text-15); }

/* ===== CART ===== */
.cart-page { padding: var(--space-16); padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
.cart-item {
  display: flex; gap: var(--space-12); padding: var(--space-12) 0;
  border-bottom: 1px solid var(--border); position: relative;
}
.cart-item-img { width: 72px; height: 96px; border-radius: var(--radius-8); object-fit: cover; background: var(--bg-surface); flex-shrink: 0; }
.cart-item-body { flex: 1; display: flex; flex-direction: column; justify-content: space-between; min-width: 0; }
.cart-item-name { font-size: var(--text-14); font-weight: var(--fw-medium); margin-bottom: var(--space-2); }
.cart-item-meta { font-size: var(--text-13); color: var(--text-secondary); margin-bottom: var(--space-8); }
.cart-item-bottom { display: flex; align-items: center; justify-content: space-between; }
.cart-item-price { font-size: var(--text-16); font-weight: var(--fw-bold); }
.cart-remove {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  color: var(--text-tertiary); border-radius: var(--radius-pill); transition: all var(--transition-fast);
  position: absolute; top: var(--space-8); right: 0;
}
.cart-remove:hover { background: oklch(0.55 0.20 25 / 0.1); color: var(--error); }

.cart-total-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--space-16) 0; font-size: var(--text-18); font-weight: var(--fw-bold);
}

/* ===== CHECKOUT ===== */
.checkout-page { padding: var(--space-16); padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
.form-group { margin-bottom: var(--space-20); }
.form-label { display: block; font-size: var(--text-13); font-weight: var(--fw-semibold); color: var(--text-secondary); margin-bottom: var(--space-8); text-transform: uppercase; letter-spacing: 0.04em; }
.form-input, .form-textarea {
  width: 100%; padding: var(--space-12) var(--space-16); border-radius: var(--radius-12);
  border: 1.5px solid var(--border); background: var(--bg-surface); color: var(--text-primary);
  font-size: var(--text-16); transition: border-color var(--transition-fast);
}
.form-input:focus, .form-textarea:focus { border-color: var(--accent); }
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-tertiary); }
.form-input.error, .form-textarea.error { border-color: var(--error); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-error { font-size: var(--text-12); color: var(--error); margin-top: var(--space-4); }

/* Radio group */
.radio-group { display: flex; gap: var(--space-8); }
.radio-option {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: var(--space-8);
  padding: var(--space-12); border: 1.5px solid var(--border); border-radius: var(--radius-12);
  cursor: pointer; transition: all var(--transition-fast); font-weight: var(--fw-medium);
  min-height: 48px;
}
.radio-option:hover { border-color: var(--accent); }
.radio-option.active { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
.radio-option svg { width: 20px; height: 20px; }
.radio-option input { display: none; }

/* ===== TOAST ===== */
.toast-container { position: fixed; top: var(--space-16); left: var(--space-16); right: var(--space-16); z-index: var(--z-toast); pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: var(--space-12); padding: var(--space-12) var(--space-16);
  border-radius: var(--radius-12); background: var(--bg-elevated); box-shadow: var(--shadow-lg);
  border: 1px solid var(--border); margin-bottom: var(--space-8);
  animation: toastIn var(--transition-slow) forwards; pointer-events: auto;
}
.toast.toast-out { animation: toastOut var(--transition-normal) forwards; }
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--error); }
.toast-text { flex: 1; font-size: var(--text-14); font-weight: var(--fw-medium); }
.toast-close { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; color: var(--text-tertiary); cursor: pointer; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-16px); } }

/* ===== SKELETON ===== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--border) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-8);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-card .product-img-wrap { background: none; }
.skeleton-text { height: 14px; margin-bottom: var(--space-6); border-radius: var(--radius-4); }
.skeleton-text.w-60 { width: 60%; }
.skeleton-text.w-40 { width: 40%; }

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--space-64) var(--space-24); text-align: center; min-height: 40vh;
}
.empty-state svg { width: 80px; height: 80px; color: var(--text-tertiary); margin-bottom: var(--space-20); opacity: 0.5; }
.empty-state-title { font-size: var(--text-18); font-weight: var(--fw-semibold); color: var(--text-primary); margin-bottom: var(--space-8); }
.empty-state-text { font-size: var(--text-15); color: var(--text-secondary); max-width: 260px; }

/* ===== SUCCESS PAGE ===== */
.success-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 70vh; padding: var(--space-24); text-align: center; }
.success-icon { width: 80px; height: 80px; border-radius: 50%; background: var(--success); color: #fff; display: flex; align-items: center; justify-content: center; margin-bottom: var(--space-24); animation: successPop 0.4s var(--ease-spring); }
.success-icon svg { width: 40px; height: 40px; }
@keyframes successPop { from { transform: scale(0); } to { transform: scale(1); } }
.success-title { font-size: var(--text-24); font-weight: var(--fw-bold); margin-bottom: var(--space-8); }
.success-text { font-size: var(--text-15); color: var(--text-secondary); margin-bottom: var(--space-32); }

/* ===== LOADING ===== */
.page-loading { display: flex; align-items: center; justify-content: center; min-height: 60vh; }

/* ===== ORDER SUMMARY ===== */
.order-summary { background: var(--bg-surface); border-radius: var(--radius-12); padding: var(--space-16); margin-bottom: var(--space-24); }
.order-summary-title { font-size: var(--text-14); font-weight: var(--fw-semibold); color: var(--text-secondary); margin-bottom: var(--space-12); text-transform: uppercase; letter-spacing: 0.04em; }
.order-summary-item { display: flex; justify-content: space-between; padding: var(--space-6) 0; font-size: var(--text-14); }
.order-summary-total { display: flex; justify-content: space-between; padding-top: var(--space-12); margin-top: var(--space-8); border-top: 1px solid var(--border); font-size: var(--text-16); font-weight: var(--fw-bold); }
