:root {
  --bg: #f5f7fc;
  --surface: rgba(255,255,255,.96);
  --surface-2: #f7f9fd;
  --text: #172033;
  --muted: #6f7787;
  --border: #e7ebf4;
  --orange: #ff7a1a;
  --orange-dark: #e56a0e;
  --navy: #1d2943;
  --green: #14b86a;
  --shadow: 0 18px 42px rgba(20, 38, 76, .08);
  --shadow-soft: 0 10px 24px rgba(20, 38, 76, .06);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --footer-h: 82px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  font-family: Inter, Tajawal, system-ui, sans-serif;
  background: radial-gradient(circle at top, #ffffff 0%, #f4f7fc 55%, #eef2f8 100%);
  color: var(--text);
}
body[dir="rtl"] { font-family: Tajawal, Inter, system-ui, sans-serif; }
button, input, select { font: inherit; }
button { border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.desktop-only { display: block; }
.app-shell { max-width: 1320px; margin: 0 auto; padding: 18px 18px calc(var(--footer-h) + 20px); }
.card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255,255,255,.82);
  box-shadow: var(--shadow);
}
.topbar {
  position: sticky; top: 12px; z-index: 30;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px;
  padding: 14px 18px; border-radius: 24px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(16px); box-shadow: var(--shadow-soft);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--orange), #ff9d4c); color: #fff; font-weight: 800; font-size: 22px;
  box-shadow: 0 10px 24px rgba(255,122,26,.24);
}
.brand-eyebrow, .section-kicker {
  margin: 0 0 2px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800;
}
.brand h1, .hero-copy h2, .section-head h3, .promo-card h3, .drawer-header h3, .modal-header h3 { margin: 0; }
.header-search, .search-wrap {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 999px; padding: 0 16px;
}
.search-icon { color: var(--muted); font-size: 17px; }
.header-search input, .search-wrap input {
  width: 100%; border: 0; background: transparent; outline: none; padding: 14px 0; color: var(--text);
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.language-switcher, .segmented {
  display: inline-flex; gap: 6px; padding: 5px; border-radius: 999px; background: #f3f5fa; border: 1px solid var(--border);
}
.lang-button, .segmented-button {
  background: transparent; color: var(--muted); padding: 9px 12px; border-radius: 999px; font-weight: 700;
}
.lang-button.active, .segmented-button.active { background: #fff; color: var(--text); box-shadow: 0 3px 10px rgba(16,24,40,.06); }
.ghost-button, .secondary-button, .cart-button, .icon-button, .footer-tab {
  border: 1px solid var(--border);
}
.ghost-button, .secondary-button, .primary-button, .cart-button {
  padding: 12px 16px; border-radius: 16px; font-weight: 700;
}
.ghost-button, .secondary-button { background: #fff; color: var(--text); }
.primary-button {
  background: linear-gradient(135deg, var(--orange), #ff9649); color: #fff; box-shadow: 0 12px 28px rgba(255,122,26,.24);
}
.cart-button {
  background: var(--navy); color: #fff; display: inline-flex; align-items: center; gap: 8px;
}
.count-badge {
  min-width: 24px; height: 24px; display: inline-grid; place-items: center; padding: 0 6px; border-radius: 999px; background: rgba(255,255,255,.12);
}
.page-stack { display: grid; gap: 18px; margin-top: 18px; }
.hero-grid {
  display: grid; grid-template-columns: 230px 1fr; gap: 18px; padding: 18px;
}
.category-rail {
  padding: 18px; border-radius: 22px; background: linear-gradient(180deg, #fbfcff 0%, #f6f8fd 100%); border: 1px solid var(--border);
}
.category-rail-list { display: grid; gap: 10px; margin-top: 14px; }
.category-rail-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 13px 14px; border-radius: 16px; background: #fff; border: 1px solid var(--border); font-weight: 700;
}
.hero-banner {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(280px, .95fr); gap: 18px; padding: 18px; border-radius: 24px;
  background: linear-gradient(135deg, #ffffff 0%, #fbfcff 50%, #f5f8ff 100%); border: 1px solid var(--border);
}
.hero-copy { display: grid; align-content: center; gap: 14px; }
.hero-chip {
  display: inline-flex; width: fit-content; padding: 8px 12px; border-radius: 999px; background: #fff3e8; color: var(--orange-dark); font-weight: 700;
}
.hero-copy p { margin: 0; color: var(--muted); line-height: 1.7; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-showcase {
  display: grid; grid-template-columns: 1.15fr .85fr; grid-template-rows: 1fr 1fr; gap: 12px; min-height: 320px;
}
.showcase-card {
  position: relative; overflow: hidden; border-radius: 22px; background: #fff; border: 1px solid var(--border);
}
.showcase-card.large { grid-row: 1 / span 2; }
.showcase-card img { width: 100%; height: 100%; object-fit: cover; }
.showcase-overlay {
  position: absolute; inset: auto 12px 12px 12px; padding: 12px 13px; border-radius: 16px; background: rgba(255,255,255,.92); backdrop-filter: blur(10px);
}
.showcase-overlay strong { display: block; margin-bottom: 4px; }
.toolbar, .section-block { padding: 18px; }
.mobile-only-search { display: none; }
.chips, .featured-row { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: #f4f6fb; color: var(--text); padding: 10px 14px; border-radius: 999px; font-weight: 700;
}
.chip.active { background: var(--orange); color: #fff; border-color: var(--orange); box-shadow: 0 10px 22px rgba(255,122,26,.22); }
.discover-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.promo-card { padding: 20px; }
.promo-card.orange { background: linear-gradient(180deg, #fff9f3 0%, #fff2e3 100%); }
.promo-card.navy { background: linear-gradient(180deg, #1b2842 0%, #23375b 100%); color: #fff; }
.promo-card p { margin: 8px 0 0; line-height: 1.7; }
.promo-card.navy .section-kicker { color: rgba(255,255,255,.72); }
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px;
}
.catalog-meta { color: var(--muted); font-weight: 700; }
.featured-row { overflow-x: auto; padding-bottom: 4px; }
.featured-card {
  min-width: 250px; max-width: 250px; border-radius: 22px; border: 1px solid var(--border); background: #fff; overflow: hidden;
}
.featured-card img, .product-card img {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover; background: #f2f4f8;
}
.featured-card-body, .product-body { padding: 16px; display: grid; gap: 10px; }
.featured-card strong, .product-card strong { font-size: 19px; }
.merchant-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.merchant-card, .product-card {
  border-radius: 22px; border: 1px solid var(--border); background: linear-gradient(180deg, #fff 0%, #fbfcff 100%);
}
.merchant-card { padding: 18px; display: grid; gap: 10px; }
.badge-row, .product-meta, .product-footer, .summary-row, .qty-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
}
.badge.orange { background: #fff3e8; color: var(--orange-dark); }
.badge.green { background: #eefbf3; color: var(--green); }
.merchant-card p, .product-card p, .helper-text { margin: 0; color: var(--muted); line-height: 1.55; }
.product-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.product-footer { justify-content: space-between; }
.drawer {
  position: fixed; top: 16px; right: 16px; bottom: 16px; width: min(420px, calc(100vw - 32px));
  background: rgba(255,255,255,.98); border-radius: 28px; box-shadow: 0 24px 60px rgba(16,24,40,.18);
  padding: 22px; z-index: 60; display: flex; flex-direction: column;
  transform: translateX(120%); transition: transform .28s ease;
}
body[dir="rtl"] .drawer { right: auto; left: 16px; transform: translateX(-120%); }
.drawer.open { transform: translateX(0); }
.drawer-header, .modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.icon-button {
  width: 40px; height: 40px; border-radius: 12px; background: #fff; font-size: 22px;
}
.cart-items { flex: 1; overflow: auto; display: grid; gap: 12px; padding: 16px 0; }
.cart-item {
  display: grid; grid-template-columns: 76px 1fr auto; gap: 12px; align-items: center; padding: 10px;
  border-radius: 18px; border: 1px solid var(--border); background: #fff;
}
.cart-item img { width: 76px; height: 76px; border-radius: 14px; object-fit: cover; }
.qty-button {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border); background: #f4f6fb;
}
.drawer-footer { border-top: 1px solid var(--border); padding-top: 16px; display: grid; gap: 10px; }
.summary-row { justify-content: space-between; color: var(--muted); }
.summary-row.total { color: var(--text); font-size: 18px; font-weight: 800; }
.full-width { width: 100%; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 69;
}
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 24px));
  background: rgba(255,255,255,.98); border-radius: 28px; box-shadow: 0 28px 70px rgba(16,24,40,.24);
  padding: 22px; z-index: 70;
}
.toggle-row, .auth-section, .auth-step { display: grid; gap: 14px; }
.toggle-row { margin: 14px 0; }
.field { display: grid; gap: 8px; font-weight: 700; }
.field input, .field select {
  border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; background: var(--surface-2); outline: none;
}
.flash { padding: 12px 14px; border-radius: 16px; font-weight: 700; }
.flash.error { background: #fff1f1; color: #ca2f2f; }
.flash.success { background: #edfdf4; color: #15824e; }
.mobile-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: none; grid-template-columns: repeat(5, 1fr); gap: 10px;
  padding: 10px 14px calc(env(safe-area-inset-bottom, 0px) + 10px);
  background: rgba(255,255,255,.95); backdrop-filter: blur(16px); border-top: 1px solid rgba(231,235,244,.9);
}
.footer-tab {
  background: transparent; border-radius: 16px; padding: 10px 6px; display: grid; gap: 4px; place-items: center; color: var(--muted); font-weight: 700;
}
.footer-tab.active { color: var(--orange-dark); background: #fff3e8; border-color: #ffe1c6; }
.footer-tab small { font-size: 11px; }
.empty-state {
  padding: 28px; border-radius: 22px; border: 1px dashed var(--border); background: #fbfcff; text-align: center; color: var(--muted);
}
@media (max-width: 1120px) {
  .topbar { grid-template-columns: auto 1fr; }
  .topbar-actions { grid-column: 1 / -1; justify-content: space-between; }
  .hero-grid { grid-template-columns: 1fr; }
  .desktop-only { display: none; }
  .merchant-grid, .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app-shell { padding: 10px 10px calc(var(--footer-h) + 12px); }
  .topbar {
    top: 8px; grid-template-columns: 1fr; gap: 10px; padding: 12px; border-radius: 20px;
  }
  .header-search { display: none; }
  .topbar-actions { grid-column: auto; }
  .language-switcher { order: 3; }
  .hero-grid, .toolbar, .section-block, .promo-card { padding: 14px; border-radius: 22px; }
  .hero-banner { grid-template-columns: 1fr; padding: 14px; }
  .hero-copy h2 { font-size: 30px; line-height: 1.08; }
  .hero-showcase { grid-template-columns: 1fr 1fr; grid-template-rows: 160px 160px; min-height: auto; }
  .showcase-card.large { grid-row: 1 / span 1; grid-column: 1 / span 2; }
  .mobile-only-search { display: flex; margin-bottom: 12px; }
  .discover-grid, .merchant-grid, .product-grid { grid-template-columns: 1fr; }
  .featured-card { min-width: 82vw; max-width: 82vw; }
  .drawer { inset: 72px 10px calc(var(--footer-h) + 10px) 10px; width: auto; }
  body[dir="rtl"] .drawer { inset: 72px 10px calc(var(--footer-h) + 10px) 10px; }
  .modal { width: calc(100vw - 20px); top: auto; bottom: calc(var(--footer-h) + 10px); left: 50%; transform: translateX(-50%); }
  .mobile-footer { display: grid; }
}
