/* ============================================================
   Suda Cart — Design System (base.css)
   Bilingual AR/EN · RTL-first · Marketplace UI
   ============================================================ */

:root {
  /* Brand — Suda violet */
  --brand-700: #4c2bd6;
  --brand-600: #6c4cf1;
  --brand-500: #8367f5;
  --brand-300: #b9a8fb;
  --brand-100: #e9e3ff;
  --brand-50:  #f4f1ff;

  /* Ink / dark */
  --ink-950: #120e33;
  --ink-900: #17123b;
  --ink-800: #221b56;
  --ink-700: #332a6e;

  /* Accent amber (deals / CTAs) */
  --amber-600: #e8820a;
  --amber-500: #ff9f1c;
  --amber-100: #fff1d9;

  /* Semantic */
  --green-600: #0e9f6e;
  --green-100: #d8f5e9;
  --red-600:   #e02424;
  --red-100:   #fde3e3;
  --blue-600:  #1f7ae0;
  --blue-100:  #e1eefc;

  /* Surfaces */
  --bg:       #f5f5fb;
  --surface:  #ffffff;
  --line:     #e8e7f4;
  --line-2:   #d9d7ee;
  --text:     #24203f;
  --muted:    #6f6c92;
  --muted-2:  #9b98b8;

  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius:    14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(23, 18, 59, .06);
  --shadow-sm: 0 2px 8px rgba(23, 18, 59, .07);
  --shadow-md: 0 6px 20px rgba(23, 18, 59, .10);
  --shadow-lg: 0 14px 40px rgba(23, 18, 59, .14);
  --shadow-brand: 0 8px 24px rgba(108, 76, 241, .32);

  --grad-brand: linear-gradient(135deg, #6c4cf1 0%, #4c2bd6 100%);
  --grad-ink:   linear-gradient(135deg, #17123b 0%, #2a1d75 55%, #4527c4 100%);
  --grad-amber: linear-gradient(135deg, #ffb020 0%, #f07d0a 100%);

  --font-ar: 'Tajawal', 'Segoe UI', Tahoma, Arial, sans-serif;
  --font-en: 'Outfit', 'Segoe UI', Tahoma, Arial, sans-serif;

  --container: 1280px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-ar);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
html[lang="en"] body { font-family: var(--font-en); }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: 0; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 800; }
p { margin: 0 0 .6em; }
ul { margin: 0; padding: 0; list-style: none; }
table { border-collapse: collapse; width: 100%; }
:focus-visible { outline: 3px solid var(--brand-300); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--brand-100); }

/* Direction-aware arrows & icons */
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

/* ---------- Layout helpers ---------- */
.container { max-width: var(--container); margin-inline: auto; padding-inline: 20px; }
.flex { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.bold { font-weight: 700; }
.center { text-align: center; }
.hide-mobile { display: initial; }
@media (max-width: 760px) { .hide-mobile { display: none !important; } }

/* ---------- Icons ---------- */
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.ic.fill { fill: currentColor; stroke: none; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 26px; height: 26px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-pill);
  font-weight: 700; font-size: 14.5px; line-height: 1.2;
  border: 1.5px solid transparent;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, color .2s ease, border-color .2s ease;
  white-space: nowrap; user-select: none;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--grad-brand); color: #fff; box-shadow: var(--shadow-brand); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-amber { background: var(--grad-amber); color: #3d2500; box-shadow: 0 8px 22px rgba(232, 130, 10, .35); }
.btn-amber:hover { filter: brightness(1.05); }
.btn-dark { background: var(--ink-900); color: #fff; }
.btn-dark:hover { background: var(--ink-800); }
.btn-outline { border-color: var(--line-2); background: var(--surface); color: var(--text); }
.btn-outline:hover { border-color: var(--brand-600); color: var(--brand-600); background: var(--brand-50); }
.btn-ghost { color: var(--muted); padding-inline: 12px; }
.btn-ghost:hover { color: var(--brand-600); background: var(--brand-50); }
.btn-soft { background: var(--brand-50); color: var(--brand-700); }
.btn-soft:hover { background: var(--brand-100); }
.btn-danger { background: var(--red-100); color: var(--red-600); }
.btn-danger:hover { background: var(--red-600); color: #fff; }
.btn-green { background: var(--green-600); color: #fff; }
.btn-green:hover { filter: brightness(1.08); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 30px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: 42px; height: 42px; border-radius: 50%; }

/* ---------- Badges & pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 10px; border-radius: var(--radius-pill);
  font-size: 11.5px; font-weight: 800; line-height: 1.7; white-space: nowrap;
}
.badge-red    { background: var(--red-600); color: #fff; }
.badge-green  { background: var(--green-600); color: #fff; }
.badge-amber  { background: var(--amber-500); color: #3d2500; }
.badge-brand  { background: var(--brand-600); color: #fff; }
.badge-ink    { background: var(--ink-900); color: #fff; }
.badge-soft   { background: var(--brand-50); color: var(--brand-700); }
.badge-soft-green { background: var(--green-100); color: var(--green-600); }
.badge-soft-amber { background: var(--amber-100); color: var(--amber-600); }
.badge-soft-red   { background: var(--red-100); color: var(--red-600); }
.badge-soft-blue  { background: var(--blue-100); color: var(--blue-600); }
.badge-soft-gray  { background: #ececf5; color: var(--muted); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--radius-pill);
  background: var(--surface); border: 1px solid var(--line);
  font-size: 13.5px; font-weight: 600; color: var(--text);
  transition: all .18s ease;
}
.pill:hover { border-color: var(--brand-500); color: var(--brand-700); }
.pill.on { background: var(--grad-brand); color: #fff; border-color: transparent; box-shadow: var(--shadow-brand); }

/* ---------- Forms ---------- */
.input, .select, textarea.input {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 14px; font-weight: 500;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.input:focus, .select:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: 0 0 0 4px rgba(108, 76, 241, .13);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236f6c92' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-inline-end: 14px; padding-inline-start: 36px;
}
html[dir="rtl"] .select { background-position: right 12px center; padding-inline: 36px 14px; }
.label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.field { margin-bottom: 16px; }

.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; padding-block: 4px; }
.check input { accent-color: var(--brand-600); width: 17px; height: 17px; cursor: pointer; }

/* ---------- Stars / rating ---------- */
.stars { display: inline-flex; align-items: center; gap: 1.5px; color: #ffb020; direction: ltr; }
.stars .ic { width: 15px; height: 15px; }
.stars .off { color: #d9d7ee; }

/* ---------- Price ---------- */
.price { display: inline-flex; align-items: baseline; gap: 7px; font-weight: 800; }
.price .now { font-size: 18px; color: var(--text); }
.price .cur { font-size: 12px; font-weight: 700; color: var(--muted); }
.price .old { font-size: 13px; font-weight: 600; color: var(--muted-2); text-decoration: line-through; }
.price.hot .now { color: var(--amber-600); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
.card-pad { padding: 20px; }

/* ---------- Product card ---------- */
.pcard {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); overflow: hidden;
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.pcard:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); border-color: var(--brand-100); }
.pcard .pimg {
  position: relative; aspect-ratio: 1 / .92; overflow: hidden;
  background: linear-gradient(160deg, #f3f1ff, #eceafc);
}
.pcard .pimg img { width: 100%; height: 100%; object-fit: cover; transition: transform .45s ease; }
.pcard:hover .pimg img { transform: scale(1.06); }
.pcard .ptags { position: absolute; top: 12px; inset-inline-start: 12px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; z-index: 2; }
.pcard .pwish {
  position: absolute; top: 10px; inset-inline-end: 10px; z-index: 2;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255, 255, 255, .92); color: #9b98b8;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm); backdrop-filter: blur(4px);
  transition: all .18s ease;
}
.pcard .pwish:hover { color: var(--red-600); transform: scale(1.1); }
.pcard .pwish.on { color: var(--red-600); background: #fff; }
.pcard .pbody { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 16px; flex: 1; }
.pcard .pvendor { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; color: var(--brand-600); }
.pcard .pname { font-size: 14.5px; font-weight: 700; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.pcard .pname a:hover { color: var(--brand-600); }
.pcard .pmeta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 6px; }
.pcard .sold { font-size: 11.5px; color: var(--muted-2); font-weight: 600; }
.pcard .pcart {
  margin-top: 10px; width: 100%; justify-content: center;
  background: var(--brand-50); color: var(--brand-700);
  border-radius: var(--radius-sm); padding: 9px 12px;
}
.pcard .pcart:hover { background: var(--grad-brand); color: #fff; box-shadow: var(--shadow-brand); }

/* product grid */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 18px; }

/* ---------- Section scaffolding ---------- */
.section { padding: 34px 0 8px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.section-title { display: flex; align-items: center; gap: 12px; }
.section-title .bar { width: 6px; height: 26px; border-radius: 3px; background: var(--grad-brand); }
.section-title h2 { font-size: 21px; }
.section-title .sub { font-size: 13px; color: var(--muted); font-weight: 500; }
.link-more { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13.5px; color: var(--brand-600); }
.link-more:hover { text-decoration: underline; }

/* ---------- Horizontal scroller ---------- */
.hscroll { display: flex; gap: 16px; overflow-x: auto; padding: 6px 4px 18px; scroll-snap-type: x mandatory; }
.hscroll > * { scroll-snap-align: start; flex: 0 0 auto; }
.hscroll::-webkit-scrollbar { height: 8px; }
.hscroll::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; }
.hscroll::-webkit-scrollbar-track { background: transparent; }

/* ---------- Tables (panels) ---------- */
.tbl { width: 100%; font-size: 13.5px; }
.tbl th {
  text-align: start; font-size: 12px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .3px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .15s ease; }
.tbl tbody tr:hover { background: #faf9ff; }

/* ---------- Misc ---------- */
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; color: #fff; background: var(--grad-brand);
}
.vbadge { display: inline-flex; color: var(--brand-600); }
.vbadge .ic { width: 15px; height: 15px; }

.progress { height: 7px; border-radius: 99px; background: #edeaf8; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: var(--grad-brand); }

/* Arabic geometric ornament (8-point star lattice) */
.pattern-star {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='84' height='84' viewBox='0 0 84 84'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.13' stroke-width='1.1'%3E%3Cpath d='M42 10 74 42 42 74 10 42Z'/%3E%3Cpath d='M22 22h40v40H22z'/%3E%3Cpath d='M42 30 54 42 42 54 30 42Z'/%3E%3C/g%3E%3C/svg%3E");
}
.pattern-star-dark {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='84' height='84' viewBox='0 0 84 84'%3E%3Cg fill='none' stroke='%236c4cf1' stroke-opacity='.12' stroke-width='1.1'%3E%3Cpath d='M42 10 74 42 42 74 10 42Z'/%3E%3Cpath d='M22 22h40v40H22z'/%3E%3Cpath d='M42 30 54 42 42 54 30 42Z'/%3E%3C/g%3E%3C/svg%3E");
}

/* divider with ornament */
.ornate { display: flex; align-items: center; gap: 14px; color: var(--brand-500); }
.ornate::before, .ornate::after { content: ""; height: 1px; flex: 1; background: linear-gradient(to var(--grad-x, right), transparent, var(--line-2), transparent); }

/* ---------- Animations ---------- */
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes pulse-dot { 0% { box-shadow: 0 0 0 0 rgba(255, 95, 95, .5); } 70% { box-shadow: 0 0 0 7px rgba(255, 95, 95, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 95, 95, 0); } }
@keyframes fade-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.reveal { opacity: 0; }
.reveal.in { animation: fade-up .6s ease forwards; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .reveal { opacity: 1; }
}

/* wishlist active state (filled heart) */
.pwish.on .ic, [data-wish].on .ic { fill: currentColor; stroke: currentColor; }

/* graceful image fallback */
.imgerr { position: relative; }
.imgerr::after {
  content: "🛍️"; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; opacity: .45;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; z-index: 200;
  transform: translate(-50%, 16px);
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--ink-900); color: #fff;
  padding: 12px 22px; border-radius: 99px;
  font-size: 13.5px; font-weight: 700;
  box-shadow: 0 16px 40px rgba(9, 5, 35, .4);
  opacity: 0; visibility: hidden;
  transition: all .3s cubic-bezier(.2, .9, .3, 1.3);
  max-width: calc(100vw - 32px);
}
.toast .ic { width: 17px; height: 17px; color: #5eead4; stroke-width: 2.6; }
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  body { font-size: 14px; }
  .pgrid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .section { padding: 26px 0 4px; }
  .section-title h2 { font-size: 18px; }
  .pcard .pname { font-size: 13px; min-height: 2.8em; }
  .price .now { font-size: 15.5px; }
}
@media (max-width: 380px) {
  .pgrid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .container { padding-inline: 14px; }
}
