/* ============================================================
   Qatarshopping — design tokens
   Concept: a family souq at dusk. Deep teal ink + Qatari maroon
   + brass lantern accents. Price tags read like market ledgers.
   ============================================================ */

:root {
  --pearl: #F1EDE4;
  --pearl-surface: #FFFFFF;
  --ink: #16333A;
  --ink-muted: rgba(22, 51, 58, 0.64);
  --border: rgba(22, 51, 58, 0.12);
  --maroon: #7A1330;
  --maroon-strong: #5A0E24;
  --brass: #C89B4A;
  --brass-soft: rgba(200, 155, 74, 0.16);
  --success: #3F7A5C;
  --danger: #A23B3B;
  --shadow: 0 8px 24px rgba(22, 51, 58, 0.08);

  --bg: var(--pearl);
  --surface: var(--pearl-surface);
  --text: var(--ink);
  --text-muted: var(--ink-muted);
  --line: var(--border);

  --font-display: 'Fraunces', 'Cairo', serif;
  --font-body: 'Inter', 'IBM Plex Sans Arabic', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
}

:root[data-theme="dark"] {
  --bg: #0B1E22;
  --surface: #123138;
  --text: #EDE7DA;
  --text-muted: rgba(237, 231, 218, 0.66);
  --line: rgba(237, 231, 218, 0.14);
  --brass-soft: rgba(200, 155, 74, 0.14);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

[dir="rtl"] :is(h1, h2, h3, h4, .brand-name) {
  font-family: 'Cairo', var(--font-display);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  transition: background-color .2s ease, color .2s ease;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 .5em;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(1.9rem, 3vw, 2.8rem); }
h2 { font-size: clamp(1.4rem, 2.2vw, 1.9rem); }
h3 { font-size: 1.2rem; }

a { color: inherit; text-decoration: none; }
p { margin: 0 0 1em; color: var(--text-muted); }

.container {
  max-width: 1180px;
  margin-inline: auto;
  padding-inline: 20px;
}

/* Signature motif: a serrated strip echoing the nine points of the
   Qatari flag's edge — used as a quiet structural divider. */
.serrated-strip {
  height: 10px;
  width: 100%;
  background:
    linear-gradient(135deg, var(--maroon) 25%, transparent 25%) 0 0/16px 16px,
    linear-gradient(-135deg, var(--maroon) 25%, transparent 25%) 0 0/16px 16px;
  background-color: var(--brass);
  opacity: .9;
}

/* ---------------- Header ---------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  padding-block: 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  margin-inline-end: auto;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--maroon);
  color: #F6EFE3;
  font-family: var(--font-display);
  font-weight: 700;
}
.main-nav {
  display: flex;
  gap: 22px;
  font-weight: 500;
}
.main-nav a { color: var(--text-muted); padding-block: 4px; border-bottom: 2px solid transparent; }
.main-nav a:hover { color: var(--text); border-color: var(--brass); }

.header-actions { display: flex; align-items: center; gap: 12px; }
.icon-toggle {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.icon-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .icon-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .icon-toggle .icon-moon { display: block; }

.lang-toggle {
  font-weight: 600;
  font-size: .92rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.lang-toggle:hover { border-color: var(--brass); }

.mobile-nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 34px;
  height: 34px;
  background: none;
  border: none;
  cursor: pointer;
}
.mobile-nav-toggle span { display: block; height: 2px; background: var(--text); border-radius: 2px; }
.mobile-nav { display: none; flex-direction: column; background: var(--surface); border-top: 1px solid var(--line); }
.mobile-nav a { padding: 12px 20px; border-bottom: 1px solid var(--line); }
.mobile-nav.open { display: flex; }

@media (max-width: 860px) {
  .main-nav, .header-actions .btn { display: none; }
  .mobile-nav-toggle { display: flex; }
}

/* ---------------- Buttons & form controls ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .1s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--maroon); color: #F8F1E6; }
.btn-primary:hover { background: var(--maroon-strong); }
.btn-outline { border-color: var(--line); color: var(--text); }
.btn-outline:hover { border-color: var(--brass); }
.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); }
.btn-block { width: 100%; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field { margin-bottom: 18px; }
.hint { font-size: .82rem; color: var(--text-muted); margin-top: 6px; }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="number"], input[type="search"], select, textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { min-height: 140px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------------- Alerts ---------------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: .92rem;
  border-inline-start: 4px solid;
}
.alert-success { background: rgba(63,122,92,.12); border-color: var(--success); color: var(--success); }
.alert-error { background: rgba(162,59,59,.1); border-color: var(--danger); color: var(--danger); }
.alert-info { background: var(--brass-soft); border-color: var(--brass); color: var(--text); }

/* ---------------- Hero / search bar ---------------- */
.hero {
  padding-block: 44px 28px;
  text-align: start;
}
.hero p.tagline { font-size: 1.05rem; margin-bottom: 24px; }
.search-shop {
  display: flex;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 8px;
  box-shadow: var(--shadow);
}
.search-shop input { border: none; box-shadow: none; }
.search-shop input:focus { outline: none; }

/* Category chip shelf — horizontal scroll strip */
.category-shelf {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-block: 18px 6px;
  margin-bottom: 8px;
  scrollbar-width: thin;
}
.chip {
  flex: 0 0 auto;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.chip.active, .chip:hover { border-color: var(--brass); color: var(--text); background: var(--brass-soft); }

/* ---------------- Listing grid & cards ---------------- */
.listing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
  margin-block: 24px 40px;
}
.listing-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .15s ease, box-shadow .15s ease;
}
.listing-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.listing-thumb {
  aspect-ratio: 4 / 3;
  background: var(--brass-soft);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.listing-thumb img { width: 100%; height: 100%; object-fit: cover; }
.listing-thumb .placeholder { color: var(--brass); font-family: var(--font-display); font-size: 2rem; }
.listing-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.listing-title { font-weight: 600; font-size: 1rem; }
.listing-meta { font-size: .8rem; color: var(--text-muted); }

/* Signature: price rendered like a market ledger tag with a die-cut hole */
.price-tag {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 6px 14px 6px 10px;
  background: var(--ink);
  color: #F3E9D2;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: .92rem;
  border-radius: 3px 10px 10px 3px;
  position: relative;
}
:root[data-theme="dark"] .price-tag { background: var(--brass); color: var(--ink); }
[dir="rtl"] .price-tag { border-radius: 10px 3px 3px 10px; }
.price-tag::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bg);
}
.badge-sold {
  align-self: flex-start;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 3px 8px;
  border-radius: 999px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state h3 { color: var(--text); }

/* ---------------- Listing detail page ---------------- */
.listing-detail { display: grid; grid-template-columns: 1.1fr .9fr; gap: 36px; padding-block: 30px 50px; }
@media (max-width: 800px) { .listing-detail { grid-template-columns: 1fr; } }
.gallery-main { border-radius: var(--radius-lg); overflow: hidden; aspect-ratio: 4/3; background: var(--brass-soft); display: grid; place-items: center; }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.gallery-thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); cursor: pointer; }
.detail-panel .price-tag { font-size: 1.2rem; padding: 10px 20px 10px 14px; margin-block: 10px 18px; }
.detail-meta-row { display: flex; justify-content: space-between; padding-block: 10px; border-bottom: 1px solid var(--line); font-size: .92rem; }
.detail-meta-row span:first-child { color: var(--text-muted); }
.seller-box { margin-top: 24px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }

/* ---------------- Forms / auth pages ---------------- */
.auth-wrap { max-width: 440px; margin: 50px auto; padding: 34px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.auth-wrap h1 { text-align: center; }
.auth-switch { text-align: center; margin-top: 18px; font-size: .92rem; color: var(--text-muted); }

.form-card { max-width: 720px; margin-inline: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 30px; box-shadow: var(--shadow); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------------- Messages / chat ---------------- */
.conversations-list { display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.conversation-row { display: flex; gap: 12px; align-items: center; padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.conversation-row:last-child { border-bottom: none; }
.conversation-row:hover { background: var(--brass-soft); }
.conversation-row .thumb { width: 46px; height: 46px; border-radius: var(--radius-sm); object-fit: cover; background: var(--brass-soft); flex-shrink: 0; }
.conversation-meta { flex: 1; min-width: 0; }
.conversation-meta .name { font-weight: 600; }
.conversation-meta .snippet { font-size: .85rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-thread { display: flex; flex-direction: column; gap: 10px; padding: 20px 0; max-height: 55vh; overflow-y: auto; }
.chat-bubble { max-width: 70%; padding: 10px 14px; border-radius: var(--radius-md); font-size: .93rem; }
.chat-bubble.mine { align-self: flex-end; background: var(--maroon); color: #F8F1E6; border-end-end-radius: 4px; }
.chat-bubble.theirs { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-end-start-radius: 4px; }
[dir="rtl"] .chat-bubble.mine { align-self: flex-start; }
[dir="rtl"] .chat-bubble.theirs { align-self: flex-end; }
.chat-form { display: flex; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.chat-form textarea { min-height: 46px; }

/* ---------------- Admin ---------------- */
.admin-grid { display: grid; grid-template-columns: 220px 1fr; gap: 30px; padding-block: 30px 60px; }
@media (max-width: 760px) { .admin-grid { grid-template-columns: 1fr; } }
.admin-side a { display: block; padding: 10px 14px; border-radius: var(--radius-sm); color: var(--text-muted); font-weight: 600; margin-bottom: 4px; }
.admin-side a.active, .admin-side a:hover { background: var(--brass-soft); color: var(--text); }
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.data-table th, .data-table td { padding: 12px 14px; text-align: start; border-bottom: 1px solid var(--line); font-size: .9rem; }
.data-table th { background: var(--brass-soft); font-weight: 700; }
.data-table tr:last-child td { border-bottom: none; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.pill-pending { background: rgba(200,155,74,.2); color: #8a6a24; }
.pill-approved { background: rgba(63,122,92,.15); color: var(--success); }
.pill-rejected, .pill-suspended { background: rgba(162,59,59,.12); color: var(--danger); }
.inline-form { display: inline; }
.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------- Footer ---------------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 40px; padding-block: 26px; }
.footer-inner { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.footer-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-family: var(--font-display); }
.footer-note { font-size: .85rem; margin: 0; }
