/* =========================================================
   سوق جيم — ملف التنسيق
   ========================================================= */

:root {
  --primary: #1f6f78;
  --primary-dark: #17565d;
  --accent: #f2a65a;
  --bg: #fbf8f3;
  --tint: #f2ede4;
  --surface: #ffffff;
  --ink: #1d2b2e;
  --muted: #5d6b6e;
  --line: #e6e0d6;
  --sale: #e0343c;
  --wa: #25d366;
  --font: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --radius: 18px;
  --shadow: 0 16px 36px -20px rgba(29, 43, 46, .35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.7; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
.container { width: min(100% - 32px, 1200px); margin-inline: auto; }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: 12px; border: 1.5px solid transparent;
  font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: transform .2s, background .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-sm { padding: 7px 14px; font-size: .9rem; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--surface); border-color: var(--line); }
.btn-wa { background: var(--wa); color: #fff; }
.btn-accent { background: var(--accent); color: var(--ink); padding: 14px 28px; font-size: 1.05rem; }
.btn[disabled] { background: var(--tint); color: var(--muted); cursor: not-allowed; transform: none; }
.link-btn { background: none; border: 0; color: var(--primary); font-weight: 700; cursor: pointer; }

/* ---------- الهيدر ---------- */
.header {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 10px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.25rem; margin-inline-end: auto; }
.brand img { border-radius: 11px; }
.mnav { display: flex; gap: 2px; }
.mnav a { padding: 7px 11px; border-radius: 99px; font-weight: 500; font-size: .92rem; color: var(--ink); text-decoration: none; white-space: nowrap; }
.mnav a:hover { background: var(--tint); }
.mnav a.current { color: var(--primary); font-weight: 700; }
.menu-toggle { display: none; width: 42px; height: 42px; padding: 10px; background: none; border: 0; cursor: pointer; }
.menu-toggle span { display: block; height: 2px; margin: 5px 0; background: var(--ink); border-radius: 2px; transition: transform .3s, opacity .3s; }
.menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.block { scroll-margin-top: 72px; }
@media (max-width: 1000px) {
  .menu-toggle { display: block; }
  .mnav {
    position: absolute; top: 64px; inset-inline: 0; flex-direction: column; gap: 0;
    padding: 8px 16px 14px; background: var(--surface); box-shadow: 0 16px 30px rgba(0, 0, 0, .08);
    display: none;
  }
  .mnav.open { display: flex; }
  .mnav a { padding: 12px; border-radius: 10px; }
}

/* ---------- الواجهة والبحث ---------- */
.hero {
  padding: 40px 0 28px;
  text-align: center;
  background:
    radial-gradient(circle at 85% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 40%),
    radial-gradient(circle at 10% 100%, color-mix(in srgb, var(--primary) 12%, transparent), transparent 45%);
}
.hero h1 { font-size: clamp(1.7rem, 5vw, 2.8rem); line-height: 1.35; }
.hl { color: var(--primary); }
.hero-text { color: var(--muted); max-width: 620px; margin: 10px auto 22px; }
.search {
  display: flex; align-items: center; gap: 10px;
  max-width: 620px; margin: 0 auto;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 4px 16px;
  box-shadow: var(--shadow);
  transition: border-color .2s;
}
.search:focus-within { border-color: var(--primary); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 12px 0; font-size: 1rem; }
.stats { color: var(--muted); font-size: .9rem; margin-top: 14px; }
.search-info { margin: 10px 0 0; font-weight: 700; color: var(--primary); }
.search-info.none { color: #b4532a; }
.search-info .link-btn { margin-inline-start: 6px; }
.filter-block { padding-bottom: 0; }
.filter-block .toolbar { margin-bottom: 0; }
.place-filters { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 10px; }
.city-filter {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 14px; padding: 6px 8px 6px 14px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px;
  font-weight: 700;
}
.city-filter select { border: 0; background: transparent; font-weight: 700; font-size: 1rem; color: var(--primary); cursor: pointer; padding: 4px; }
.city-filter select:focus { outline: none; }

/* ---------- الأقسام ---------- */
.block { padding: 18px 0; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.block-head h2 { font-size: 1.3rem; }

/* شريط أفقي قابل للتمرير */
.rail-wrap { width: min(100%, 1232px); margin-inline: auto; }
.rail {
  display: flex; gap: 14px;
  overflow-x: auto;
  padding: 4px 16px 14px;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}
.rail > * { scroll-snap-align: start; flex: none; }

/* بطاقة العرض */
.offer-card {
  width: 290px;
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px;
  border-radius: var(--radius);
  color: #fff;
  background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 55%, #000));
  box-shadow: var(--shadow);
}
.offer-store { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .9rem; opacity: .95; }
.offer-store img { width: 30px; height: 30px; border-radius: 50%; background: #fff; object-fit: cover; }
.offer-card h3 { font-size: 1.15rem; line-height: 1.45; margin-top: 4px; }
.offer-card p { font-size: .9rem; opacity: .88; }
.offer-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 10px; }
.offer-time { font-size: .82rem; font-weight: 700; background: rgba(255, 255, 255, .18); padding: 2px 10px; border-radius: 99px; }
.offer-card .btn { background: #fff; color: var(--ink); }

/* بطاقة منتج مخفّض داخل شريط العروض */
.deal-card {
  width: 200px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
}
.deal-card .media { position: relative; aspect-ratio: 4 / 3; background: var(--tint); }
.deal-card .media img { width: 100%; height: 100%; object-fit: cover; }
.deal-card .body { padding: 10px 12px 12px; }
.deal-card h3 { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deal-card .store-name { color: var(--muted); font-size: .8rem; }

/* المتاجر */
.stores-rail { gap: 10px; }
.store-chip {
  width: 96px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: 0; cursor: pointer;
  text-align: center; color: inherit; text-decoration: none;
}
.store-chip .logo {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--surface) center / cover no-repeat;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 2px var(--line);
  display: grid; place-items: center;
  font-size: 1.6rem; font-weight: 700; color: #fff;
  transition: box-shadow .2s, transform .2s;
}
.store-chip:hover .logo { transform: scale(1.05); }
.store-chip.active .logo { box-shadow: 0 0 0 3px var(--primary); }
.store-chip .name { font-size: .82rem; font-weight: 500; line-height: 1.4; }
.store-chip .city { font-size: .74rem; color: var(--muted); line-height: 1.2; }
.offer-store-text { display: grid; line-height: 1.3; }
.offer-store-text small { font-weight: 500; font-size: .78rem; opacity: .85; }

/* بطاقة المتجر المختار */
.store-banner {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 16px 18px; margin-bottom: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  border-inline-start: 6px solid var(--c, var(--primary));
}
.store-banner img { width: 58px; height: 58px; border-radius: 50%; object-fit: cover; }
.store-banner .info { flex: 1; min-width: 180px; }
.store-banner h2 { font-size: 1.2rem; }
.store-banner p { color: var(--muted); font-size: .9rem; }
.store-banner .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- شريط الأدوات ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 14px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface);
  font-weight: 500; font-size: .9rem; cursor: pointer;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.deal.active { background: var(--sale); border-color: var(--sale); }
#sort { padding: 7px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }

/* ---------- شبكة المنتجات ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.card {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card.off { opacity: .6; }
.media { position: relative; aspect-ratio: 4 / 3; background: var(--tint); }
.media img { width: 100%; height: 100%; object-fit: cover; }
.badge, .sale {
  position: absolute; top: 10px;
  font-size: .76rem; font-weight: 700;
  padding: 2px 10px; border-radius: 99px;
}
.badge { right: 10px; background: var(--surface); color: var(--ink); }
.sale { left: 10px; background: var(--sale); color: #fff; direction: ltr; }
.card .body { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px 14px; flex: 1; }
.store-link {
  display: inline-flex; align-items: center; gap: 6px;
  align-self: flex-start;
  background: none; border: 0; padding: 0; cursor: pointer; text-decoration: none;
  color: var(--muted); font-size: .8rem; font-weight: 500;
}
.store-link img, .store-link .dot { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }
.store-link:hover { color: var(--primary); }
.dot { display: inline-block; width: 22px; height: 22px; border-radius: 50%; flex: none; }
.card h3 { font-size: 1rem; line-height: 1.5; }
.card .desc { color: var(--muted); font-size: .85rem; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 8px; flex-wrap: wrap; }
.price { color: var(--primary); font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.old { color: var(--muted); font-weight: 400; font-size: .82rem; text-decoration: line-through; margin-inline-start: 4px; }

/* بطاقات التحميل */
.skeleton .media, .skeleton .line {
  background: linear-gradient(90deg, var(--tint) 25%, #faf7f2 50%, var(--tint) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
}
.skeleton .line { height: 12px; border-radius: 6px; margin: 6px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- دعوة للانضمام ---------- */
.join { padding: 32px 0 40px; }
.join-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  padding: 32px;
  border-radius: 24px;
  background: var(--primary); color: #fff;
  background-image: radial-gradient(circle at 100% 0%, rgba(242, 166, 90, .35), transparent 45%);
}
.join h2 { font-size: 1.5rem; }
.join p { opacity: .85; }

.footer { padding: 24px 0 32px; text-align: center; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }

/* ---------- الجوال ---------- */
@media (max-width: 600px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card .body { padding: 10px; }
  .card h3 { font-size: .92rem; }
  .card .desc { display: none; }
  .card .foot { flex-direction: column; align-items: stretch; }
  .card .foot .btn { padding: 8px; font-size: .85rem; }
  .offer-card { width: 260px; }
  .deal-card { width: 160px; }
  .toolbar { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; min-width: 0; }
  .chip { flex: none; }
  .join-inner { padding: 24px; text-align: center; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton .media, .skeleton .line { animation: none; }
}

/* العناصر المخفية تبقى مخفية مهما كان تنسيقها */
[hidden] { display: none !important; }
