/* =========================================================
   Wabel Plus — Shared Stylesheet
   Theme: navy (#1B2A4A) + gold (#C9A84C), Almarai (Arabic/RTL)
   Supports dark/light mode and AR/EN language toggle
   ========================================================= */

:root {
    --primary: #1B2A4A;
    --primary-dark: #0F1B33;
    --primary-light: #E8ECF5;
    --primary-gradient: linear-gradient(135deg, #1B2A4A 0%, #2C4A7E 100%);
    --gold: #C9A84C;
    --gold-light: #F5EDD6;
    --accent: #E8573A;
    --blue: #2D7DD2;

    --bg: #F4F6FB;
    --surface: #FFFFFF;
    --surface-2: #F1F4FA;
    --text: #1B2A4A;
    --text-muted: #6B7896;
    --border: #E3E8F2;
    --on-primary: #FFFFFF;

    --shadow: 0 2px 12px rgba(27, 42, 74, 0.06);
    --shadow-lg: 0 8px 30px rgba(27, 42, 74, 0.12);
    --radius: 16px;
    --radius-sm: 10px;

    --header-h: 60px;
    --nav-h: 64px;
    --maxw: 720px;
    --font: 'Almarai', 'Segoe UI', Tahoma, sans-serif;
}

html[data-theme="dark"] {
    --bg: #0B1322;
    --surface: #15233F;
    --surface-2: #1B2A4A;
    --text: #E8ECF5;
    --text-muted: #8FA0C0;
    --border: #243453;
    --primary-light: #1B2A4A;
    --gold-light: #3A3320;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.55);
}

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

html, body { height: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background 0.3s, color 0.3s;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; display: block; }

/* ---------- layout ---------- */
.app { min-height: 100%; display: flex; flex-direction: column; }
.app-main {
    flex: 1;
    width: 100%;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 16px 14px calc(var(--nav-h) + 24px);
}
.app-main.no-nav { padding-bottom: 40px; }

/* ---------- header ---------- */
.app-header {
    position: sticky; top: 0; z-index: 30;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.app-header-inner {
    max-width: var(--maxw); margin: 0 auto;
    height: var(--header-h);
    display: flex; align-items: center; gap: 12px;
    padding: 0 14px;
}
.h-btn-back {
    width: 38px; height: 38px; border-radius: 50%;
    border: none; background: var(--surface-2); color: var(--text);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 18px; flex-shrink: 0;
}
.h-title { font-size: 17px; font-weight: 800; flex: 1; }
.h-actions { display: flex; gap: 6px; }
.h-btn {
    width: 40px; height: 40px; border-radius: 50%;
    border: none; background: transparent; color: var(--text);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 18px; position: relative;
}
.h-btn:active { background: var(--surface-2); }
.h-badge {
    position: absolute; top: 4px; right: 4px;
    background: var(--accent); color: #fff; font-size: 9px; font-weight: 800;
    min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px;
    display: flex; align-items: center; justify-content: center; border: 2px solid var(--surface);
}

/* brand header (home-like) */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--primary-gradient); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.brand-text { font-weight: 800; font-size: 16px; line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--text-muted); font-weight: 700; }

/* ---------- bottom nav ---------- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(27, 42, 74, 0.08);
    display: flex; justify-content: space-around; align-items: stretch;
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.bn-item {
    flex: 1; background: none; border: none; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 4px; color: var(--text-muted);
    font-size: 11px; font-weight: 700; position: relative;
    transition: color 0.2s; text-decoration: none;
}
.bn-item i { font-size: 20px; }
.bn-item.active { color: var(--primary); }
.bn-cart .bn-badge {
    position: absolute; top: 2px; right: 50%; transform: translateX(20px);
    background: var(--accent); color: #fff; font-size: 9px; font-weight: 800;
    min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px;
    display: flex; align-items: center; justify-content: center; border: 2px solid var(--surface);
}

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: none; border-radius: var(--radius-sm); cursor: pointer;
    font-weight: 800; font-size: 14px; padding: 12px 18px; transition: 0.2s;
    font-family: var(--font);
}
.btn-primary { background: var(--primary-gradient); color: #fff; box-shadow: var(--shadow); }
.btn-primary:active { transform: translateY(1px); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--border); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-danger { background: var(--accent); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* ---------- cards ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
    margin-bottom: 14px;
}
.card-title { font-size: 15px; font-weight: 800; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card-title i { color: var(--primary); }
.section-label { font-size: 13px; font-weight: 800; color: var(--text-muted); margin: 18px 4px 8px; }

/* ---------- menu list ---------- */
.menu-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; }
.menu-item {
    display: flex; align-items: center; gap: 12px; padding: 14px 16px;
    border-bottom: 1px solid var(--border); cursor: pointer; text-decoration: none; color: inherit;
    transition: background 0.15s;
}
.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: var(--surface-2); }
.mi-icon {
    width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
    background: var(--primary-light); color: var(--primary);
    display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.mi-icon.gold { background: var(--gold-light); color: var(--gold); }
.mi-icon.accent { background: rgba(232, 87, 58, 0.12); color: var(--accent); }
.mi-icon.blue { background: rgba(45, 125, 210, 0.12); color: var(--blue); }
.mi-body { flex: 1; min-width: 0; }
.mi-title { font-size: 14px; font-weight: 700; }
.mi-sub { font-size: 12px; color: var(--text-muted); }
.mi-end { color: var(--text-muted); font-size: 16px; display: flex; align-items: center; gap: 8px; }
.mi-value { font-size: 13px; font-weight: 700; color: var(--text); }

/* ---------- switch ---------- */
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute; inset: 0; background: var(--border); border-radius: 20px; cursor: pointer; transition: 0.25s;
}
.switch .slider::before {
    content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%; transition: 0.25s; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }
html:not([dir="rtl"]) .switch input:checked + .slider::before { transform: translateX(20px); }
html[dir="rtl"] .switch input:checked + .slider::before { transform: translateX(-20px); }

/* ---------- forms ---------- */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--text-muted); }
.input, .select {
    width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); font-family: var(--font); font-size: 14px; outline: none; transition: 0.2s;
}
.input:focus, .select:focus { border-color: var(--primary); }
.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; }

/* ---------- wallet ---------- */
.wallet-card {
    background: var(--primary-gradient); color: #fff; border-radius: var(--radius);
    padding: 22px; margin-bottom: 14px; position: relative; overflow: hidden; box-shadow: var(--shadow-lg);
}
.wallet-card::after {
    content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px;
    background: rgba(255,255,255,0.08); border-radius: 50%;
}
.wallet-label { font-size: 13px; opacity: 0.85; font-weight: 700; }
.wallet-balance { font-size: 34px; font-weight: 800; margin: 6px 0 14px; letter-spacing: 0.5px; }
.wallet-actions { display: flex; gap: 10px; position: relative; z-index: 1; }
.wallet-btn {
    flex: 1; background: rgba(255,255,255,0.16); border: 1px solid rgba(255,255,255,0.3);
    color: #fff; border-radius: var(--radius-sm); padding: 10px; font-weight: 800; font-size: 13px;
    cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; transition: 0.2s;
}
.wallet-btn:active { background: rgba(255,255,255,0.28); }

/* ---------- payment methods ---------- */
.pm-card {
    display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); margin-bottom: 10px; background: var(--surface);
}
.pm-logo {
    width: 46px; height: 32px; border-radius: 6px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; color: #fff; font-size: 16px;
}
.pm-logo.visa { background: #1A1F71; }
.pm-logo.master { background: #EB001B; }
.pm-logo.mada { background: #00AEEF; }
.pm-logo.apple { background: #000; }
.pm-logo.paypal { background: #003087; }
.pm-body { flex: 1; }
.pm-name { font-weight: 700; font-size: 14px; }
.pm-num { font-size: 12px; color: var(--text-muted); }
.pm-default { font-size: 10px; background: var(--gold-light); color: var(--gold); font-weight: 800; padding: 2px 8px; border-radius: 20px; }
.pm-del { color: var(--accent); cursor: pointer; background: none; border: none; font-size: 16px; }

/* ---------- profile header ---------- */
.profile-head { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 10px 0 18px; }
.avatar {
    width: 84px; height: 84px; border-radius: 50%;
    background: var(--primary-gradient); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: 800;
    border: 3px solid var(--surface); box-shadow: var(--shadow); margin-bottom: 10px; position: relative;
}
.avatar-edit {
    position: absolute; bottom: 0; right: 0; width: 26px; height: 26px; border-radius: 50%;
    background: var(--gold); color: #fff; border: 2px solid var(--surface); cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.profile-name { font-size: 19px; font-weight: 800; }
.profile-meta { font-size: 13px; color: var(--text-muted); }
.profile-stats { display: flex; gap: 0; width: 100%; max-width: 320px; margin-top: 14px; }
.pstat { flex: 1; text-align: center; }
.pstat + .pstat { border-inline-start: 1px solid var(--border); }
.pstat .n { font-size: 17px; font-weight: 800; color: var(--primary); }
.pstat .l { font-size: 11px; color: var(--text-muted); }

/* ---------- FAQ accordion ---------- */
.faq-item { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; background: var(--surface); overflow: hidden; }
.faq-q {
    width: 100%; text-align: start; background: none; border: none; cursor: pointer;
    padding: 14px 16px; font-size: 14px; font-weight: 700; color: var(--text);
    display: flex; align-items: center; justify-content: space-between; gap: 10px; font-family: var(--font);
}
.faq-q i { transition: transform 0.25s; color: var(--text-muted); }
.faq-item.open .faq-q i { transform: rotate(180deg); }
.faq-a { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.faq-a-inner { padding: 0 16px 14px; font-size: 13px; color: var(--text-muted); line-height: 1.7; }

/* ---------- legal text ---------- */
.legal h1 { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.legal .updated { font-size: 12px; color: var(--text-muted); margin-bottom: 18px; }
.legal h2 { font-size: 16px; font-weight: 800; margin: 20px 0 8px; color: var(--primary); }
.legal p { font-size: 13.5px; color: var(--text-muted); margin-bottom: 10px; line-height: 1.8; }
.legal ul { margin: 0 0 10px 20px; color: var(--text-muted); font-size: 13.5px; }
.legal li { margin-bottom: 6px; line-height: 1.7; }

/* ---------- search / help ---------- */
.search-bar { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 16px; }
.search-bar i { color: var(--text-muted); }
.search-bar input { border: none; outline: none; flex: 1; background: none; color: var(--text); font-family: var(--font); font-size: 14px; }
.help-cat { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
.help-cat .hc {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; text-align: center; cursor: pointer; box-shadow: var(--shadow); transition: 0.2s;
}
.help-cat .hc:active { transform: translateY(1px); }
.help-cat .hc i { font-size: 24px; color: var(--primary); margin-bottom: 8px; }
.help-cat .hc div { font-size: 13px; font-weight: 700; }

/* ---------- language toggle (header) ---------- */
.lang-pill {
    display: flex; align-items: center; background: var(--surface-2); border-radius: 20px; padding: 3px; gap: 2px;
}
.lang-pill button {
    border: none; background: none; cursor: pointer; font-weight: 800; font-size: 12px;
    padding: 5px 10px; border-radius: 16px; color: var(--text-muted); font-family: var(--font);
}
.lang-pill button.active { background: var(--primary); color: #fff; }

/* ---------- toast ---------- */
.toast {
    position: fixed; bottom: calc(var(--nav-h) + 20px); left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--primary-dark); color: #fff; padding: 12px 20px; border-radius: 30px;
    font-size: 13px; font-weight: 700; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
    transition: 0.3s; z-index: 80; max-width: 90%; text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast-icon { margin-inline-end: 6px; }

/* ---------- FAB + AI chat ---------- */
.ai-fab {
    position: fixed; bottom: calc(var(--nav-h) + 18px); right: 18px; z-index: 60;
    width: 58px; height: 58px; border-radius: 50%;
    background: var(--primary-gradient); color: #fff; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 24px;
    box-shadow: 0 8px 24px rgba(27, 42, 74, 0.35); transition: transform 0.2s, box-shadow 0.2s;
}
.ai-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(27, 42, 74, 0.45); }
.ai-fab-dot { position: absolute; top: 11px; right: 13px; width: 11px; height: 11px; border-radius: 50%; background: var(--gold); border: 2px solid #fff; }
.ai-chat {
    position: fixed; bottom: calc(var(--nav-h) + 88px); right: 18px; z-index: 60;
    width: 330px; max-width: calc(100vw - 32px); background: var(--surface); border-radius: 16px;
    box-shadow: 0 16px 50px rgba(27, 42, 74, 0.28); border: 1px solid var(--border);
    display: none; flex-direction: column; overflow: hidden; font-family: var(--font);
}
.ai-chat.show { display: flex; animation: aiPop 0.2s ease-out; }
@keyframes aiPop { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.ai-chat-header { background: var(--primary-gradient); color: #fff; padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.ai-chat-header i { font-size: 20px; }
.ai-chat-header .ai-t { font-weight: 800; font-size: 14px; line-height: 1.2; }
.ai-chat-header .ai-s { font-size: 11px; opacity: 0.85; }
.ai-chat-close { margin-inline-start: auto; background: none; border: none; color: #fff; font-size: 18px; cursor: pointer; }
.ai-chat-body { padding: 14px; height: 230px; overflow-y: auto; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }
.ai-msg { max-width: 85%; padding: 8px 12px; border-radius: 12px; font-size: 13px; line-height: 1.5; }
.ai-msg.bot { background: var(--surface); color: var(--text); align-self: flex-start; border-bottom-right-radius: 4px; }
.ai-msg.user { background: var(--primary); color: #fff; align-self: flex-end; border-bottom-left-radius: 4px; }
.ai-chat-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); background: var(--surface); }
.ai-chat-input input { flex: 1; border: 1px solid var(--border); border-radius: 20px; padding: 8px 14px; font-family: var(--font); font-size: 13px; outline: none; background: var(--surface); color: var(--text); }
.ai-chat-input input:focus { border-color: var(--primary); }
.ai-chat-input button { background: var(--primary); color: #fff; border: none; border-radius: 50%; width: 38px; height: 38px; cursor: pointer; flex-shrink: 0; }
.ai-typing { align-self: flex-start; font-size: 12px; color: var(--text-muted); padding: 0 4px; }

/* ---------- language visibility ----------
   Works for both inline labels (<span class="lang-ar">) and
   full block sections (<div class="lang-ar legal">) */
html:not(.en) .lang-en { display: none; }
html.en .lang-ar { display: none; }
html.en { direction: ltr; }
html:not(.en) { direction: rtl; }

/* ---------- responsive ---------- */
@media (min-width: 901px) {
    .bottom-nav { display: none; }
    .app-main { padding-bottom: 40px; }
    .ai-fab { bottom: 24px; right: 24px; }
    .ai-chat { bottom: 96px; right: 24px; }
    .toast { bottom: 30px; }
}
@media (max-width: 480px) {
    .help-cat { grid-template-columns: repeat(2, 1fr); }
    .wallet-balance { font-size: 28px; }
}
