/* style.css — طراحی app-like (شبیه اپ اینستاگرام) برای فروشگاه مرسدس
 * هدر بالا + نوار تب پایین + گرید immersive
 */

:root {
  /* Palette */
  --primary: #0f1e3d;
  --primary-light: #1e3a8a;
  --primary-soft: #eef2ff;
  --accent: #b8965a;
  --accent-dark: #9a7b3f;
  --accent-soft: #faf6ec;
  --bg: #fafafa;
  --bg-alt: #f1f3f6;
  --card: #ffffff;
  --text: #0f172a;
  --text-muted: #6b7280;
  --text-soft: #9ca3af;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --success: #10b981;
  --success-soft: #d1fae5;
  --warning: #f59e0b;
  --warning-soft: #fef3c7;
  --danger: #ef4444;
  --danger-soft: #fee2e2;

  /* Layout */
  --header-h: 56px;
  --tab-h: 60px;
  --max-w: 960px;
  --bottom-bar-h: 76px;

  /* Effects */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 40px rgba(15, 23, 42, 0.12);
}

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

html, body {
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; display: block; }

/* ─── Top Header (Instagram-like) ─────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
}

.app-header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 16px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Brand */
.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  min-width: 0;
}

.app-brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(15, 30, 61, 0.15);
  border: 1px solid var(--border);
}

.app-brand-name {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Header actions */
.app-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.hdr-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: all 0.18s ease;
  cursor: pointer;
}

.hdr-icon-btn svg {
  width: 22px;
  height: 22px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hdr-icon-btn:hover {
  background: var(--bg-alt);
  color: var(--primary);
}

.hdr-icon-btn:active { transform: scale(0.92); }

.hdr-icon-btn-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ─── Tab Bar (Bottom navigation like Instagram) ─── */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: var(--tab-h);
  z-index: 90;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.04);
}

.tab-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-w);
  height: 1px;
  background: var(--border);
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 100%;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 2px;
  cursor: pointer;
  transition: color 0.18s;
  position: relative;
  min-width: 0;
}

.tab-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-icon {
  width: 24px;
  height: 24px;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.18s;
}

.tab-item:hover { color: var(--text); }

.tab-item:hover .tab-icon { transform: scale(1.08); }

.tab-item:active .tab-icon { transform: scale(0.92); }

.tab-item.active {
  color: var(--primary);
}

.tab-item.active .tab-icon {
  stroke-width: 2.5;
  fill: var(--primary);
  fill-opacity: 0.1;
}

.tab-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.tab-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

/* ─── Main Content Area ─────────────────────────── */
.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 16px;
  /* padding-bottom باید به اندازه کافی بزرگ باشه تا محتوا زیر نوار tab-bar
     نره. اضافه می‌کنیم margin برای نوار bottom-actions (در صفحات سبد/checkout)
     که بالای tab-bar قرار می‌گیره. */
  padding-bottom: calc(var(--tab-h) + var(--bottom-bar-h) + 32px + env(safe-area-inset-bottom, 0px));
}

body.no-tab-bar .app-main {
  padding-bottom: 24px;
}

/* وقتی bottom-actions فعال نیست، فضای اضافی لازم نیست.
   اما برای سادگی و اطمینان از اینکه هیچوقت محتوا زیر نوار نره،
   همیشه padding-bottom کامل رو نگه می‌داریم. */

/* ─── Page Header (in-content) ──────────────────── */
.page-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding-top: 2px;
  min-height: 40px;
}

.page-head .back-btn {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text);
  font-size: 18px;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s;
  flex-shrink: 0;
  font-weight: 700;
}

.page-head .back-btn:hover {
  background: var(--bg-alt);
  border-color: var(--border-strong);
}

.page-head .page-title {
  font-size: 22px;
  font-weight: 800;
  flex: 1;
  color: var(--text);
  letter-spacing: -0.3px;
}

.page-head .cart-count {
  background: var(--danger);
  color: white;
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  min-width: 22px;
  text-align: center;
}

/* ─── Flash Messages ────────────────────────────── */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 14px;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}

.flash-success { background: var(--success-soft); color: #065f46; border-color: #6ee7b7; }
.flash-warning { background: var(--warning-soft); color: #78350f; border-color: #fcd34d; }
.flash-danger  { background: var(--danger-soft); color: #991b1b; border-color: #fca5a5; }
.flash-info    { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }

/* ─── Cards ─────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

/* ─── Home Hero + Stories-style row ─────────────── */
.home-hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 60%, #2563eb 100%);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  color: white;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.home-hero::before {
  content: '';
  position: absolute;
  top: -40px;
  left: -40px;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(184, 150, 90, 0.4) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.home-hero .hero-eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 4px 12px;
  background: rgba(184, 150, 90, 0.25);
  border: 1px solid rgba(184, 150, 90, 0.4);
  color: var(--accent);
  border-radius: 100px;
  margin-bottom: 12px;
}

.home-hero .hero-title {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
  position: relative;
}

.home-hero .hero-subtitle {
  font-size: 14px;
  opacity: 0.85;
  position: relative;
  line-height: 1.6;
}

.home-hero .hero-stats {
  display: flex;
  gap: 24px;
  margin-top: 18px;
  position: relative;
}

.home-hero .hero-stat {
  display: flex;
  flex-direction: column;
}

.home-hero .hero-stat-num {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
}

.home-hero .hero-stat-label {
  font-size: 11px;
  opacity: 0.75;
}

/* Quick action row (Instagram story-style circles) */
.quick-row {
  display: flex;
  gap: 16px;
  padding: 4px 4px 18px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.quick-row::-webkit-scrollbar { display: none; }

.quick-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  cursor: pointer;
  color: var(--text);
  transition: transform 0.15s;
}

.quick-item:active { transform: scale(0.95); }

.quick-item-icon {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-soft), white);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  border: 2px solid var(--primary);
  position: relative;
  box-shadow: 0 4px 12px rgba(15, 30, 61, 0.08);
}

.quick-item-icon svg {
  width: 26px;
  height: 26px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.quick-item-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  max-width: 70px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quick-item .quick-badge {
  position: absolute;
  top: -2px;
  left: -2px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* ─── Section Title ───────────────────────────── */
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 0 12px;
}

.section-title h2 {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.2px;
}

.section-title .link {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-light);
}

/* ─── Category chips (horizontal scroll like IG) ─ */
.cat-chips {
  display: flex;
  gap: 8px;
  padding: 6px 0 14px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 4px;
}
.cat-chips::-webkit-scrollbar { display: none; }

.cat-chip {
  padding: 8px 18px;
  scroll-snap-align: start;
  border-radius: 100px;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.15s;
}

.cat-chip:hover { border-color: var(--primary); color: var(--primary); }
.cat-chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Selected category banner (when a filter is active) */
.selected-cat-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.selected-cat-banner .selected-cat-name {
  font-size: 15px;
  font-weight: 700;
  flex: 1;
}

.selected-cat-banner .selected-cat-count {
  font-size: 12px;
  opacity: 0.85;
  background: rgba(255, 255, 255, 0.18);
  padding: 3px 10px;
  border-radius: 100px;
}

.selected-cat-clear {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  transition: background 0.15s;
}

.selected-cat-clear:hover { background: rgba(255, 255, 255, 0.3); }

/* page-head for explore - allow wrapping */
.explore-page-head { flex-wrap: wrap; }

/* ─── Explore Grid (Instagram-style square grid) ── */
.explore-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.explore-cell {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg-alt);
  cursor: pointer;
  overflow: hidden;
  display: block;
}

.explore-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.explore-cell:hover img { transform: scale(1.05); }

.explore-cell-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(15, 23, 42, 0.85) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: flex-end;
  padding: 8px;
  pointer-events: none;
}

.explore-cell:hover .explore-cell-overlay { opacity: 1; }

.explore-cell-code {
  color: white;
  font-size: 12px;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  z-index: 1;
}

/* On touch devices, always show code (bottom bar) */
@media (hover: none) {
  .explore-cell-overlay { opacity: 1; background: linear-gradient(to top, rgba(15, 23, 42, 0.7) 0%, transparent 60%); }
}

/* ─── Category Grid (catalog page) ──────────────── */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.cat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 18px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all 0.18s;
  position: relative;
  overflow: hidden;
}

.cat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  background: radial-gradient(circle at top right, var(--accent-soft) 0%, transparent 70%);
  pointer-events: none;
}

.cat-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.cat-card .cat-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
  position: relative;
}

.cat-card .cat-count {
  font-size: 12px;
  color: var(--text-muted);
  position: relative;
}

.cat-card .cat-arrow {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-dark);
  position: relative;
}

/* ─── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.18s ease;
  font-family: inherit;
  text-align: center;
  min-height: 44px;
  white-space: nowrap;
}

.btn svg { width: 18px; height: 18px; stroke-linecap: round; stroke-linejoin: round; }

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:active { background: var(--primary-light); transform: scale(0.98); }

.btn-accent {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(184, 150, 90, 0.3);
}

.btn-accent:active { transform: scale(0.98); }

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:active { transform: scale(0.98); }

.btn-danger { background: var(--danger); color: white; }

.btn-ghost {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-ghost:active { background: var(--bg-alt); transform: scale(0.98); }

/* Rubika login button (Google-style) */
.btn-rubika-login {
  background: var(--card);
  color: var(--text);
  border: 1.5px solid var(--border-strong);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  position: relative;
  font-weight: 700;
}

.btn-rubika-login:hover {
  background: #fafafa;
  border-color: var(--text-muted);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.btn-rubika-login:active { transform: scale(0.98); }

.btn-rubika-login .rubika-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
  color: white;
  flex-shrink: 0;
}

.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; min-height: 36px; border-radius: 8px; }
.btn-lg { padding: 14px 24px; font-size: 16px; min-height: 52px; }

/* ─── Forms ────────────────────────────────────── */
.form-group { margin-bottom: 14px; }

label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text);
}

input[type="text"],
input[type="tel"],
input[type="number"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px; /* ≥16px for iOS */
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  transition: all 0.15s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

input::placeholder, textarea::placeholder { color: var(--text-soft); }

textarea { min-height: 84px; resize: vertical; }

.field-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 5px;
}

/* ─── Product Grid (catalog list) ──────────────── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.product-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: all 0.18s;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

.product-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg-alt);
  display: block;
}

.product-info {
  padding: 10px 12px;
  text-align: center;
}

.product-code {
  font-weight: 700;
  font-size: 14px;
  color: var(--primary);
}

/* ─── Browse page (single product) ──────────────── */
.browse-product {
  text-align: center;
  max-width: 540px;
  margin: 0 auto;
}

.browse-product .browse-img-wrap {
  position: relative;
  margin-bottom: 14px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--card);
  border: 1px solid var(--border);
}

.browse-product .browse-img {
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
  background: var(--card);
  display: block;
}

.browse-product .browse-code {
  font-size: 20px;
  font-weight: 800;
  margin: 12px 0 4px;
  color: var(--text);
  letter-spacing: -0.2px;
}

.browse-product .browse-counter {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* prev/next side by side */
.browse-nav {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.browse-nav-btn { flex: 1; }

/* ─── Quantity selector (hidden until order clicked) ─── */
.qty-section {
  display: none;
  animation: fadeInUp 0.25s ease-out;
  margin-top: 16px;
  padding: 18px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.qty-section.show { display: block; }

.qty-section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.qty-selector {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.qty-option {
  width: 70px;
  height: 70px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--card);
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  color: var(--text);
}

.qty-option:hover {
  border-color: var(--primary-light);
}

.qty-option.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(15, 30, 61, 0.3);
}

.qty-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.qty-actions .btn { flex: 1; min-width: 130px; }

/* ─── Cart items ──────────────────────────────── */
.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--card);
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: opacity 0.25s, transform 0.25s;
}

.cart-item-img {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-alt);
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.cart-item-info { flex: 1; min-width: 0; }
.cart-item-info .code { font-weight: 700; font-size: 15px; color: var(--primary); }
.cart-item-info .qty { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

.cart-item-controls {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.cart-item-controls button {
  width: 36px; height: 36px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  transition: all 0.15s;
  color: var(--text);
}

.cart-item-controls button:hover { background: var(--bg-alt); }
.cart-item-controls button:active { transform: scale(0.92); }

.cart-item-controls .del-btn {
  color: var(--danger);
  border-color: #fecaca;
  background: var(--danger-soft);
  font-size: 14px;
}

.cart-item-controls .del-btn:hover { background: var(--danger); color: white; }

/* ─── Bottom action bar (sticky) ──────────────── */
.bottom-actions {
  position: fixed;
  bottom: var(--tab-h);
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  gap: 10px;
  z-index: 80;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.04);
  max-width: var(--max-w);
  margin: 0 auto;
}

.bottom-actions .btn { flex: 1; }
.bottom-actions.row-2 { flex-wrap: wrap; }
.bottom-actions.row-2 .btn { flex: 1 1 45%; }

/* ─── Cart toast ──────────────────────────────── */
.cart-toast {
  position: fixed;
  bottom: calc(var(--tab-h) + 12px);
  left: 16px;
  right: 16px;
  max-width: 420px;
  margin: 0 auto;
  background: var(--text);
  color: white;
  padding: 14px 16px;
  border-radius: var(--radius);
  display: none;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.cart-toast.show { display: flex; }

.cart-toast #cart-toast-msg {
  font-weight: 600;
  font-size: 14px;
  text-align: center;
}

.cart-toast-actions {
  display: flex;
  gap: 8px;
}

.cart-toast-actions .btn { flex: 1; }

/* ─── Tables ──────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: 14px;
  border: 1px solid var(--border);
}

.table th, .table td {
  padding: 11px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.table th {
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 13px;
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-alt); }

/* ─── Badges ──────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success { background: var(--success-soft); color: #065f46; }
.badge-warning { background: var(--warning-soft); color: #78350f; }
.badge-danger  { background: var(--danger-soft); color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }

/* ─── Auth pages (login/register) ─────────────── */
.auth-wrap {
  max-width: 460px;
  margin: 0 auto;
  padding: 24px 18px;
}

.auth-card-outside {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 30px 26px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.auth-card-outside::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
}

.auth-logo {
  text-align: center;
  margin-bottom: 22px;
}

.auth-logo-img {
  width: 80px;
  height: 80px;
  border-radius: 18px;
  object-fit: cover;
  margin: 0 auto 12px;
  box-shadow: 0 8px 24px rgba(15, 30, 61, 0.2);
  border: 2px solid var(--border);
}

.auth-logo .auth-logo-name {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.auth-logo .auth-subtitle {
  color: var(--text-muted);
  margin-top: 4px;
  font-size: 13px;
}

/* ─── Empty states ────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  width: 76px;
  height: 76px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state .icon svg {
  width: 34px;
  height: 34px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-state .title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

.empty-state .desc {
  font-size: 14px;
  margin-bottom: 16px;
  color: var(--text-muted);
}

/* ─── Order card ──────────────────────────────── */
.order-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 10px;
  transition: box-shadow 0.15s;
}

.order-card:hover { box-shadow: var(--shadow); }

.order-card.new-order {
  border-color: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.order-card .order-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.order-card .order-head .order-id {
  font-weight: 700;
  font-size: 15px;
  color: var(--primary);
}

.order-card .order-items { padding-top: 4px; }

.order-card .order-item {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text);
}

.order-card .order-item .qty { color: var(--text-muted); }

/* ─── Info display ────────────────────────────── */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  gap: 12px;
}

.info-row:last-child { border-bottom: none; }
.info-row .label { color: var(--text-muted); flex-shrink: 0; }
.info-row .value { font-weight: 600; text-align: left; }

/* ─── Profile card ────────────────────────────── */
.profile-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  color: white;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-md);
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
}

.profile-header .profile-name {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 4px;
}

.profile-header .profile-meta {
  font-size: 12px;
  opacity: 0.85;
}

/* ─── Animations ──────────────────────────────── */
@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Utilities ───────────────────────────────── */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ─── Responsive: Tablet & Desktop ───────────── */
@media (min-width: 768px) {
  .app-main {
    padding: 20px;
    padding-bottom: calc(var(--tab-h) + var(--bottom-bar-h) + 32px + env(safe-area-inset-bottom, 0px));
  }

  .home-hero { padding: 32px 28px; }
  .home-hero .hero-title { font-size: 28px; }

  .explore-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
  }

  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
  }
}

@media (min-width: 1024px) {
  .explore-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* ─── Responsive: Mobile (default) ────────────── */
@media (max-width: 600px) {
  .app-header-inner { padding: 0 12px; }
  .app-brand-logo { width: 32px; height: 32px; }
  .app-brand-name { font-size: 18px; }
  .hdr-icon-btn { width: 38px; height: 38px; }
  .hdr-icon-btn svg { width: 20px; height: 20px; }

  .app-main {
    padding: 12px;
    /* padding-bottom رو دوباره تنظیم می‌کنیم چون padding:12px همه طرف رو بازنویسی می‌کنه */
    padding-bottom: calc(var(--tab-h) + var(--bottom-bar-h) + 24px + env(safe-area-inset-bottom, 0px));
  }
  body.no-tab-bar .app-main {
    padding-bottom: 24px;
  }

  .home-hero { padding: 22px 18px; }
  .home-hero .hero-title { font-size: 22px; }
  .home-hero .hero-subtitle { font-size: 13px; }
  .home-hero .hero-stats { gap: 18px; margin-top: 14px; }
  .home-hero .hero-stat-num { font-size: 18px; }

  .quick-item-icon { width: 56px; height: 56px; }
  .quick-item-icon svg { width: 22px; height: 22px; }
  .quick-item-label { font-size: 10px; }

  .explore-grid { gap: 2px; }

  .cat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cat-card { padding: 18px 12px; }

  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  .page-head .page-title { font-size: 19px; }

  .qty-option { width: 60px; height: 60px; font-size: 19px; }

  .auth-card-outside { padding: 22px 18px; }
  .auth-wrap { padding: 16px 12px; }
}

/* ─── Very small screens ──────────────────────── */
@media (max-width: 360px) {
  .app-brand-name { display: none; }

  .explore-grid { grid-template-columns: repeat(2, 1fr); }

  .product-grid, .cat-grid { gap: 8px; }

  .qty-option { width: 52px; height: 52px; font-size: 17px; }

  .cart-item-img { width: 56px; height: 56px; }

  .quick-item-icon { width: 52px; height: 52px; }
}

/* ─── Desktop: hide some elements, show "desktop nav" alternative ── */
@media (min-width: 1024px) {
  .tab-bar {
    max-width: var(--max-w);
    margin: 0 auto;
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    bottom: 16px;
    height: 64px;
  }
  .app-main {
    padding-bottom: calc(64px + 48px);
  }
}
