/* =====================================================================
   Kayan Store — كتالوج الجملة
   ألوان البراند: غيّر القيم دي بس لو حبيت تغير الألوان
   ===================================================================== */
:root {
  --red: #b32229;
  --red-deep: #8f1a20;
  --red-soft: #fbecec;
  --ink: #221e1f;
  --ink-2: #4a4446;
  --muted: #7d7678;
  --line: #e8e3e1;
  --line-2: #d9d3d1;
  --canvas: #f4f2f0;
  --paper: #ffffff;
  --wa: #1c9d4f;
  --wa-deep: #15823f;

  --display: "Alexandria", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --body: "IBM Plex Sans Arabic", "Alexandria", system-ui, sans-serif;

  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
  --tile: 12px 12px 12px 4px;      /* شكل مربع الـ K في اللوجو */
  --shadow-sm: 0 1px 2px rgba(34, 30, 31, .06);
  --shadow-md: 0 10px 30px -12px rgba(34, 30, 31, .22);
  --shadow-lg: 0 30px 80px -20px rgba(34, 30, 31, .45);
  --topbar-h: 72px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 16px); }
body {
  margin: 0;
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.wrap { width: 100%; max-width: 1440px; margin-inline: auto; padding-inline: 16px; }
@media (min-width: 768px) { .wrap { padding-inline: 28px; } }

/* ---------- الهيدر ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar::before { content: ""; display: block; height: 3px; background: var(--red); }
.topbar-in {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "logo . order" "search search search";
  align-items: center;
  gap: 8px 12px;
  padding-block: 8px 10px;
}
.logo { grid-area: logo; display: block; }
.logo img { height: 42px; width: auto; }
.search-row { grid-area: search; display: flex; gap: 8px; min-width: 0; }
.order-btn { grid-area: order; }

.search {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  height: 46px; padding-inline: 14px 6px;
  background: var(--canvas); border: 1.5px solid transparent; border-radius: 999px;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.search:focus-within { background: var(--paper); border-color: var(--ink); box-shadow: 0 0 0 4px rgba(34, 30, 31, .06); }
.search > svg { color: var(--muted); }
.search input { flex: 1; width: 0; min-width: 0; border: 0; background: none; outline: none; height: 100%; font-size: 15px; }
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.search-clear:hover { background: var(--line); color: var(--ink); }
.search-clear svg { width: 16px; height: 16px; }

.filters-btn {
  flex: none; position: relative; display: inline-flex; align-items: center; gap: 6px;
  height: 46px; padding-inline: 14px; border-radius: 999px;
  background: var(--ink); color: #fff; font-weight: 600;
}
.filters-btn .dot { position: absolute; top: 8px; inset-inline-start: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--ink); }

.order-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding-inline: 14px 10px;
  border-radius: var(--tile); background: var(--red); color: #fff;
  font-family: var(--display); font-weight: 600; font-size: 14px;
  transition: background .2s, transform .2s var(--ease);
}
.order-btn:hover { background: var(--red-deep); }
.order-btn:active { transform: scale(.97); }
.order-count {
  min-width: 24px; height: 24px; padding-inline: 6px; border-radius: 8px;
  display: grid; place-items: center;
  background: #fff; color: var(--red); font-size: 13px; font-weight: 700;
}
.order-btn.bump { animation: bump .45s var(--ease); }
@keyframes bump { 30% { transform: scale(1.12); } 60% { transform: scale(.96); } }

@media (min-width: 1024px) {
  :root { --topbar-h: 76px; }
  .topbar-in { grid-template-columns: auto minmax(0, 640px) 1fr auto; grid-template-areas: "logo search . order"; gap: 28px; padding-block: 12px; }
  .logo img { height: 50px; }
  .filters-btn { display: none; }
  .order-btn { height: 48px; padding-inline: 18px 12px; font-size: 15px; }
}

/* ---------- الهيرو ---------- */
.hero {
  position: relative; overflow: hidden;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .035) 0 1px, transparent 1px 22px),
    radial-gradient(120% 140% at 0% 0%, #3a3234 0%, var(--ink) 55%);
  color: #fff;
}
.hero-in { position: relative; display: grid; gap: 22px; padding-block: 30px 18px; z-index: 1; }
.eyebrow {
  margin: 0 0 10px; display: flex; align-items: center; gap: 10px;
  font-family: var(--display); font-size: 12px; letter-spacing: .08em; color: rgba(255, 255, 255, .62);
  direction: ltr; justify-content: flex-end;
}
.eyebrow i { width: 5px; height: 5px; background: var(--red); border-radius: 1.5px; }
.hero h1 {
  margin: 0; font-family: var(--display); font-weight: 800;
  font-size: clamp(30px, 6.4vw, 56px); line-height: 1.12; letter-spacing: -.01em;
}
.hero h1::after { content: "."; color: var(--red); }
.hero .sub { margin: 12px 0 0; max-width: 56ch; color: rgba(255, 255, 255, .72); font-size: 15px; }
.stats { margin: 0; display: flex; gap: 10px; }
.stats > div {
  flex: 1; min-width: 0; padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, .12); border-radius: var(--r-md);
  background: rgba(255, 255, 255, .04);
}
.stats dd { margin: 0; font-family: var(--display); font-weight: 700; font-size: 26px; line-height: 1.1; }
.stats dt { font-size: 13px; color: rgba(255, 255, 255, .6); }
.hero-k { position: absolute; width: 260px; height: 260px; inset-inline-end: -70px; top: -40px; opacity: .95; z-index: -1; stroke: none; }
.hero-k rect { fill: var(--red); }
.hero-k path { fill: var(--ink); }
.updated { position: relative; z-index: 1; margin: 0; padding-block: 0 18px; font-size: 13px; color: rgba(255, 255, 255, .55); }
.updated b { color: #fff; font-weight: 600; }
.live-dot { display: inline-block; width: 8px; height: 8px; margin-inline-end: 8px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 3px rgba(61, 220, 132, .2); vertical-align: 1px; }
@media (max-width: 767px) {
  .hero-k { width: 170px; height: 170px; inset-inline-end: -64px; top: -26px; opacity: .9; }
  .hero-text { padding-inline-end: 72px; }
}
@media (min-width: 768px) {
  .hero-in { grid-template-columns: 1fr auto; align-items: end; padding-block: 44px 22px; padding-inline-end: 230px; }
  .stats > div { min-width: 104px; }
  .hero-k { width: 300px; height: 300px; inset-inline-end: -40px; top: 50%; transform: translateY(-50%) rotate(-6deg); }
}
@media (min-width: 1024px) { .hero-in { padding-inline-end: 300px; } .hero-k { width: 340px; height: 340px; inset-inline-end: 0; } }

/* ---------- شريط الأقسام ---------- */
.rail { position: relative; margin-top: 16px; }
.rail-scroll {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-block: 2px 6px;
  mask-image: linear-gradient(to left, #000 calc(100% - 40px), transparent);
  -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 40px), transparent);
}
.rail-scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding-inline: 16px 12px; border-radius: 999px;
  background: var(--paper); border: 1px solid var(--line);
  font-weight: 500; font-size: 14px; white-space: nowrap;
  transition: background .18s, color .18s, border-color .18s;
}
.chip small { font-family: var(--display); font-size: 11px; color: var(--muted); background: var(--canvas); border-radius: 6px; padding: 1px 6px; }
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip[aria-pressed="true"] small { background: rgba(255, 255, 255, .14); color: #fff; }
.chip.is-zero { opacity: .45; }

/* ---------- التخطيط ---------- */
.layout { display: grid; gap: 24px; padding-block: 16px 56px; align-items: start; }
@media (min-width: 1024px) { .layout { grid-template-columns: 276px minmax(0, 1fr); gap: 28px; } }

/* ---------- الفلاتر ---------- */
.filters { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); }
.sheet-head, .sheet-foot { display: none; }
.sheet-body { padding: 6px 18px; }
.fgroup { padding-block: 16px; border-bottom: 1px solid var(--line); }
.fgroup:last-child { border-bottom: 0; }
.fgroup-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.fgroup h2 { margin: 0; font-family: var(--display); font-size: 15px; font-weight: 700; }
.fgroup h2 small { font-weight: 400; color: var(--muted); font-size: 12px; }
.link-btn { font-size: 13px; color: var(--red); font-weight: 600; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--muted); }
.mini-search {
  width: 100%; height: 38px; padding-inline: 12px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--canvas); outline: none;
  font-size: 14px;
}
.mini-search:focus { border-color: var(--ink); background: var(--paper); }
.checks { list-style: none; margin: 0; padding: 0; max-height: 292px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.check {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 6px; border-radius: 8px; text-align: start; font-size: 14px;
}
.check:hover { background: var(--canvas); }
.check .box {
  width: 18px; height: 18px; flex: none; border: 1.5px solid var(--line-2); border-radius: 5px 5px 5px 2px;
  display: grid; place-items: center; transition: background .15s, border-color .15s;
}
.check .box svg { width: 12px; height: 12px; stroke: #fff; stroke-width: 3; opacity: 0; }
.check[aria-checked="true"] .box { background: var(--red); border-color: var(--red); }
.check[aria-checked="true"] .box svg { opacity: 1; }
.check[aria-checked="true"] .label { font-weight: 600; }
.check .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check .n { font-family: var(--display); font-size: 12px; color: var(--muted); }
.check.is-zero { opacity: .4; }
.price-range { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.price-range label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.price-range input {
  width: 100%; height: 40px; padding-inline: 10px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--canvas); outline: none; font-family: var(--display); font-size: 14px; direction: ltr; text-align: right;
}
.price-range input:focus { border-color: var(--ink); background: var(--paper); }
.sort-mobile { display: none; }

@media (min-width: 1024px) {
  .filters { position: sticky; top: calc(var(--topbar-h) + 16px); max-height: calc(100dvh - var(--topbar-h) - 32px); overflow-y: auto; scrollbar-width: thin; }
}
@media (max-width: 1023px) {
  .filters {
    position: fixed; z-index: 60; inset: auto 0 0 0; max-height: 88dvh;
    display: flex; flex-direction: column;
    border-radius: 22px 22px 0 0; border: 0; box-shadow: var(--shadow-lg);
    transform: translateY(105%); transition: transform .35s var(--ease); visibility: hidden;
  }
  .filters.open { transform: none; visibility: visible; }
  .sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 8px; font-family: var(--display); font-size: 17px; }
  .sheet-head::before { content: ""; position: absolute; top: 7px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--line-2); }
  .sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
  .sheet-foot { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
  .sort-mobile { display: block; }
  .checks { max-height: 232px; }
}

/* ---------- شريط الأدوات ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 16px; }
.result-count { margin: 0; font-size: 14px; color: var(--muted); white-space: nowrap; }
.result-count b { font-family: var(--display); font-size: 22px; color: var(--ink); margin-inline-end: 4px; }
.active-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.fchip {
  display: inline-flex; align-items: center; gap: 4px; height: 30px; padding-inline: 12px 6px;
  border-radius: 999px; background: var(--red-soft); color: var(--red-deep); font-size: 13px; font-weight: 600;
}
.fchip svg { width: 14px; height: 14px; stroke-width: 2.4; }
.fchip:hover { background: #f6d9da; }
.tools { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.select {
  height: 40px; padding-inline: 12px 34px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23221e1f' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat left 10px center / 16px;
  appearance: none; -webkit-appearance: none; font-size: 14px; cursor: pointer; width: 100%;
}
.sort-desktop { width: auto; }
.seg { display: inline-flex; padding: 3px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); }
.seg button { width: 34px; height: 32px; border-radius: 7px; display: grid; place-items: center; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.icon-btn { width: 40px; height: 40px; border-radius: var(--r-sm); display: grid; place-items: center; color: var(--ink); }
.icon-btn:hover { background: var(--canvas); }
.icon-btn.outline { border: 1px solid var(--line); background: var(--paper); }
@media (max-width: 1023px) {
  .sort-desktop, #printBtn { display: none; }
  .active-chips { order: 3; flex-basis: 100%; }
  .active-chips:empty { display: none; }
}

/* ---------- كروت المنتجات ---------- */
.grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 1280px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1600px) { .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

.card {
  position: relative; display: flex; flex-direction: column; min-width: 0;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden; transition: box-shadow .25s var(--ease), transform .25s var(--ease), border-color .25s;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); border-color: transparent; }
.card-media { position: relative; display: block; width: 100%; aspect-ratio: 1; background: #fff; overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: contain; padding: 8%; transition: transform .45s var(--ease); }
.card:hover .card-media img { transform: scale(1.05); }
.badge {
  position: absolute; top: 10px; inset-inline-start: 10px; z-index: 1;
  padding: 3px 10px; border-radius: var(--tile); background: var(--red); color: #fff;
  font-family: var(--display); font-size: 11px; font-weight: 600;
}
.badge.out { background: var(--ink-2); }
.card.sold-out .card-media img { opacity: .45; filter: grayscale(1); }
.card-body { display: flex; flex-direction: column; flex: 1; gap: 4px; padding: 4px 14px 14px; border-top: 1px solid var(--canvas); }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 10px; min-width: 0; }
.brand-tag {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0;
  font-family: var(--display); font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--ink);
  direction: ltr; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-tag::before { content: ""; width: 7px; height: 7px; flex: none; border-radius: 2px 2px 2px 1px; background: var(--red); }
.cat-tag { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-title { margin: 2px 0 0; font-size: 15px; font-weight: 600; line-height: 1.45; }
.card-title button { display: block; width: 100%; text-align: start; }
.card-title span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.card-title button:hover { color: var(--red); }
.model { margin: 0; font-family: var(--display); font-size: 11.5px; color: var(--muted); direction: ltr; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 10px; }
.price { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.price b { font-family: var(--display); font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.price b small { font-size: 12px; font-weight: 500; color: var(--muted); margin-inline-start: 3px; }
.price .per { font-size: 11px; color: var(--muted); }
.price .carton { font-size: 11.5px; color: var(--ink-2); margin-top: 3px; }
.price .ask { font-size: 13px; color: var(--muted); font-weight: 500; }

.cta { flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.unit-cap { font-size: 11px; font-weight: 600; line-height: 1; color: var(--muted); }
.stepper + .unit-cap { color: var(--red-deep); }
.add-btn {
  flex: none; width: 42px; height: 42px; border-radius: var(--tile);
  background: var(--red); color: #fff; display: grid; place-items: center;
  transition: background .2s, transform .2s var(--ease);
}
.add-btn svg { width: 20px; height: 20px; stroke-width: 2.4; }
.add-btn:hover { background: var(--red-deep); }
.add-btn:active { transform: scale(.92); }
.stepper {
  flex: none; display: inline-flex; align-items: center; height: 42px;
  border: 1.5px solid var(--red); border-radius: var(--tile); background: var(--red-soft); overflow: hidden;
}
.stepper button { width: 34px; height: 100%; display: grid; place-items: center; color: var(--red); }
.stepper button:hover { background: #f5d6d7; }
.stepper svg { width: 16px; height: 16px; stroke-width: 2.6; }
.stepper output, .stepper input {
  min-width: 26px; width: 34px; text-align: center; font-family: var(--display); font-weight: 700; color: var(--red-deep);
  border: 0; background: none; outline: none; padding: 0; -moz-appearance: textfield;
}
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }

@media (max-width: 480px) {
  .card-body { padding: 2px 10px 10px; }
  .card-title { font-size: 13.5px; }
  .price b { font-size: 17px; }
  .add-btn, .stepper { height: 38px; }
  .add-btn { width: 38px; }
  .stepper button { width: 28px; }
  .stepper output { min-width: 20px; width: 24px; }
  .card-foot { flex-wrap: wrap; }
  .cat-tag { display: none; }
}

/* عرض القائمة */
.grid.list { grid-template-columns: 1fr; gap: 8px; }
.grid.list .card { flex-direction: row; align-items: center; border-radius: var(--r-md); }
.grid.list .card:hover { transform: none; }
.grid.list .card-media { width: 92px; flex: none; }
.grid.list .card-media img { padding: 6px; }
.grid.list .badge { top: 6px; inset-inline-start: 6px; padding: 1px 7px; font-size: 10px; }
.grid.list .card-body { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 2px 16px; padding: 10px 14px; border-top: 0; border-inline-start: 1px solid var(--canvas); }
.grid.list .card-info { flex: 1; min-width: 200px; }
.grid.list .card-meta { padding-top: 0; justify-content: flex-start; }
.grid.list .card-title span { min-height: 0; -webkit-line-clamp: 1; }
.grid.list .card-foot { margin-top: 0; padding-top: 0; gap: 16px; }
.grid.list .price { align-items: flex-end; }
@media (max-width: 640px) {
  .grid.list .card-media { width: 78px; }
  .grid.list .card-body { padding: 8px 10px; }
  .grid.list .card-info { min-width: 0; flex-basis: 100%; }
  .grid.list .card-title span { -webkit-line-clamp: 2; }
  .grid.list .card-foot { flex-basis: 100%; justify-content: space-between; }
  .grid.list .price { align-items: flex-start; }
}

/* كروت فاضية لحد ما الأسعار تتحمّل */
.card.skeleton { pointer-events: none; }
.card.skeleton .card-media, .card.skeleton i {
  background: linear-gradient(90deg, var(--canvas) 0%, #ebe7e5 50%, var(--canvas) 100%) 0 0 / 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
.card.skeleton .card-body { gap: 8px; padding: 14px; }
.card.skeleton i { display: block; height: 12px; border-radius: 6px; }
.card.skeleton i:nth-child(1) { width: 40%; }
.card.skeleton i:nth-child(2) { width: 85%; }
.card.skeleton i:nth-child(3) { width: 55%; height: 20px; margin-top: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ظهور الكروت */
.reveal { animation: rise .5s var(--ease) both; animation-delay: var(--d, 0ms); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* ---------- حالة فاضية ---------- */
.empty { text-align: center; padding: 64px 16px; background: var(--paper); border: 1px dashed var(--line-2); border-radius: var(--r-lg); }
.empty svg { width: 56px; height: 56px; stroke: none; margin-inline: auto; }
.empty svg rect { fill: var(--canvas); }
.empty svg path { fill: var(--line-2); }
.empty h2 { font-family: var(--display); font-size: 20px; margin: 16px 0 4px; }
.empty p { margin: 0 0 20px; color: var(--muted); }

/* ---------- أزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding-inline: 20px; border-radius: var(--r-md);
  font-family: var(--display); font-weight: 600; font-size: 15px; text-decoration: none; white-space: nowrap;
  transition: background .2s, border-color .2s, transform .15s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-deep); }
.btn.dark { background: var(--ink); color: #fff; }
.btn.dark:hover { background: #000; }
.btn.ghost { background: var(--paper); border: 1.5px solid var(--line-2); color: var(--ink); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.wa { background: var(--wa); color: #fff; }
.btn.wa:hover { background: var(--wa-deep); }
.btn.wa svg { width: 22px; height: 22px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- الفوتر ---------- */
.footer { background: var(--paper); border-top: 1px solid var(--line); padding-block: 32px calc(32px + env(safe-area-inset-bottom)); }
.footer-in { display: grid; gap: 16px; justify-items: start; }
.footer-logo { height: 54px; width: auto; }
.contacts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 20px; }
.contacts a, .contacts span { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); text-decoration: none; font-size: 14px; }
.contacts a:hover { color: var(--red); }
.contacts svg { color: var(--red); }
.copy { margin: 0; font-size: 12.5px; color: var(--muted); }
@media (min-width: 768px) { .footer-in { grid-template-columns: auto 1fr; align-items: center; column-gap: 32px; } .copy { grid-column: 1 / -1; } }

/* ---------- خلفية معتمة ---------- */
.scrim { position: fixed; inset: 0; z-index: 55; background: rgba(20, 17, 18, .5); backdrop-filter: blur(2px); animation: fade .25s both; }
@keyframes fade { from { opacity: 0; } }

/* ---------- نافذة المنتج ---------- */
dialog { padding: 0; border: 0; color: var(--ink); background: var(--paper); }
dialog::backdrop { background: rgba(20, 17, 18, .55); backdrop-filter: blur(3px); }
.modal {
  width: min(1000px, calc(100% - 32px)); max-height: calc(100dvh - 48px);
  border-radius: 24px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal[open] { animation: pop .35s var(--ease); }
.modal[open]::backdrop { animation: fade .3s both; }
@keyframes pop { from { opacity: 0; transform: translateY(18px) scale(.98); } }
.modal-in { display: flex; flex-direction: column; max-height: calc(100dvh - 48px); overflow-y: auto; overscroll-behavior: contain; }
.pm-top { display: grid; }
.pm-media { position: relative; background: #fff; border-bottom: 1px solid var(--line); }
.pm-media img { width: 100%; aspect-ratio: 1; object-fit: contain; padding: 6%; max-height: 62vh; }
.pm-nav { position: absolute; inset-inline: 10px; top: 50%; display: flex; justify-content: space-between; transform: translateY(-50%); pointer-events: none; }
.pm-nav button {
  pointer-events: auto; width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255, 255, 255, .92); border: 1px solid var(--line); display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
}
.pm-nav button:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.pm-nav button[disabled] { visibility: hidden; }
.pm-close {
  position: absolute; top: 12px; inset-inline-end: 12px; z-index: 2; width: 42px; height: 42px; border-radius: 50%;
  background: var(--ink); color: #fff; display: grid; place-items: center;
}
.pm-close:hover { background: var(--red); }
.pm-pos { position: absolute; bottom: 12px; inset-inline-start: 14px; font-family: var(--display); font-size: 12px; color: var(--muted); }
.pm-info { padding: 22px 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.pm-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pm-tags button { font-size: 13px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); }
.pm-tags button:hover { border-color: var(--ink); }
.pm-tags .brand-tag { font-size: 13px; padding: 4px 12px; border-radius: 999px; background: var(--canvas); border: 1px solid transparent; }
.pm-info h2 { margin: 0; font-family: var(--display); font-weight: 700; font-size: clamp(20px, 3.2vw, 28px); line-height: 1.35; }
.pm-model { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.pm-model code { font-family: var(--display); font-size: 14px; color: var(--ink); background: var(--canvas); border-radius: 6px; padding: 2px 8px; direction: ltr; }
.pm-model button { color: var(--red); font-size: 13px; font-weight: 600; }
.pm-prices { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.pm-price { padding: 14px 16px; border-radius: var(--r-md); background: var(--canvas); }
.pm-price span { display: block; font-size: 12.5px; color: var(--muted); }
.pm-price b { font-family: var(--display); font-size: 26px; font-weight: 700; }
.pm-price b small { font-size: 13px; color: var(--muted); font-weight: 500; margin-inline-start: 4px; }
.pm-price.main { background: var(--ink); color: #fff; }
.pm-price.main span, .pm-price.main b small { color: rgba(255, 255, 255, .6); }
.pm-desc { margin: 0; color: var(--ink-2); white-space: pre-line; }
.unit-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.unit-seg button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 14px; text-align: start;
  border: 1.5px solid var(--line-2); border-radius: var(--r-md); background: var(--paper);
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.unit-seg button:hover { border-color: var(--ink); }
.unit-seg button b { font-family: var(--display); font-size: 15px; }
.unit-seg button small { font-size: 12.5px; color: var(--muted); }
.unit-seg button[aria-checked="true"] { border-color: var(--red); background: var(--red-soft); box-shadow: inset 0 0 0 1px var(--red); }
.unit-seg button[aria-checked="true"] b { color: var(--red-deep); }
.pm-line-total { margin: -4px 0 0; font-size: 14px; color: var(--ink-2); }
.pm-line-total b { font-family: var(--display); color: var(--ink); }
.pm-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.pm-actions .stepper { height: 48px; }
.pm-actions .stepper button { width: 42px; }
.pm-actions .stepper input { width: 44px; font-size: 16px; }
.pm-actions .btn.primary { flex: 1; min-width: 160px; }
.pm-links { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; }
.pm-links a, .pm-links button { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.pm-links a:hover, .pm-links button:hover { color: var(--red); }
.pm-links svg { width: 18px; height: 18px; }
.pm-related { padding: 20px 20px 24px; border-top: 1px solid var(--line); background: var(--canvas); }
.pm-related h3 { margin: 0 0 12px; font-family: var(--display); font-size: 15px; }
.mini-row { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 6px; }
.mini {
  flex: none; width: 138px; text-align: start; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md);
  overflow: hidden; transition: border-color .2s, transform .2s var(--ease);
}
.mini:hover { border-color: var(--ink); transform: translateY(-2px); }
.mini img { width: 100%; aspect-ratio: 1; object-fit: contain; padding: 10px; background: #fff; }
.mini span { display: block; padding: 6px 10px 0; font-size: 12.5px; line-height: 1.4; height: 3.2em; overflow: hidden; }
.mini b { display: block; padding: 4px 10px 10px; font-family: var(--display); font-size: 14px; }
@media (min-width: 768px) {
  .pm-top { grid-template-columns: 1.05fr 1fr; }
  .pm-media { border-bottom: 0; border-inline-end: 1px solid var(--line); }
  .pm-media img { max-height: none; height: 100%; }
  .pm-info { padding: 32px 30px; justify-content: center; }
  .pm-info { padding-top: 40px; }
}
@media (max-width: 767px) {
  .modal { width: 100%; max-width: 100%; max-height: 94dvh; margin: auto 0 0; border-radius: 22px 22px 0 0; }
  .modal-in { max-height: 94dvh; }
  .modal[open] { animation: slideUp .38s var(--ease); }
  .pm-info { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
}
@keyframes slideUp { from { transform: translateY(100%); } }

/* ---------- سلة الطلب ---------- */
.drawer {
  width: min(440px, 100%); max-width: 100%; height: 100dvh; max-height: 100dvh;
  margin: 0 auto 0 0; /* بتفتح من الشمال */
  border-radius: 0; box-shadow: var(--shadow-lg);
}
.drawer[open] { animation: slideIn .38s var(--ease); }
.drawer[open]::backdrop { animation: fade .3s both; }
@keyframes slideIn { from { transform: translateX(-100%); } }
.drawer-in { height: 100%; display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer-head::before { content: ""; position: absolute; top: 0; inset-inline: 0; height: 3px; background: var(--red); }
.drawer-head h2 { margin: 0; font-family: var(--display); font-size: 20px; }
.drawer-head h2 span { font-size: 14px; color: var(--muted); font-weight: 500; }
.drawer-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 8px 18px; }
.line { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding-block: 14px; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line img { width: 64px; height: 64px; object-fit: contain; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; padding: 4px; cursor: pointer; }
.line-top { display: flex; gap: 8px; align-items: flex-start; }
.line-name { flex: 1; margin: 0; font-size: 14px; font-weight: 600; line-height: 1.45; }
.line-out { display: block; margin-top: 2px; font-size: 12px; font-weight: 600; color: var(--red); }
.line-meta { margin: 2px 0 8px; font-size: 12px; color: var(--muted); }
.line-meta bdi { font-family: var(--display); }
.line-remove { color: var(--muted); width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.line-remove:hover { color: var(--red); background: var(--red-soft); }
.line-remove svg { width: 16px; height: 16px; }
.unit-mini { display: inline-flex; padding: 2px; margin-bottom: 8px; background: var(--canvas); border: 1px solid var(--line); border-radius: 9px; }
.unit-mini button { height: 28px; padding-inline: 12px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.unit-mini button[aria-checked="true"] { background: var(--ink); color: #fff; }
.line-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.line-bottom .stepper { height: 36px; }
.line-bottom .stepper button { width: 32px; }
.line-total { font-family: var(--display); font-weight: 700; font-size: 15px; }
.line-total small { font-size: 11px; color: var(--muted); font-weight: 500; }
.drawer-foot { padding: 14px 18px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--canvas); display: grid; gap: 12px; }
.buyer { display: grid; gap: 8px; padding: 14px 0 18px; border-top: 1px solid var(--line); }
.buyer label { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.buyer input, .buyer textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--paper);
  outline: none; font-size: 14px; color: var(--ink); resize: vertical;
}
.buyer input:focus, .buyer textarea:focus { border-color: var(--ink); }
.buyer-title { margin: 0 0 2px; font-family: var(--display); font-size: 15px; }
.buyer-title small { display: block; margin-top: 2px; font-family: var(--body); font-size: 12px; font-weight: 400; color: var(--muted); }
.buyer label b { color: var(--red); }
.buyer #buyerPhone { direction: ltr; text-align: right; }
.buyer .invalid { border-color: var(--red); background: var(--red-soft); }
.buyer .invalid:focus { border-color: var(--red); }
.order-note { margin: 0; padding: 8px 12px; border-radius: var(--r-sm); background: var(--red-soft); color: var(--red-deep); font-size: 13px; }
.total-row { display: flex; align-items: baseline; justify-content: space-between; }
.total-row span { font-size: 14px; color: var(--muted); }
.total-row b { font-family: var(--display); font-size: 26px; }
.total-row b small { font-size: 14px; color: var(--muted); font-weight: 500; margin-inline-start: 4px; }
.drawer-actions { display: flex; gap: 8px; }
.drawer-actions .btn { flex: 1; padding-inline: 14px; }
.drawer-actions .btn.wa:not([hidden]) + .btn { flex: none; }
.drawer-actions .btn { min-width: 0; }
#clearOrder { justify-self: start; margin-top: 4px; }
.drawer-empty { text-align: center; padding: 56px 16px; color: var(--muted); }
.drawer-empty svg { width: 54px; height: 54px; color: var(--line-2); margin: 0 auto 12px; stroke-width: 1.4; }
.drawer-empty h3 { margin: 0 0 4px; color: var(--ink); font-family: var(--display); font-size: 17px; }
.drawer-empty p { margin: 0 0 18px; }

/* ---------- رسالة سريعة ---------- */
.toast {
  position: fixed; z-index: 100; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  display: inline-flex; align-items: center; gap: 10px; max-width: calc(100% - 32px);
  padding: 11px 18px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-md); transition: opacity .25s, transform .3s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast::before { content: ""; width: 8px; height: 8px; flex: none; border-radius: 2px; background: var(--red); }
.noscript { text-align: center; padding: 20px; background: var(--red-soft); color: var(--red-deep); }

.print-head { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}

/* ---------- الطباعة / PDF ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 11px; }
  .topbar, .hero, .rail, .filters, .toolbar, .footer, .toast, .scrim, dialog, .add-btn, .stepper, .unit-cap { display: none !important; }
  .print-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 10px; margin-bottom: 12px; border-bottom: 2px solid var(--red); }
  .print-head img { height: 44px; width: auto; }
  .print-head div { text-align: left; }
  .print-head strong { display: block; font-family: var(--display); font-size: 18px; }
  .print-head span { font-size: 11px; color: var(--muted); }
  .layout { display: block; padding: 0; }
  .wrap { padding: 0; max-width: none; }
  .grid, .grid.list { grid-template-columns: repeat(4, 1fr) !important; gap: 8px; }
  .grid.list .card { flex-direction: column; }
  .grid.list .card-media { width: 100%; }
  .grid.list .card-body { flex-direction: column; align-items: stretch; }
  .card { break-inside: avoid; box-shadow: none !important; transform: none !important; border-color: #ddd; border-radius: 10px; animation: none !important; }
  .card-media img { padding: 4%; transform: none !important; }
  .card-title { font-size: 11px; }
  .card-title span { min-height: 0; }
  .price b { font-size: 14px; }
  .cat-tag { display: block; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
