/* ============ Variables ============ */
:root {
  --color-bg: #fff5fa;
  --color-card: #ffffff;
  --color-text: #3a1f33;
  --color-text-light: #8a6d82;
  --color-primary: #e8438f;
  --color-primary-dark: #c22f74;
  --color-accent: #9b5de5;
  --color-gold: #f5b942;
  --color-border: #f3d9e8;
  --color-success: #2fa86a;
  --color-error: #e0475a;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 6px 24px rgba(232, 67, 143, 0.12);
  --shadow-hover: 0 12px 32px rgba(232, 67, 143, 0.22);
  --gradient: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  --transition: 0.25s cubic-bezier(.4,0,.2,1);
  --app-max-width: 480px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, h4 { margin: 0 0 0.5em; line-height: 1.25; }
input, textarea, select, button { font-family: inherit; }

/* ============ App shell ============ */
.top-bar {
  position: sticky; top: 0; z-index: 100;
  background: var(--gradient); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  max-width: var(--app-max-width); margin: 0 auto;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
}
.logo-text { font-size: 1.25rem; font-weight: 800; }
.logo img { height: 34px; }
.lang-switch { display: flex; gap: 4px; align-items: center; font-weight: 700; font-size: 0.85rem; background: rgba(255,255,255,0.2); padding: 4px 10px; border-radius: 20px; }
.lang-switch a { color: rgba(255,255,255,0.75); }
.lang-switch a.active { color: #fff; }

.dev-banner {
  max-width: var(--app-max-width); margin: 8px auto 0; background: #fff3cd; color: #8a6d1f;
  text-align: center; font-size: 0.78rem; padding: 6px 10px; border-radius: 8px; font-weight: 600;
}

.app-main { max-width: var(--app-max-width); margin: 0 auto; padding: 16px 16px 90px; min-height: 60vh; }

.flash-wrap { max-width: var(--app-max-width); margin: 10px auto 0; padding: 0 16px; }
.flash { padding: 10px 16px; border-radius: var(--radius-sm); margin-bottom: 10px; font-weight: 600; font-size: 0.9rem; }
.flash-success { background: #e3f6ec; color: var(--color-success); }
.flash-error { background: #fce8ea; color: var(--color-error); }

/* ============ Bottom nav ============ */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--app-max-width);
  background: #fff; display: flex; justify-content: space-around; align-items: center;
  padding: 8px 0 10px; box-shadow: 0 -4px 20px rgba(232, 67, 143, 0.12); z-index: 100;
  border-radius: var(--radius) var(--radius) 0 0;
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 0.72rem; color: var(--color-text-light); font-weight: 600; padding: 4px 14px; border-radius: 12px; transition: var(--transition); position: relative; }
.bottom-nav a.active { color: var(--color-primary); background: #fdeaf3; }
.bn-icon { font-size: 1.3rem; position: relative; }
.cart-badge {
  position: absolute; top: -6px; right: -10px; background: var(--color-gold); color: #4a2f00;
  font-size: 0.62rem; font-weight: 800; border-radius: 20px; padding: 1px 5px; display: flex;
}

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--color-text); color: #fff; padding: 10px 20px; border-radius: 30px;
  font-size: 0.85rem; font-weight: 600; opacity: 0; pointer-events: none; transition: all 0.3s ease; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ Buttons ============ */
.btn { display: inline-block; padding: 0.7em 1.5em; border-radius: 30px; border: none; cursor: pointer; font-weight: 700; font-size: 0.92rem; transition: transform var(--transition), box-shadow var(--transition); }
.btn-primary { background: var(--gradient); color: #fff; box-shadow: var(--shadow); }
.btn-primary:active { transform: scale(0.96); }
.btn-outline { background: #fff; border: 2px solid var(--color-primary); color: var(--color-primary); }
.btn-danger { background: var(--color-error); color: #fff; }
.btn-add { background: var(--gradient); color: #fff; width: 100%; padding: 0.55em 0.5em; border-radius: 20px; font-size: 0.82rem; }
.btn-add:active { transform: scale(0.94); }
.btn-sm { padding: 0.45em 1.1em; font-size: 0.82rem; }
.btn-lg { width: 100%; padding: 0.9em; font-size: 1rem; }

/* ============ Hero + chips ============ */
.hero-banner { background: var(--gradient); color: #fff; border-radius: var(--radius); padding: 26px 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.hero-banner h1 { font-size: 1.4rem; margin-bottom: 6px; }
.hero-banner p { font-size: 0.9rem; opacity: 0.9; margin: 0; }

.category-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; scrollbar-width: none; }
.category-chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; padding: 8px 16px; border-radius: 20px; background: #fff; border: 1px solid var(--color-border); font-size: 0.85rem; font-weight: 600; color: var(--color-text-light); }
.chip.active { background: var(--gradient); color: #fff; border-color: transparent; }

.toolbar { display: flex; gap: 10px; margin-bottom: 12px; }
.search-form { flex: 1; display: flex; }
.search-form input { flex: 1; padding: 10px 14px; border: 1px solid var(--color-border); border-radius: 20px 0 0 20px; background: #fff; }
.search-form button { border: 1px solid var(--color-border); border-left: none; background: #fff; border-radius: 0 20px 20px 0; padding: 0 14px; }
.found-count { color: var(--color-text-light); font-size: 0.82rem; margin-bottom: 10px; }

/* ============ Fade in ============ */
.fade-in { opacity: 0; transform: translateY(18px); transition: opacity 0.5s ease, transform 0.5s ease; }
.fade-in.visible { opacity: 1; transform: translateY(0); }

/* ============ Product grid ============ */
.product-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.product-card { background: var(--color-card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform var(--transition); }
.product-card:active { transform: scale(0.98); }
.product-image { display: block; aspect-ratio: 1/1; background: linear-gradient(135deg, #fde2f0, #f3e6ff); overflow: hidden; }
.product-image img { width: 100%; height: 100%; object-fit: cover; }
.product-info { padding: 10px 12px 12px; }
.product-info h3 { font-size: 0.85rem; margin-bottom: 6px; min-height: 2.2em; }
.product-price { font-weight: 800; color: var(--color-primary-dark); margin-bottom: 8px; font-size: 0.95rem; }
.stock-info { font-size: 0.75rem; color: var(--color-text-light); margin-bottom: 8px; }
.stock-info.out { color: var(--color-error); font-weight: 600; }
.btn-add:disabled { background: #e5d9e0; color: #a893a0; cursor: not-allowed; box-shadow: none; }
.stock-badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 700; margin-bottom: 14px; }
.stock-badge.in { background: #e3f6ec; color: var(--color-success); }
.stock-badge.out { background: #fce8ea; color: var(--color-error); }

.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 24px; flex-wrap: wrap; }
.pagination a { padding: 6px 12px; border-radius: 10px; border: 1px solid var(--color-border); color: var(--color-text-light); font-size: 0.85rem; }
.pagination a.active { background: var(--gradient); color: #fff; border-color: transparent; }
.empty-state { text-align: center; padding: 40px 0; color: var(--color-text-light); }

/* ============ Filter drawer ============ */
.filter-drawer { position: fixed; inset: 0; z-index: 300; visibility: hidden; }
.filter-drawer.open { visibility: visible; }
.filter-drawer-overlay { position: absolute; inset: 0; background: rgba(58, 31, 51, 0.4); opacity: 0; transition: opacity var(--transition); }
.filter-drawer.open .filter-drawer-overlay { opacity: 1; }
.filter-drawer-panel {
  position: absolute; top: 0; right: 0; height: 100%; width: 82%; max-width: 340px;
  background: #fff; padding: 20px; overflow-y: auto; transform: translateX(100%);
  transition: transform var(--transition); box-shadow: -8px 0 24px rgba(0,0,0,0.15);
}
.filter-drawer.open .filter-drawer-panel { transform: translateX(0); }
.filter-close { position: absolute; top: 14px; right: 14px; background: none; border: none; font-size: 1.6rem; cursor: pointer; color: var(--color-text-light); }
.filter-block { margin: 24px 0 18px; }
.filter-block h4 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.4px; color: var(--color-primary-dark); }
.filter-block select { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--color-border); }
.filter-list li { margin-bottom: 8px; }
.filter-list label { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; color: var(--color-text); }
.filter-count { color: var(--color-text-light); font-size: 0.78rem; }
.filter-actions { display: flex; gap: 8px; margin-top: 20px; }

/* ============ Product detail ============ */
.product-detail { display: flex; flex-direction: column; gap: 16px; }
.gallery-main { border-radius: var(--radius); overflow: hidden; background: linear-gradient(135deg, #fde2f0, #f3e6ff); box-shadow: var(--shadow); }
.gallery-main img { width: 100%; aspect-ratio: 1/1; object-fit: cover; }
.gallery-thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; cursor: pointer; border: 2px solid transparent; opacity: 0.7; transition: var(--transition); flex-shrink: 0; }
.thumb:hover, .thumb.active { opacity: 1; border-color: var(--color-primary); }
.location-ok { color: var(--color-success); font-weight: 600; }
.product-price-lg { font-size: 1.5rem; font-weight: 800; color: var(--color-primary-dark); margin: 8px 0 14px; }
.attributes-list { margin: 14px 0; }
.attributes-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--color-border); font-size: 0.9rem; }
.attributes-list span { color: var(--color-text-light); }
.product-description p { color: var(--color-text-light); line-height: 1.6; font-size: 0.9rem; }

.add-to-cart-box { display: flex; align-items: center; gap: 12px; margin-top: 20px; }
.qty-stepper { display: flex; align-items: center; background: #fdeaf3; border-radius: 30px; padding: 4px; }
.qty-stepper.small { padding: 2px; }
.qty-btn { width: 32px; height: 32px; border-radius: 50%; border: none; background: #fff; color: var(--color-primary); font-size: 1.1rem; font-weight: 700; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.qty-stepper input, .qty-value { width: 34px; text-align: center; border: none; background: transparent; font-weight: 700; }

/* ============ Cart ============ */
.cart-items { display: flex; flex-direction: column; gap: 10px; }
.cart-item { display: flex; align-items: center; gap: 10px; background: var(--color-card); border-radius: var(--radius-sm); padding: 10px; box-shadow: var(--shadow); }
.cart-item img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; }
.cart-item-price { font-size: 0.85rem; color: var(--color-primary-dark); font-weight: 700; }
.cart-remove { background: none; border: none; color: var(--color-error); font-size: 1.3rem; cursor: pointer; }
.cart-summary { margin-top: 20px; background: var(--color-card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.cart-summary-row { display: flex; justify-content: space-between; font-size: 0.95rem; }

/* ============ Checkout ============ */
.checkout-summary { background: var(--color-card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.checkout-item { display: flex; justify-content: space-between; padding: 6px 0; font-size: 0.88rem; color: var(--color-text-light); }
.checkout-total { border-top: 1px solid var(--color-border); margin-top: 6px; padding-top: 10px; font-size: 1rem; color: var(--color-text); font-weight: 800; }
.checkout-form { display: flex; flex-direction: column; gap: 14px; }
.form-block { display: flex; flex-direction: column; gap: 6px; }
.form-block label { font-size: 0.85rem; font-weight: 700; color: var(--color-text-light); }
.checkout-form input, .checkout-form textarea { padding: 12px 14px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-size: 0.95rem; background: #fff; }
.checkout-form textarea { min-height: 70px; resize: vertical; }
.payment-box { background: #fff8ea; border: 1px dashed var(--color-gold); border-radius: var(--radius); padding: 14px; }
.payment-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 0.88rem; flex-wrap: wrap; }
.payment-row span { color: var(--color-text-light); min-width: 90px; }
.hint { color: var(--color-text-light); font-size: 0.82rem; }

/* ============ Success / orders ============ */
.success-box { text-align: center; padding: 40px 20px; }
.success-icon { font-size: 3.5rem; animation: bounceIn 0.6s ease; }
@keyframes bounceIn { 0% { transform: scale(0); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }
.order-ref { color: var(--color-text-light); margin-bottom: 20px; }
.success-box .btn { margin: 6px; }

.orders-list { display: flex; flex-direction: column; gap: 12px; }
.order-card { background: var(--color-card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.order-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.order-card-date { color: var(--color-text-light); font-size: 0.78rem; margin-bottom: 8px; }
.order-items-mini { margin-bottom: 8px; }
.order-items-mini li { font-size: 0.85rem; color: var(--color-text-light); padding: 2px 0; }
.order-card-total { font-weight: 800; color: var(--color-primary-dark); }

.status-badge { padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 700; }
.status-kutilmoqda, .badge.status-kutilmoqda { background: #fff3cd; color: #8a6d1f; }
.status-tasdiqlandi, .badge.status-tasdiqlandi { background: #e3f6ec; color: var(--color-success); }
.status-bekor_qilindi, .badge.status-bekor_qilindi { background: #fce8ea; color: var(--color-error); }

.page-title { font-size: 1.3rem; margin: 10px 0 16px; color: var(--color-primary-dark); }

@media (min-width: 540px) {
  body { background: #f3d9e8; }
}