/* IdrissiMart web app — mirrors the mobile app UI (Figma "Master: IdrissiMart – Mobile App UI/UX").
   Every colour is a design token rendered by base.html from webapp/design_tokens.json
   (synced from idrissimart_app/constants/Colors.ts). Never write a literal colour here. */

:root {
  --font: "Cairo", system-ui, sans-serif;
  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 24px;
  --control-h: 54px;
  --page-pad: 20px;
  --tabbar-h: 64px;
  --shadow-soft: 0 2px 10px color-mix(in srgb, var(--shadow) 5%, transparent);
  --overlay: color-mix(in srgb, var(--black) 45%, transparent);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--background); color: var(--text); font-family: var(--font); }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app { max-width: 430px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: var(--background); }
main { flex: 1; padding: 16px var(--page-pad) 32px; display: flex; flex-direction: column; gap: 20px; }
.app--tabs main { padding-bottom: calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); }
.app--plain { background: var(--card); }
.app--plain main { justify-content: center; }

/* ---------- Typography ---------- */
.h1 { margin: 0; font-size: 26px; font-weight: 800; color: var(--primary-dark); line-height: 1.3; }
.h2 { margin: 0; font-size: 22px; font-weight: 700; color: var(--primary-dark); line-height: 1.35; }
.h3 { margin: 0; font-size: 16px; font-weight: 700; color: var(--text); line-height: 1.5; }
.muted { color: var(--text-muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.accent-text { color: var(--secondary); }
.primary-text { color: var(--primary); }
.lead { margin: 0; font-size: 15px; color: var(--text-muted); line-height: 1.7; }

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.page-header__title { flex: 1; margin: 0; font-size: 24px; font-weight: 700; color: var(--primary-dark); }
.page-header__sub { margin: -14px 0 0; font-size: 14px; color: var(--text-muted); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--primary-dark); cursor: pointer; }
.icon-btn--card { width: 44px; height: 44px; background: var(--card); box-shadow: var(--shadow-soft); color: var(--primary); }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

/* ---------- Home header ---------- */
.home-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.home-header__greeting { margin: 0; font-size: 14px; color: var(--text-muted); }
.home-header__title { margin: 2px 0 0; font-size: 28px; font-weight: 800; color: var(--primary-dark); }
.home-header__logo { width: 44px; height: 44px; border-radius: var(--radius-sm); background: var(--card); display: grid; place-items: center; box-shadow: var(--shadow-soft); overflow: hidden; }
.home-header__logo img { width: 32px; height: 32px; object-fit: contain; }

/* ---------- Search ---------- */
.search { display: flex; align-items: center; gap: 10px; height: var(--control-h); padding: 0 16px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-soft); }
.search__icon { color: var(--secondary); flex-shrink: 0; }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: 14px; }
.search input::placeholder { color: var(--text-muted); }

/* ---------- Section heading ---------- */
.section { display: flex; flex-direction: column; gap: 14px; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section__title { margin: 0; font-size: 22px; font-weight: 700; color: var(--primary-dark); }
.section__subtitle { margin: -10px 0 0; font-size: 14px; color: var(--text-muted); }
.section__more { font-size: 14px; font-weight: 700; color: var(--secondary); }

/* ---------- Quick categories (home) ---------- */
.quick-cats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.quick-cat { display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; color: var(--text); text-align: center; }
.quick-cat__tile { width: 100%; aspect-ratio: 1; border-radius: var(--radius-lg); background: var(--card); display: grid; place-items: center; color: var(--primary); box-shadow: var(--shadow-soft); }
.quick-cat__tile img { width: 36px; height: 36px; object-fit: contain; }

/* ---------- Publish banner ---------- */
.promo { display: flex; flex-direction: column; gap: 6px; padding: 28px 20px; border-radius: var(--radius-lg); background: var(--primary); color: var(--white); }
.promo__title { margin: 0; font-size: 22px; font-weight: 700; }
.promo__text { margin: 0; font-size: 14px; color: var(--on-primary-muted); }
.promo__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--control-h); padding: 0 24px; border-radius: var(--radius); border: 1px solid transparent; font-size: 16px; font-weight: 700; cursor: pointer; text-align: center; }
.btn--block { width: 100%; }
.btn--primary { background: var(--primary); color: var(--white); }
.btn--secondary { background: var(--secondary); color: var(--white); }
.btn--outline { background: var(--card); color: var(--primary-dark); border-color: var(--border); }
.btn--small { min-height: 40px; padding: 0 18px; font-size: 14px; border-radius: var(--radius-sm); }
.btn--link { min-height: 0; padding: 0; background: none; color: var(--text-muted); font-weight: 600; font-size: 15px; }
.btn--danger-link { min-height: 0; padding: 0; background: none; color: var(--error-dark); font-weight: 700; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.link-accent { color: var(--secondary); font-weight: 700; font-size: 14px; }
.actions { display: flex; flex-direction: column; gap: 14px; margin-top: auto; }

/* ---------- Chips ---------- */
.chips { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips > * { flex-shrink: 0; }
.chips--wrap { flex-wrap: wrap; overflow: visible; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 18px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); font-size: 14px; font-weight: 700; color: var(--text); cursor: pointer; }
.chip--active, .chip:has(input:checked) { background: var(--primary); border-color: var(--primary); color: var(--white); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip--lg { height: 44px; padding: 0 22px; }

/* ---------- Cards & lists ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-soft); }
.card--pad { padding: 16px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack--tight { gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.row--between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.count-label { margin: 0; font-size: 14px; font-weight: 700; color: var(--text-muted); }

.thumb { flex-shrink: 0; width: 86px; height: 86px; border-radius: var(--radius-sm); background: var(--surface-alt); overflow: hidden; display: grid; place-items: center; color: var(--primary); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb--alt { background: var(--highlight-bg); }
.thumb--lg { width: 100%; height: 110px; }

.ad-row { display: flex; gap: 14px; padding: 10px; align-items: stretch; }
.ad-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding: 6px 0; }
.ad-row__title { margin: 0; font-size: 15px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ad-row__meta { font-size: 13px; font-weight: 700; color: var(--secondary); }
.ad-row__foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-muted); }

.ad-tile { display: flex; flex-direction: column; gap: 6px; padding: 10px 10px 14px; }
.ad-tile__title { margin: 6px 0 0; font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-tile__price { font-size: 13px; font-weight: 700; color: var(--secondary); }

.fav-btn { display: inline-flex; border: 0; background: none; padding: 4px; cursor: pointer; color: var(--primary); }
.fav-btn--on { color: var(--error); }

.cat-card { display: flex; align-items: center; gap: 12px; padding: 14px; min-height: 70px; font-size: 15px; font-weight: 700; color: var(--text); }
.cat-card__icon { flex-shrink: 0; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-alt); display: grid; place-items: center; color: var(--primary); }
.cat-card__icon img { width: 22px; height: 22px; object-fit: contain; }

.list-row { display: flex; align-items: center; gap: 12px; padding: 16px; font-size: 15px; font-weight: 700; color: var(--text); }
.list-row__hint { font-size: 13px; font-weight: 400; color: var(--text-muted); }
.list-row__chev { color: var(--text-muted); }
.list-row__icon { color: var(--primary); }

.badge { display: inline-flex; align-items: center; align-self: flex-start; height: 26px; padding: 0 12px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--tag-bg); color: var(--primary); }
.badge--accent { background: var(--highlight-bg); color: var(--secondary); }
.badge--success { background: var(--success-bg); color: var(--success-emphasis); }
.badge--error { background: var(--error-bg); color: var(--error-dark); }
.status--active { color: var(--success-dark); font-weight: 700; font-size: 13px; }
.status--pending, .status--draft { color: var(--secondary); font-weight: 700; font-size: 13px; }
.status--rejected, .status--expired, .status--suspended, .status--banned { color: var(--error-dark); font-weight: 700; font-size: 13px; }
.status--sold { color: var(--text-muted); font-weight: 700; font-size: 13px; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field__label { font-size: 14px; font-weight: 700; color: var(--text); }
.field__label .req { color: var(--error); }
.input, .select, .textarea { width: 100%; min-height: var(--control-h); padding: 0 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--card); font-size: 14px; outline: 0; }
.textarea { min-height: 110px; padding: 14px 16px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); }
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.field__row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field__error { font-size: 13px; color: var(--error); }
.form-errors { padding: 12px 16px; border-radius: var(--radius-sm); background: var(--error-bg); color: var(--error-dark); font-size: 14px; }
.form-errors p { margin: 0; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

.radio-card { display: flex; align-items: center; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); cursor: pointer; font-size: 14px; }
.radio-card input { width: 20px; height: 20px; accent-color: var(--primary); margin: 0; }
.radio-card:has(input:checked) { border-color: var(--primary); }

.otp { display: flex; justify-content: center; gap: 12px; direction: ltr; }
.otp input { width: 56px; height: 56px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--card); text-align: center; font-size: 20px; font-weight: 700; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 14px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.hint-box { padding: 16px; border-radius: var(--radius); background: var(--surface-alt); }
.hint-box--accent { background: var(--banner-bg); }
.hint-box__title { margin: 0 0 6px; font-size: 14px; font-weight: 700; color: var(--primary-dark); }
.hint-box--accent .hint-box__title { color: var(--secondary); }
.hint-box p { margin: 0; font-size: 13px; color: var(--text); }

/* ---------- Ad detail ---------- */
.gallery { position: relative; border-radius: var(--radius-lg); background: var(--surface-alt); aspect-ratio: 4 / 3; overflow: hidden; display: grid; place-items: center; color: var(--text-muted); }
.gallery__track { display: flex; width: 100%; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.gallery__track img { flex: 0 0 100%; height: 100%; object-fit: cover; scroll-snap-align: center; }
.price { margin: 0; font-size: 24px; font-weight: 800; color: var(--secondary); }
.prose { font-size: 14px; line-height: 1.9; color: var(--text); overflow-wrap: anywhere; }
.prose img { height: auto; border-radius: var(--radius-sm); }
.spec { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.spec:last-child { border-bottom: 0; }
.spec__key { color: var(--text-muted); }
.seller { display: flex; align-items: center; gap: 12px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--surface-alt); color: var(--primary); display: grid; place-items: center; font-size: 20px; font-weight: 800; overflow: hidden; flex-shrink: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { width: 64px; height: 64px; background: var(--card); }

/* ---------- Profile ---------- */
.profile-card { display: flex; flex-direction: column; gap: 12px; padding: 20px; border-radius: var(--radius-lg); background: var(--primary); color: var(--white); }
.profile-card__name { margin: 0; font-size: 20px; font-weight: 700; }
.profile-card__role { margin: 0; font-size: 13px; color: var(--on-primary-muted); }

/* ---------- Notifications ---------- */
.notif { display: flex; align-items: flex-start; gap: 14px; padding: 16px; }
.notif--unread { background: var(--unread-bg); }
.notif__dot { flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-alt); color: var(--primary); font-weight: 800; }
.notif--unread .notif__dot { background: var(--secondary); color: var(--white); }
.notif__title { margin: 0; font-size: 15px; font-weight: 700; }
.notif__time { margin: 6px 0 0; font-size: 12px; color: var(--text-muted); }

/* ---------- Hub / help ---------- */
.hero { padding: 24px 20px; border-radius: var(--radius-lg); background: var(--primary); color: var(--white); text-align: center; }
.hero__title { margin: 0; font-size: 22px; font-weight: 700; }
.hero__text { margin: 6px 0 0; font-size: 14px; color: var(--on-primary-muted); }
.video-thumb { position: relative; }
.video-thumb__play { position: absolute; inset: 0; display: grid; place-items: center; color: var(--white); }
.video-thumb__play span { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--secondary); }
.embed { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: var(--black); }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------- States (empty / success / offline / face) ---------- */
.state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 40px 12px; text-align: center; flex: 1; }
.state__icon { color: var(--text-muted); }
.state__icon--accent { color: var(--secondary); }
.state__icon--success { color: var(--success-emphasis); }
.state__title { margin: 0; font-size: 22px; font-weight: 700; color: var(--primary-dark); }
.state__text { margin: 0; font-size: 15px; color: var(--text-muted); line-height: 1.7; max-width: 320px; }

/* ---------- Onboarding / splash ---------- */
.illustration { width: 100%; max-width: 300px; aspect-ratio: 1 / .93; margin: 32px auto 0; border-radius: 32px; background: var(--surface-alt); display: grid; place-items: center; color: var(--secondary); }
.dots { display: flex; justify-content: center; gap: 12px; }
.dots a, .dots span { width: 28px; height: 40px; border-radius: 14px; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--primary-dark); }
.dots .is-active { background: var(--primary); color: var(--white); }
.splash { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; min-height: 100vh; background: var(--card); }
.splash__logo { width: 190px; }
.splash__tagline { margin: 0; font-size: 18px; font-weight: 700; color: var(--secondary); }
.splash__bar { width: 100px; height: 5px; border-radius: 3px; background: var(--secondary); }

/* ---------- Wizard ---------- */
.step-label { margin: 0; font-size: 13px; font-weight: 700; color: var(--secondary); }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.choice { position: relative; display: flex; align-items: center; justify-content: center; min-height: 56px; padding: 8px 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--card); font-size: 14px; font-weight: 700; text-align: center; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:has(input:checked) { background: var(--primary); border-color: var(--primary); color: var(--white); }
.upload { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--card); color: var(--text-muted); cursor: pointer; text-align: center; font-size: 14px; }

/* ---------- Tab bar ---------- */
.tabbar { position: fixed; bottom: 0; inset-inline: 0; z-index: 10; display: flex; justify-content: center; background: var(--card); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.tabbar__inner { display: flex; justify-content: space-around; align-items: center; width: 100%; max-width: 430px; height: var(--tabbar-h); }
.tabbar a { flex: 1; text-align: center; font-size: 13px; color: var(--text-muted); padding: 12px 0; }
.tabbar a[aria-current="page"] { color: var(--primary); font-weight: 700; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: calc(var(--tabbar-h) + 16px); inset-inline: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { max-width: 380px; margin: 0 16px; padding: 12px 18px; border-radius: var(--radius-sm); background: var(--primary-dark); color: var(--white); font-size: 14px; animation: toast-out .3s ease 4s forwards; }
.toast--error { background: var(--error-dark); }
@keyframes toast-out { to { opacity: 0; visibility: hidden; } }

.pager { display: flex; justify-content: center; gap: 12px; }

.fill { flex: 1; }
[data-push] { margin-top: auto; }
.fieldset { border: 0; padding: 0; margin: 0; }
.otp input[data-otp] { width: 100%; max-width: 260px; letter-spacing: 12px; }
[data-center] { margin: 8px auto 0; }
button[data-reset] { width: 100%; border: 0; font: inherit; text-align: start; cursor: pointer; }
.badge[data-reset] { width: auto; }
[data-start] { align-self: flex-start; }
details summary { cursor: pointer; }
.actions--inline { margin-top: 24px; }
/* LTR keeps the back button first; the RTL mockups put "<" at the far (left) end. */
[dir="ltr"] .page-header__back { order: -1; }
.btn--link.primary-text { color: var(--primary); }
.center-col { display: flex; flex-direction: column; justify-content: center; }
.state--fit { flex: 0 0 auto; }
