/* asouqna — premium UAE-inspired theme.
   Authored as CSS custom properties so light/dark and RTL are data-driven.
   Source of truth: wwwroot/scss/site.scss (compiled by dart-sass in CI, Phase 15).
   Kept in sync here so the app runs without a Node/Sass toolchain. */

:root {
    --brand: #0e7c66;          /* deep UAE teal-green */
    --brand-600: #0b6455;
    --brand-700: #094e43;
    --gold: #c8a45c;           /* soft gold accent */
    --bg: #f6f7f5;
    --surface: #ffffff;
    --surface-2: #f0f2ef;
    --text: #14201d;
    --text-muted: #5c6b66;
    --border: #e3e7e3;
    --shadow: 0 6px 24px rgba(18, 40, 34, .08);
    --shadow-sm: 0 2px 8px rgba(18, 40, 34, .06);
    --radius: 16px;
    --radius-sm: 12px;
    --header-bg: rgba(255, 255, 255, .82);

    /* ---- Typography tokens (added Phase 16 — consistent, responsive scale) ---- */
    --font-sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --font-arabic: "Segoe UI", "Dubai", "Tahoma", "Noto Naskh Arabic", "Noto Sans Arabic", system-ui, sans-serif;
    /* Fluid heading scale — clamps so nothing overflows small screens or grows huge on wide ones. */
    --fs-h1: clamp(1.55rem, 1.15rem + 1.7vw, 2.1rem);
    --fs-h2: clamp(1.35rem, 1.05rem + 1.2vw, 1.7rem);
    --fs-h3: clamp(1.2rem, 1rem + 0.7vw, 1.4rem);
    --fs-h4: 1.15rem;
    --fs-h5: 1rem;
    --fs-h6: 0.875rem;
    --fs-sm: 0.875rem;
    --fs-xs: 0.78rem;
    --lh-body: 1.55;
    --lh-heading: 1.25;
}

:root[data-theme="dark"] {
    --brand: #35c9a8;
    --brand-600: #2bb597;
    --brand-700: #24a086;
    --gold: #d8b978;
    --bg: #0d1512;
    --surface: #131e1a;
    --surface-2: #172420;
    --text: #eaf1ee;
    --text-muted: #9db1aa;
    --border: #24322d;
    --shadow: 0 8px 28px rgba(0, 0, 0, .35);
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, .3);
    --header-bg: rgba(19, 30, 26, .78);
}

* { box-sizing: border-box; }

html {
    font-size: 15px;              /* modern, readable base (was implicit 16px — trims oversized type) */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: var(--lh-body);
    overflow-x: clip;             /* safety net vs. horizontal scroll (clip, so sticky-top header still works) */
    overflow-wrap: break-word;    /* long words / URLs / IDs wrap instead of overflowing */
}

/* Arabic typography: dedicated stack + a small size bump for legibility. */
html[lang="ar"] body { font-family: var(--font-arabic); font-size: 1.04rem; letter-spacing: 0; }

/* ---- Consistent heading scale (overrides Bootstrap's larger defaults) ---- */
h1, .h1 { font-size: var(--fs-h1); }
h2, .h2 { font-size: var(--fs-h2); }
h3, .h3 { font-size: var(--fs-h3); }
h4, .h4 { font-size: var(--fs-h4); }
h5, .h5 { font-size: var(--fs-h5); }
h6, .h6 { font-size: var(--fs-h6); }
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    line-height: var(--lh-heading);
    overflow-wrap: break-word;
}

/* Media never forces the page wider than the viewport. */
img, svg, video, canvas, table { max-width: 100%; }
img, svg, video { height: auto; }

/* Any bare table scrolls inside its own box rather than stretching the page. */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); text-decoration: underline; }

.site-main { flex: 1 0 auto; }

/* ---- Header ---- */
.site-header {
    background: var(--header-bg);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--border);
}
.brand-mark {
    width: 40px; height: 40px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 12px; font-size: 1.25rem; color: #fff;
    background: linear-gradient(135deg, var(--brand-700), var(--brand));
    box-shadow: var(--shadow-sm);
}
.brand-name { font-weight: 800; font-size: 1.25rem; color: var(--brand); letter-spacing: .3px; line-height: 1.15; }
.brand-tagline { font-size: .72rem; color: var(--text-muted); }
.navbar .nav-link { color: var(--text); font-weight: 600; border-radius: 10px; padding: .4rem .8rem; }
.navbar .nav-link:hover { background: var(--surface-2); text-decoration: none; }
/* On narrow desktops the action cluster may wrap to a second line rather than overflow. */
@media (min-width: 992px) {
    .navbar .navbar-collapse { flex-wrap: wrap; row-gap: .4rem; }
}

/* ---- Buttons ---- */
.btn-brand {
    background: var(--brand); color: #fff; border: none; border-radius: 999px;
    padding: .5rem 1.15rem; font-weight: 700; box-shadow: var(--shadow-sm);
}
.btn-brand:hover { background: var(--brand-700); color: #fff; }
.btn-outline-soft {
    background: transparent; color: var(--text); border: 1px solid var(--border);
    border-radius: 999px; padding: .45rem 1rem; font-weight: 600;
}
.btn-outline-soft:hover { background: var(--surface-2); }
.btn-icon {
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
    border-radius: 999px; width: 42px; height: 42px; display: inline-flex;
    align-items: center; justify-content: center;
}
.theme-icon { font-size: 1.05rem; display: inline-flex; }
.theme-icon .bi-sun-fill { display: none; }
:root[data-theme="dark"] .theme-icon .bi-moon-stars-fill { display: none; }
:root[data-theme="dark"] .theme-icon .bi-sun-fill { display: inline-flex; }

/* ---- Hero ---- */
.hero {
    background: radial-gradient(1200px 400px at 80% -10%, rgba(200,164,92,.18), transparent 60%),
                linear-gradient(135deg, var(--brand-700), var(--brand));
    color: #fff; border-radius: var(--radius); padding: clamp(2rem, 5vw, 4rem);
    box-shadow: var(--shadow); overflow: hidden; position: relative;
}
.hero h1 { font-weight: 800; font-size: clamp(1.7rem, 3.2vw, 2.6rem); line-height: 1.2; margin-bottom: .75rem; }
.hero p { font-size: 1.02rem; opacity: .95; max-width: 60ch; }
.hero .btn-brand { background: #fff; color: var(--brand-700); }
.hero .btn-brand:hover { background: var(--gold); color: #1a1205; }
.hero .btn-hero-ghost {
    border: 1px solid rgba(255,255,255,.6); color: #fff; border-radius: 999px;
    padding: .5rem 1.15rem; font-weight: 700;
}
.hero .btn-hero-ghost:hover { background: rgba(255,255,255,.14); text-decoration: none; color: #fff; }

/* ---- Cards ---- */
.section-title { font-weight: 800; font-size: 1.25rem; margin: 1.75rem 0 1rem; }
.vertical-card, .listing-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
    transition: transform .15s ease, box-shadow .15s ease; height: 100%;
}
.vertical-card:hover, .listing-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.vertical-card { padding: 1.25rem; text-align: center; color: var(--text); display: block; }
.vertical-card .emoji { font-size: 2rem; display: block; margin-bottom: .5rem; }
.vertical-card:hover { text-decoration: none; }

.listing-card { display: flex; flex-direction: column; overflow: hidden; }
.listing-card .thumb {
    aspect-ratio: 16 / 10; background: linear-gradient(135deg, var(--surface-2), var(--border));
    display: flex; align-items: center; justify-content: center; font-size: 2.4rem; color: var(--text-muted);
    overflow: hidden;
}
.listing-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.listing-card .body { padding: 1rem; display: flex; flex-direction: column; gap: .35rem; flex: 1; }
.listing-card .title { font-weight: 700; color: var(--text); }
.listing-card .price { color: var(--brand); font-weight: 800; font-size: 1.15rem; }
.listing-card .meta { color: var(--text-muted); font-size: .85rem; }

.badge-soft {
    background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
    border-radius: 999px; padding: .15rem .6rem; font-size: .75rem; font-weight: 600;
}
.badge-negotiable { background: rgba(200,164,92,.16); color: var(--gold); border-color: transparent; }

/* ---- Forms ---- */
.form-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); padding: clamp(1.25rem, 3vw, 2rem);
}
.form-label { font-weight: 600; color: var(--text); }
.form-control, .form-select {
    background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(14,124,102,.18);
    background: var(--surface); color: var(--text);
}

/* ---- Footer ---- */
.site-footer {
    flex-shrink: 0; margin-top: 3rem; padding: 1.5rem 0;
    background: var(--surface); border-top: 1px solid var(--border); color: var(--text-muted);
}

/* ---- Accessibility ---- */
.skip-link {
    position: absolute; inset-inline-start: 1rem; top: .5rem; z-index: 1080;
    background: var(--brand); color: #fff; padding: .5rem 1rem; border-radius: 8px;
}
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

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

/* ============================================================
   Icon system & UI refinements (Bootstrap Icons)
   ============================================================ */

/* Crisp optical alignment for inline icons. */
.bi { vertical-align: -0.125em; line-height: 1; }
.text-brand { color: var(--brand) !important; }

/* Buttons become icon+label friendly: centred flex with a consistent gap. */
.btn,
.btn-brand,
.btn-outline-soft,
.btn-hero-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    transition: transform .12s ease, background-color .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.btn-brand:hover, .btn-outline-soft:hover, .btn-hero-ghost:hover { transform: translateY(-1px); }
.btn-brand:active, .btn-outline-soft:active { transform: translateY(0); }

.navbar .nav-link { display: inline-flex; align-items: center; gap: .45rem; }

/* Directional icons (e.g. "back") mirror automatically in RTL. */
html[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

/* Category tiles: icon in a soft brand-tinted circle. */
.vertical-card .icon-wrap {
    width: 56px; height: 56px; margin: 0 auto .6rem;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: color-mix(in srgb, var(--brand) 14%, transparent);
    color: var(--brand); font-size: 1.5rem;
}
.vertical-card:hover .icon-wrap { background: var(--brand); color: #fff; }

/* Listing thumbnail icon. */
.listing-card .thumb .bi { font-size: 2.6rem; }

/* Badges: pill styling + icon spacing + status variants. */
.badge-soft { display: inline-flex; align-items: center; gap: .3rem; line-height: 1.4; }
.badge-featured { background: color-mix(in srgb, var(--gold) 22%, transparent); color: var(--gold); border-color: transparent; }
.badge-verified { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); border-color: transparent; }

/* Meta rows (price / location / date) with muted leading icons. */
.meta-row { display: inline-flex; align-items: center; gap: .35rem; color: var(--text-muted); }
.meta-row .bi { color: var(--brand); }

/* Definition lists on detail pages: icon-led terms. */
.spec-list dt { display: inline-flex; align-items: center; gap: .5rem; }
.spec-list dt .bi { color: var(--brand); }

/* Stat cards (admin): icon chip in the corner. */
.stat-card { position: relative; }
.stat-card .stat-icon {
    position: absolute; inset-inline-end: 1rem; top: 1rem;
    width: 40px; height: 40px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--brand) 12%, transparent);
    color: var(--brand); font-size: 1.15rem;
}

/* Admin nav icons keep a fixed width so labels line up. */
.admin-nav-link .bi { width: 1.2em; text-align: center; }

/* ---- Notification badge + toasts ---- */
.notif-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 1.2rem; height: 1.2rem; padding: 0 .35rem; margin-inline-start: .15rem;
    font-size: .68rem; font-weight: 700; line-height: 1; color: #fff;
    background: #d64545; border-radius: 999px; vertical-align: middle;
}
.toast-stack {
    position: fixed; inset-block-start: 4.5rem; inset-inline-end: 1rem; z-index: 1090;
    display: flex; flex-direction: column; gap: .5rem; width: min(92vw, 22rem);
}
.app-toast {
    display: flex; align-items: flex-start; gap: .6rem; padding: .7rem .8rem;
    background: var(--surface); color: var(--text); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow);
    animation: toast-in .18s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.app-toast .toast-icon {
    flex-shrink: 0; width: 2rem; height: 2rem; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand);
}
.app-toast .toast-body-wrap { flex: 1; min-width: 0; }
.app-toast .toast-title { font-weight: 700; font-size: .9rem; }
.app-toast .toast-sub { font-size: .78rem; color: var(--text-muted); }
.app-toast .toast-preview { font-size: .82rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-toast .toast-close { flex-shrink: 0; background: none; border: none; color: var(--text-muted); font-size: 1.1rem; line-height: 1; cursor: pointer; }

/* Listing image gallery (migrated media). */
.gallery-main {
    display: block; border-radius: var(--radius-sm); overflow: hidden;
    border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.gallery-main img { width: 100%; height: auto; max-height: 460px; object-fit: cover; display: block; }
.gallery-thumbs { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }
.gallery-thumbs img {
    width: 76px; height: 60px; object-fit: cover; border-radius: 8px;
    border: 1px solid var(--border); transition: transform .12s ease;
}
.gallery-thumbs a:hover img { transform: translateY(-2px); }

/* License-plate badge (Details view) — a simple UAE-style plate. */
.plate-badge {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .35rem .8rem; border: 2px solid #16324f; border-radius: 8px;
    background: #fff; color: #16324f; font-weight: 700; letter-spacing: .04em;
    box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.plate-badge .plate-emirate { font-size: .7rem; text-transform: uppercase; opacity: .8; }
.plate-badge .plate-code { font-size: 1.1rem; }
.plate-badge .plate-number { font-size: 1.4rem; }
