/* ═══════════════════════════════════════════════════════════════════════════
   styles.css — تصميم خفيف بلا أي إطار عمل (لا Bootstrap ولا Tailwind)
   الحجم المستهدف < 8KB لضمان رسم أوّل سريع.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg: #0b0f17;
  --surface: #131a26;
  --surface-2: #1a2333;
  --line: #24304a;
  --text: #e7edf7;
  --muted: #93a2bd;
  --brand: #ff5a3c;         /* برتقالي AliExpress */
  --brand-soft: #ff5a3c22;
  --accent: #37d3a0;
  --warn: #ffcc55;
  --danger: #ff6b6b;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fb; --surface: #ffffff; --surface-2: #f0f3f9; --line: #dde3ee;
    --text: #14203a; --muted: #5d6b87; --shadow: 0 6px 20px rgba(20, 32, 58, .08);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 "Segoe UI", "Noto Kufi Arabic", Tahoma, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; font-weight: 700; }

/* ───────── الشريط العلوي ───────── */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between;
  padding: 14px clamp(12px, 3vw, 32px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid; place-items: center; width: 44px; height: 44px; font-size: 22px;
  background: var(--brand-soft); border: 1px solid var(--brand); border-radius: 12px;
}
.brand h1 { font-size: 19px; }
.sub { margin: 0; font-size: 12.5px; color: var(--muted); }

.search { flex: 1 1 320px; max-width: 520px; }
.search input {
  width: 100%; padding: 11px 14px; font: inherit; font-size: 15px;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px;
}
.search input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

/* ───────── الألواح ───────── */

main { max-width: 1240px; margin: 0 auto; padding: 20px clamp(12px, 3vw, 32px) 60px; }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-title { font-size: 15px; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
.panel-head .panel-title { margin-bottom: 0; }

/* ───────── شرائح الفئات ───────── */

.categories { display: flex; flex-wrap: wrap; gap: 10px; }
.cat-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; font: inherit; font-size: 15px; font-weight: 600;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
  transition: transform .12s, border-color .12s, background .12s;
}
.cat-chip:hover { transform: translateY(-1px); border-color: var(--brand); }
.cat-chip.is-active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.cat-icon { font-size: 18px; }

/* ───────── القوائم المتتالية ───────── */

.facets {
  display: grid; gap: 12px; margin-top: 14px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

.facet { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.facet-label { font-size: 13px; font-weight: 600; color: var(--muted); }

.facet-select, .mini select, .mini input {
  width: 100%; padding: 10px 12px; font: inherit; font-size: 14.5px;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
  transition: border-color .12s;
}
.facet-select:hover:not(:disabled) { border-color: var(--brand); }
.facet-select:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.facet-select:disabled { opacity: .5; cursor: not-allowed; }

.facet-hint { font-size: 11.5px; color: var(--muted); min-height: 16px; }
.facet.is-locked .facet-hint { color: var(--warn); }

/* ───────── فلاتر إضافية ───────── */

.extra-filters {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: end;
  margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line);
}
.mini { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.mini input, .mini select { min-width: 120px; }

.toggle {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px;
  font-size: 13.5px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer; user-select: none;
}
.toggle input { accent-color: var(--brand); width: 16px; height: 16px; }

/* ───────── شرائح الاختيارات ───────── */

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; font: inherit; font-size: 13px;
  color: var(--text); background: var(--brand-soft);
  border: 1px solid var(--brand); border-radius: 999px; cursor: pointer;
}
.chip:hover { background: var(--brand); color: #fff; }
.chip-key { color: var(--muted); font-size: 11.5px; }
.chip:hover .chip-key { color: #ffffffcc; }
.chip-x { font-size: 11px; opacity: .8; }
.chip-clear { background: transparent; border-color: var(--line); color: var(--muted); }
.chip-clear:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ───────── تنبيه الإسقاط ───────── */

.notice {
  display: flex; gap: 9px; align-items: flex-start;
  margin-top: 14px; padding: 10px 13px; font-size: 13.5px;
  color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); border-radius: 10px;
}
.notice-icon { flex: none; }

/* ───────── الحالة والأداء ───────── */

.stats { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 13px; }
.stat-total strong { font-size: 16px; color: var(--brand); }
.stat-perf {
  padding: 3px 10px; border-radius: 999px; font-variant-numeric: tabular-nums;
  background: var(--surface-2); border: 1px solid var(--line);
}
.stat-perf.is-fast { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.stat-perf.is-slow { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.stat-mode { color: var(--muted); }

.status { min-height: 20px; margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.status.is-busy::after { content: ' ⏳'; }
.status.is-error { color: var(--danger); }

/* ───────── شبكة النتائج ───────── */

.results {
  display: grid; gap: 14px; margin-top: 14px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

.card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; transition: transform .14s, border-color .14s;
}
.card:hover { transform: translateY(-3px); border-color: var(--brand); }

.card-media { position: relative; display: block; aspect-ratio: 1; background: #0006; }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-ph {
  display: grid; place-items: center; width: 100%; height: 100%; font-size: 44px;
  background: linear-gradient(140deg, var(--surface) 0%, var(--surface-2) 100%);
}
.badge-off {
  position: absolute; inset-inline-start: 8px; top: 8px;
  padding: 2px 8px; font-size: 12px; font-weight: 700;
  color: #fff; background: var(--brand); border-radius: 999px;
}

.card-body { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px 12px; }
.card-title {
  font-size: 13.5px; line-height: 1.45; color: var(--text); text-decoration: none;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-title:hover { color: var(--brand); }
.card-price { display: flex; align-items: baseline; gap: 8px; }
.card-price strong { font-size: 17px; color: var(--brand); }
.card-price s { font-size: 12px; color: var(--muted); }
.card-meta { display: flex; flex-wrap: wrap; gap: 9px; font-size: 11.5px; color: var(--muted); }
.card-meta .ship { color: var(--accent); }
.card-meta .srch { color: var(--brand); cursor: help; }

.empty { grid-column: 1 / -1; padding: 46px 20px; text-align: center; color: var(--muted); }
.empty-icon { font-size: 40px; }
.muted { color: var(--muted); }

.btn-more, .btn-ghost {
  padding: 10px 18px; font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer;
}
.btn-more { display: block; width: 100%; margin-top: 16px; }
.btn-more:hover, .btn-ghost:hover { border-color: var(--brand); color: var(--brand); }

/* ───────── صندوق الشرح ───────── */

.how {
  padding: 14px 18px; font-size: 13.5px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.how summary { cursor: pointer; font-weight: 600; color: var(--text); }
.how ol { margin: 12px 0 0; padding-inline-start: 20px; }
.how li { margin-bottom: 6px; }
.how code {
  padding: 1px 6px; font-size: 12.5px; direction: ltr; display: inline-block;
  background: var(--surface-2); border-radius: 5px;
}

@media (max-width: 560px) {
  .facets { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .results { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
