/* =====================================================================
   Baa (بع) Platform — Core Theme
   Mobile-first. White background. RTL default (dir="rtl" on <html>).
   Brand: navy #232F4E + green #22B573 (from logo).
   ===================================================================== */

:root {
    /* Brand */
    --navy:        #232F4E;
    --navy-700:    #1B2540;
    --navy-900:    #131B30;
    --green:       #22B573;
    --green-600:   #1DA968;
    --green-50:    #E7F8F0;

    /* Neutrals */
    --ink:         #1F2937;
    --muted:       #6B7280;
    --muted-2:     #9CA3AF;
    --line:        #E5E7EB;
    --line-soft:   #F0F1F3;
    --bg:          #FFFFFF;
    --bg-soft:     #F7F8FA;
    --bg-softer:   #FBFCFD;

    /* Status */
    --danger:      #EF4444;
    --danger-50:   #FEF2F2;
    --warning:     #F59E0B;
    --warning-50:  #FFFBEB;
    --info:        #3B82F6;
    --success:     #10B981;

    /* Shape & motion */
    --radius:      14px;
    --radius-sm:   10px;
    --radius-lg:   20px;
    --shadow-sm:   0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
    --shadow:      0 4px 16px rgba(16,24,40,.08);
    --shadow-lg:   0 12px 32px rgba(16,24,40,.12);
    --container:   1400px;
    --header-h:    60px;
    --transition:  .2s ease;

    --font: 'Cairo', 'Segoe UI', Tahoma, system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.6;
    font-size: 15px;
    min-height: 100vh;
    overflow-x: hidden;
}

/* LTR override applied when html[dir="ltr"] (English) */
html[dir="ltr"] body { text-align: left; }

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
ul { list-style: none; }

/* ------------------------------- Layout ------------------------------ */
.container {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: 16px;
}
.section { padding-block: 28px; }
.row { display: flex; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.center { align-items: center; }
.grow { flex: 1; }
.hide { display: none !important; }

/* ------------------------------ Typography --------------------------- */
h1,h2,h3,h4 { color: var(--navy); font-weight: 800; line-height: 1.3; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
.text-muted { color: var(--muted); }
.text-green { color: var(--green); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.small { font-size: .85rem; }
.tiny { font-size: .75rem; }
.bold { font-weight: 700; }

/* ------------------------------- Buttons ----------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .7rem 1.25rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    background: var(--bg-soft);
    color: var(--ink);
    font-weight: 700;
    font-size: .92rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    line-height: 1.2;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--green); color: #fff; box-shadow: 0 6px 16px rgba(34,181,115,.25); }
.btn-primary:hover { background: var(--green-600); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-700); }
.btn-outline { background: #fff; border-color: var(--line); color: var(--navy); }
.btn-outline:hover { border-color: var(--green); color: var(--green); }
.btn-ghost { background: transparent; color: var(--navy); }
.btn-ghost:hover { background: var(--bg-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: .45rem .85rem; font-size: .82rem; }
.btn-lg { padding: .9rem 1.6rem; font-size: 1rem; }
.btn-icon { padding: .55rem; width: 40px; height: 40px; border-radius: 50%; }

/* -------------------------------- Cards ------------------------------ */
.card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-body { padding: 16px; }
.card-pad { padding: 18px; }

/* ------------------------------- Forms ------------------------------- */
.field { margin-bottom: 16px; }
.field label, .label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
    font-size: .88rem;
    color: var(--navy);
}
.field label .req { color: var(--danger); }
.input, .select, .textarea {
    width: 100%;
    padding: .72rem .9rem;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--ink);
    transition: var(--transition);
    outline: none;
}
.input:focus, .select:focus, .textarea:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(34,181,115,.12);
}
.textarea { resize: vertical; min-height: 110px; }
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.field-hint { font-size: .78rem; color: var(--muted); margin-top: 5px; }
.field-error { font-size: .8rem; color: var(--danger); margin-top: 5px; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: 0; }

/* Phone/whatsapp grouped input prefix */
.input-prefix {
    display: inline-flex; align-items: center; padding: 0 .8rem;
    background: var(--bg-soft); border: 1.5px solid var(--line);
    color: var(--muted); font-weight: 700;
}

/* ------------------------------- Badges ------------------------------ */
.badge {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .28rem .7rem; border-radius: 999px;
    font-size: .73rem; font-weight: 700; line-height: 1;
}
.badge-green { background: var(--green-50); color: var(--green-600); }
.badge-navy  { background: #EEF1F7; color: var(--navy); }
.badge-muted { background: var(--bg-soft); color: var(--muted); }
.badge-danger{ background: var(--danger-50); color: var(--danger); }
.badge-warn  { background: var(--warning-50); color: var(--warning); }

/* Trust logo badge */
.trust-badge {
    display: inline-flex; align-items: center; gap: .35rem;
    color: var(--green-600); font-weight: 800; font-size: .8rem;
}
.trust-badge i { color: var(--green); }

/* --------------------------- Star rating ----------------------------- */
.stars { display: inline-flex; gap: 2px; color: #E5C100; }
.stars .empty { color: var(--line); }

/* ----------------------------- Chips/tabs ---------------------------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-block: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex: 0 0 auto; padding: .5rem 1rem; border-radius: 999px;
    background: var(--bg-soft); color: var(--muted); font-weight: 700;
    font-size: .85rem; cursor: pointer; border: 1.5px solid transparent;
    transition: var(--transition);
}
.chip.active, .chip:hover { background: #fff; color: var(--green); border-color: var(--green); }

/* ===================================================================== */
/* Header / Navbar                                                       */
/* ===================================================================== */
.app-header {
    position: sticky; top: 0; z-index: 900;
    background: #fff; border-bottom: 1px solid var(--line);
    height: var(--header-h);
}
.app-header .container { display: flex; align-items: center; gap: 12px; height: 100%; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 900; color: var(--navy); font-size: 1.25rem; }
.brand img { height: 34px; width: auto; }
.header-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }

/* Location selector pill in header */
.loc-pill {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .45rem .8rem; border-radius: 999px;
    background: var(--bg-soft); color: var(--navy); font-weight: 700;
    font-size: .82rem; cursor: pointer; border: 1.5px solid var(--line);
}
.loc-pill i { color: var(--green); }

/* ===================================================================== */
/* Top banner (company ads)                                              */
/* ===================================================================== */
.top-banner { width: 100%; background: var(--bg-soft); }
.top-banner a { display: block; }
.top-banner img, .top-banner video { width: 100%; max-height: 160px; object-fit: cover; }
.banner-cta {
    display: flex; align-items: center; justify-content: center; gap: .5rem;
    padding: 10px; background: linear-gradient(135deg, var(--navy), var(--navy-700));
    color: #fff; font-weight: 700; font-size: .85rem; cursor: pointer;
}

/* ===================================================================== */
/* Category grid (home)                                                  */
/* ===================================================================== */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.cat-card {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 16px 8px; background: #fff; border: 1px solid var(--line);
    border-radius: var(--radius); text-align: center; transition: var(--transition);
}
.cat-card:hover { border-color: var(--green); box-shadow: var(--shadow); transform: translateY(-2px); }
.cat-icon {
    width: 52px; height: 52px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; color: var(--navy); background: var(--bg-soft);
}
.cat-card .cat-name { font-weight: 700; font-size: .85rem; color: var(--ink); }
.cat-card .cat-count { font-size: .72rem; color: var(--muted); }

/* ===================================================================== */
/* Listing cards                                                         */
/* ===================================================================== */
.listings { display: flex; flex-direction: column; gap: 12px; }
.listing-card {
    display: flex; gap: 12px; padding: 12px; background: #fff;
    border: 1px solid var(--line); border-radius: var(--radius);
    transition: var(--transition);
}
.listing-card:hover { box-shadow: var(--shadow); border-color: var(--line); }
.listing-thumb {
    flex: 0 0 96px; width: 96px; height: 96px; border-radius: var(--radius-sm);
    object-fit: cover; background: var(--bg-soft);
}
.listing-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.listing-title { font-weight: 700; color: var(--navy); font-size: .98rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.listing-meta { display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: .78rem; }
.listing-price { color: var(--green-600); font-weight: 800; font-size: 1rem; margin-top: auto; }

/* Grid view (optional) */
.listings.grid { display: grid; grid-template-columns: repeat(2, 1fr); }
.listings.grid .listing-card { flex-direction: column; }
.listings.grid .listing-thumb { width: 100%; height: 130px; flex: none; }

/* ===================================================================== */
/* Footer                                                                */
/* ===================================================================== */
.app-footer {
    margin-top: 40px; background: var(--navy); color: #cdd5e3;
    padding-block: 28px 18px;
}
.app-footer a { color: #cdd5e3; }
.app-footer a:hover { color: #fff; }
.footer-cols { display: grid; grid-template-columns: 1fr; gap: 24px; }
.footer-col h4 { color: #fff; font-size: 1rem; margin-bottom: 12px; }
.footer-col ul li { margin-bottom: 8px; font-size: .9rem; }
.footer-agent {
    background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
    border-radius: var(--radius); padding: 14px; font-size: .88rem;
}
.footer-agent .agent-name { color: #fff; font-weight: 700; }
.footer-social { display: flex; gap: 10px; margin-top: 12px; }
.footer-social a {
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(255,255,255,.1); display: flex; align-items: center; justify-content: center;
    color: #fff; transition: var(--transition);
}
.footer-social a:hover { background: var(--green); }
.footer-bottom {
    border-top: 1px solid rgba(255,255,255,.12); margin-top: 22px; padding-top: 16px;
    text-align: center; font-size: .82rem; color: #8b97ad;
}

/* ===================================================================== */
/* Mobile bottom nav (Haraj-style)                                       */
/* ===================================================================== */
.bottom-nav {
    position: fixed; bottom: 0; inset-inline: 0; z-index: 800;
    background: #fff; border-top: 1px solid var(--line);
    display: flex; justify-content: space-around; align-items: center;
    height: 60px; padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    color: var(--muted); font-size: .68rem; font-weight: 700; flex: 1; padding: 6px 0;
}
.bottom-nav a i { font-size: 1.15rem; }
.bottom-nav a.active { color: var(--green); }
.bottom-nav .fab {
    width: 50px; height: 50px; border-radius: 50%; background: var(--green);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; margin-top: -20px; box-shadow: 0 6px 18px rgba(34,181,115,.4);
}
body.has-bottom-nav { padding-bottom: 64px; }

/* ===================================================================== */
/* Modal                                                                 */
/* ===================================================================== */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(19,27,48,.55);
    display: none; align-items: flex-end; justify-content: center; z-index: 1000;
    backdrop-filter: blur(2px);
}
.modal-overlay.show { display: flex; }
.modal {
    background: #fff; width: 100%; max-width: 480px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 90vh; overflow-y: auto; animation: modalUp .3s ease;
}
@keyframes modalUp { from { transform: translateY(40px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
.modal-head h3 { margin: 0; }
.modal-body { padding: 16px; }
.modal-close { background: var(--bg-soft); border: none; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; color: var(--muted); font-size: 1.1rem; }

/* ------------------------------- Misc -------------------------------- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state i { font-size: 2.5rem; color: var(--line); margin-bottom: 12px; }
.divider { height: 1px; background: var(--line); margin-block: 16px; }
.spinner {
    width: 22px; height: 22px; border: 3px solid var(--line);
    border-top-color: var(--green); border-radius: 50%;
    animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-wrap { display: flex; align-items: center; justify-content: center; padding: 40px; }

/* ----------------------------- Responsive ---------------------------- */
@media (min-width: 600px) {
    .cat-grid { grid-template-columns: repeat(4, 1fr); }
    .listings.grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
    body.has-bottom-nav { padding-bottom: 0; }
    .bottom-nav { display: none; }
    .cat-grid { grid-template-columns: repeat(6, 1fr); }
    .footer-cols { grid-template-columns: 2fr 1fr 1fr; }
    .top-banner img, .top-banner video { max-height: 200px; }
}

/* ===================================================================== */
/* Auth pages (login / register / verify / forgot / reset)              */
/* ===================================================================== */
.auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 28px 16px; background: linear-gradient(135deg, #f7f8fa, #eef1f7);
}
.auth-card {
    width: 100%; max-width: 440px; background: #fff; border: 1px solid var(--line);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden;
}
.auth-card.wide { max-width: 560px; }
.auth-head { text-align: center; padding: 30px 28px 6px; }
.auth-brand { display: inline-flex; align-items: center; gap: .55rem; margin-bottom: 12px; }
.auth-brand .b-ico {
    width: 48px; height: 48px; border-radius: 13px;
    background: linear-gradient(135deg, var(--navy), var(--green));
    display: flex; align-items: center; justify-content: center; color: #fff;
    font-size: 1.25rem; box-shadow: 0 8px 20px rgba(34,181,115,.3);
}
.auth-brand .b-logo {
    width: 50px; height: 50px; border-radius: 13px; display: block; flex-shrink: 0;
    box-shadow: 0 8px 20px rgba(34,181,115,.3); object-fit: cover;
}
.auth-brand .b-text { font-size: 1.9rem; font-weight: 900; color: var(--navy); line-height: 1; }
.auth-brand .b-text span { color: var(--green); }
.auth-title { font-size: 1.3rem; font-weight: 800; color: var(--navy); }
.auth-sub { color: var(--muted); font-size: .9rem; margin-top: 5px; }
.auth-body { padding: 22px 28px 26px; }
.auth-foot {
    text-align: center; padding: 16px; border-top: 1px solid var(--line-soft);
    background: var(--bg-softer); font-size: .9rem; color: var(--muted);
}
.auth-foot a, .auth-link { color: var(--green-600); font-weight: 800; }
.auth-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; }

/* Input with leading icon + password reveal */
.input-wrap { position: relative; }
.input-wrap .in-ico {
    position: absolute; inset-inline-start: .9rem; top: 50%; transform: translateY(-50%);
    color: var(--muted-2); pointer-events: none; font-size: .95rem;
}
.input-wrap .input { padding-inline-start: 2.5rem; }
.input-wrap .toggle-pass {
    position: absolute; inset-inline-end: .55rem; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--muted); cursor: pointer; padding: .35rem;
}

/* Segmented control (account-type / role picker) */
.seg { display: flex; gap: 6px; background: var(--bg-soft); padding: 5px; border-radius: var(--radius-sm); margin-bottom: 18px; }
.seg button {
    flex: 1; padding: .65rem .5rem; border: none; background: transparent; border-radius: 8px;
    font-weight: 800; color: var(--muted); cursor: pointer; font-family: inherit;
    transition: var(--transition); font-size: .88rem;
}
.seg button.active { background: #fff; color: var(--green-600); box-shadow: var(--shadow-sm); }

/* OTP code inputs */
.otp-row { display: flex; gap: 9px; direction: ltr; justify-content: center; margin: 10px 0 6px; }
.otp-row input {
    width: 46px; height: 56px; text-align: center; font-size: 1.5rem; font-weight: 800;
    border: 1.5px solid var(--line); border-radius: var(--radius-sm); color: var(--navy); background: #fff;
}
.otp-row input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(34,181,115,.12); outline: none; }

/* Inline notice (errors / success inside auth body) */
.notice { padding: .8rem 1rem; border-radius: var(--radius-sm); font-size: .88rem; font-weight: 600; margin-bottom: 16px; display: none; line-height: 1.7; }
.notice.show { display: block; }
.notice-error { background: var(--danger-50); color: #991b1b; border: 1px solid #fecaca; }
.notice-success { background: var(--green-50); color: #047857; border: 1px solid #a7f3d0; }
.notice-info { background: #eef2f9; color: var(--navy); border: 1px solid #c7d2e6; }

/* ===================================================================== */
/* Dashboard primitives (stat cards / tabs / messaging) — shared         */
/* ===================================================================== */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.stat-card .stat-ico { width: 42px; height: 42px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; background: var(--green-50); color: var(--green-600); }
.stat-card .stat-ico.navy { background: #EEF1F7; color: var(--navy); }
.stat-card .stat-ico.warn { background: var(--warning-50); color: var(--warning); }
.stat-card .stat-val { font-size: 1.6rem; font-weight: 900; color: var(--navy); line-height: 1; }
.stat-card .stat-lbl { font-size: .82rem; color: var(--muted); font-weight: 700; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: .75rem 1.1rem; border: none; background: none; font-weight: 800; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; font-family: inherit; white-space: nowrap; font-size: .92rem; }
.tab.active { color: var(--green-600); border-bottom-color: var(--green); }
.tab-panel { display: none; } .tab-panel.active { display: block; }

.msg-layout { display: grid; grid-template-columns: 1fr; gap: 16px; }
.conv-list { display: flex; flex-direction: column; gap: 6px; max-height: 540px; overflow-y: auto; }
.conv-item { display: flex; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; align-items: center; background: #fff; transition: var(--transition); }
.conv-item.active, .conv-item:hover { border-color: var(--green); background: var(--green-50); }
.conv-avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--bg-soft); display: flex; align-items: center; justify-content: center; color: var(--navy); font-weight: 800; flex-shrink: 0; overflow: hidden; }
.conv-avatar img { width: 100%; height: 100%; object-fit: cover; }
.conv-meta { min-width: 0; flex: 1; }
.conv-name { font-weight: 800; color: var(--navy); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-last { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-unread { background: var(--green); color: #fff; border-radius: 999px; font-size: .7rem; font-weight: 800; padding: .1rem .45rem; min-width: 20px; text-align: center; }

.thread { border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; height: 540px; background: #fff; }
.thread-head { padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 800; color: var(--navy); display: flex; align-items: center; gap: 10px; }
.thread-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--bg-softer); }
.bubble { max-width: 78%; padding: .6rem .9rem; border-radius: 14px; font-size: .9rem; line-height: 1.55; word-break: break-word; }
.bubble.in { background: #fff; border: 1px solid var(--line); align-self: flex-start; border-bottom-right-radius: 4px; }
.bubble.out { background: var(--green); color: #fff; align-self: flex-end; border-bottom-left-radius: 4px; }
.bubble .b-time { display: block; font-size: .68rem; opacity: .75; margin-top: 4px; }
.thread-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: #fff; }
.thread-input .input { flex: 1; }

@media (min-width: 700px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 760px) { .msg-layout { grid-template-columns: 320px 1fr; } }
