/* Nassib Market : styles. Propriétés logiques (inline-start/end) pour que l'arabe en RTL fonctionne sans surcharge. */
:root {
  --red: #E53238; --blue: #0064D2; --yellow: #F5A623; --green: #86B817; --slate: #5A6683;
  --bg: #F6F7FA; --surface: #FFFFFF; --fg: #1B2233; --muted: #5A6683; --line: #E1E5EE; --chip: #EAF1FB;
  --shadow: 0 1px 2px rgba(20,30,60,.06), 0 8px 22px rgba(20,30,60,.08);
  --display: 'Bricolage Grotesque', 'Trebuchet MS', sans-serif;
  --body: 'DM Sans', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0F1420; --surface: #171E2E; --fg: #EEF1F8; --muted: #9DA8C2; --line: #2A3350; --chip: #1C2A47; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark; }
}
:root[dir="rtl"] { --display: 'Noto Sans Arabic', 'DM Sans', sans-serif; --body: 'Noto Sans Arabic', 'DM Sans', sans-serif; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 var(--body); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: progress; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--display); line-height: 1.2; margin: 0; text-wrap: balance; }
.wrap { max-width: 1240px; margin-inline: auto; padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); }
#view { padding-block: 8px 40px; min-height: 60vh; }

/* En-tête */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.hdr { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding-block: 12px 8px; }
.logo { font-family: var(--display); font-weight: 800; font-size: 32px; letter-spacing: -1px; line-height: 1; display: flex; align-items: baseline; gap: 8px; direction: ltr; color: var(--fg); }
.logo:hover { text-decoration: none; }
.letters b:nth-child(1), .letters b:nth-child(5) { color: var(--red); }
.letters b:nth-child(2), .letters b:nth-child(6) { color: var(--blue); }
.letters b:nth-child(3) { color: var(--yellow); }
.letters b:nth-child(4) { color: var(--green); }
.logo small { font: 700 11px var(--body); letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }
.search { flex: 1 1 300px; display: flex; min-width: 0; border: 2px solid var(--fg); border-radius: 999px; overflow: hidden; background: var(--surface); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 10px 16px; outline: 0; }
.search select { border: 0; border-inline-start: 1px solid var(--line); background: transparent; padding-inline: 10px; max-width: 150px; }
.search button { border: 0; background: var(--blue); color: #fff; font-weight: 700; padding-inline: 22px; }
.hbtns { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; border: 1.5px solid var(--blue); color: var(--blue); background: transparent; border-radius: 999px; padding: 8px 18px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.btn:hover { text-decoration: none; background: var(--chip); }
.btn.solid { background: var(--blue); color: #fff; }
.btn.solid:hover { filter: brightness(1.1); background: var(--blue); }
.btn.ghost { border-color: var(--line); color: var(--fg); }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.wide { width: 100%; }
.rail { display: flex; gap: 8px; overflow-x: auto; padding-block: 4px 12px; scrollbar-width: thin; }
.rail a { flex: none; border: 1px solid var(--line); border-block-end: 3px solid var(--cc); background: var(--surface); border-radius: 10px; padding: 5px 14px; color: var(--fg); font-weight: 500; }
.rail a:hover { background: var(--chip); text-decoration: none; }

/* Accueil */
.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-block: 18px 22px; }
.hero > div { border-radius: 18px; padding: 26px 28px; min-width: 0; }
.h1 { background: var(--blue); color: #fff; position: relative; overflow: hidden; }
.h1 h1 { font-size: clamp(26px, 4vw, 42px); letter-spacing: -.5px; max-width: 16ch; margin-block-end: 10px; }
.h1 p { margin: 0 0 18px; max-width: 46ch; opacity: .94; }
.h1 h1, .h1 p, .h1 .cta { position: relative; z-index: 1; }
.cta { display: flex; gap: 10px; flex-wrap: wrap; }
.h1 .btn { border-color: #fff; color: #fff; }
.h1 .btn:hover { background: rgba(255,255,255,.15); }
.h1 .btn.solid { background: #fff; color: var(--blue); }
.h1::after { content: ""; position: absolute; inset-inline-end: -50px; top: -50px; width: 210px; height: 210px; border-radius: 50%; background: var(--yellow); }
.h1::before { content: ""; position: absolute; inset-inline-end: 90px; bottom: -60px; width: 120px; height: 120px; border-radius: 50%; background: var(--green); }
.h2 { background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.h2 h2 { font-size: 20px; }
.h2 ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; color: var(--muted); }
.h2 li { display: flex; gap: 10px; align-items: center; }
.h2 li span { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.sec { font-size: 22px; margin-block: 8px 12px; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-block-end: 4px; }
.tg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-block-end: 26px; }
.tile { background: var(--cc); color: #fff; border-radius: 16px; padding: 14px; min-height: 120px; display: flex; flex-direction: column; justify-content: space-between; font-weight: 700; font-size: 16px; overflow: hidden; transition: transform .15s; }
.tile:hover { transform: translateY(-3px); text-decoration: none; }
.tile img { width: 62px; height: 62px; align-self: flex-end; }

/* Liste et cartes */
.layout { display: grid; grid-template-columns: 230px 1fr; gap: 22px; align-items: start; margin-block-start: 14px; }
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: grid; gap: 14px; position: sticky; top: 118px; }
.filters h2 { font-size: 17px; }
.f { display: grid; gap: 6px; min-width: 0; }
.f label { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
input, select, textarea { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 9px 11px; }
.search input, .search select { width: auto; border-radius: 0; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 8px 4px; font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--blue); color: #fff; font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; margin-block: 8px 26px; }
.cw { position: relative; display: flex; min-width: 0; }
.card { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-block-start: 5px solid var(--cc); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; color: var(--fg); transition: box-shadow .15s, transform .15s; }
.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); text-decoration: none; }
.card img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.cb { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.cb h3 { font-size: 15px; font-weight: 500; font-family: var(--body); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cat { font-size: 12px; font-weight: 700; color: var(--cc); }
.price { font-family: var(--display); font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
.meta { color: var(--muted); font-size: 13px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; border-radius: 6px; padding: 2px 7px; width: fit-content; }
.tag.a { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.tag.b { background: color-mix(in srgb, var(--green) 24%, transparent); color: #4F7A00; }
@media (prefers-color-scheme: dark) { .tag.b { color: var(--green); } }
.left { color: var(--red); font-weight: 700; font-variant-numeric: tabular-nums; }
.fav { position: absolute; top: 14px; inset-inline-end: 10px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(255,255,255,.94); color: #444; font-size: 18px; line-height: 1; display: grid; place-items: center; }
.fav[aria-pressed="true"] { color: var(--red); }
.empty { padding: 46px 12px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 14px; margin-block: 10px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-block: 10px 20px; }

/* Page article */
.crumbs { color: var(--muted); font-size: 13px; margin-block: 12px; }
.detail { display: grid; grid-template-columns: 1.1fr 1fr; gap: 28px; align-items: start; }
.detail > * { min-width: 0; }
.pic img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 16px; border-block-end: 6px solid var(--cc); }
.panel { display: grid; gap: 6px; align-content: start; }
.panel h1 { font-size: 26px; margin-block: 6px; }
.mt { margin-block-start: 10px; }
.big { font-family: var(--display); font-weight: 800; font-size: 34px; font-variant-numeric: tabular-nums; }
.stack { display: grid; gap: 10px; margin-block: 12px; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; }
.note { font-size: 13px; padding: 10px 12px; border-radius: 10px; background: var(--chip); }
.note.ok { background: color-mix(in srgb, var(--green) 22%, transparent); }
.note.err { background: color-mix(in srgb, var(--red) 14%, transparent); }
.seller { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; border-block: 1px solid var(--line); padding-block: 12px; margin-block: 8px; }
.desc { margin-block: 26px; max-width: 760px; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; max-width: 520px; font-variant-numeric: tabular-nums; }
th, td { text-align: start; padding: 8px 12px; border-block-end: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

/* Formulaires et compte */
.formpage { max-width: 760px; margin-block: 18px; }
.formpage.narrow { max-width: 440px; }
.formpage h1 { margin-block-end: 14px; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.form.one { grid-template-columns: 1fr; }
.form .full { grid-column: 1 / -1; }
.sum { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-block-end: 14px; }
.sum img { width: 96px; border-radius: 10px; aspect-ratio: 4/3; object-fit: cover; }
.tabs { display: flex; gap: 6px; border-block-end: 1px solid var(--line); margin-block: 8px 14px; overflow-x: auto; }
.tabs a { padding: 9px 16px; color: var(--muted); font-weight: 700; border-block-end: 3px solid transparent; white-space: nowrap; }
.tabs a[aria-current="true"] { color: var(--fg); border-block-end-color: var(--blue); }
.rows { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 10px; }
.row { display: flex; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-inline-start: 5px solid var(--cc); border-radius: 14px; padding: 12px; }
.row img { width: 92px; height: 69px; object-fit: cover; border-radius: 8px; flex: none; }
.rb { min-width: 0; display: grid; gap: 4px; flex: 1; }
.rb > a { font-weight: 700; overflow-wrap: anywhere; }
.line { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.badge { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--chip); }
.badge.st-pending, .badge.os-pending, .badge.st-awaiting_details, .badge.os_pending { background: color-mix(in srgb, var(--yellow) 28%, transparent); }
.badge.st-delivered, .badge.st-sold, .badge.st-accepted { background: color-mix(in srgb, var(--green) 28%, transparent); }
.badge.st-declined, .badge.st-expired, .badge.st-removed { background: color-mix(in srgb, var(--red) 16%, transparent); }

.foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding-block: 28px; color: var(--muted); font-size: 13px; border-block-start: 1px solid var(--line); }
#toast { position: fixed; inset-inline: 0; margin-inline: auto; width: fit-content; max-width: 92vw; bottom: max(20px, env(safe-area-inset-bottom)); background: var(--fg); color: var(--bg); padding: 11px 20px; border-radius: 999px; z-index: 80; font-weight: 500; }
#toast[hidden] { display: none; }

@media (max-width: 860px) {
  .hero, .detail, .layout { grid-template-columns: 1fr; }
  .filters { position: static; }
  .form { grid-template-columns: 1fr; }
  .grid, .tg { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .h1::after { width: 130px; height: 130px; top: -40px; }
  .h1::before { width: 80px; height: 80px; }
  .price { font-size: 17px; }
  .hbtns { width: 100%; }
  .hbtns .btn { flex: 1; }
  .top { position: static; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
