/* ==========================================================================
   Al Hallaq — web app styles (customer + barber)
   Black & gold brand, light / dark themes, RTL, mobile first.
   ========================================================================== */

:root {
    --bg: #F6F3EC;
    --surface: #FFFFFF;
    --surface-2: #FBF8F1;
    --text: #16181D;
    --muted: #6E6759;
    --line: #E8E0CE;
    --gold: #A9822F;
    --gold-2: #D9B866;
    --gold-soft: rgba(176, 138, 62, .12);
    --on-gold: #15110A;
    --success: #1F8A5B;
    --success-soft: rgba(31, 138, 91, .12);
    --danger: #C2413B;
    --danger-soft: rgba(194, 65, 59, .1);
    --shadow: 0 1px 2px rgba(22, 24, 29, .04), 0 8px 24px rgba(22, 24, 29, .06);
    --radius: 18px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #090C11;
        --surface: #121821;
        --surface-2: #18202B;
        --text: #F2EEE5;
        --muted: #9C968A;
        --line: #242C38;
        --gold: #D4AF5A;
        --gold-2: #F0D48A;
        --gold-soft: rgba(212, 175, 90, .12);
        --success: #3CC48A;
        --success-soft: rgba(60, 196, 138, .12);
        --danger: #F06B63;
        --danger-soft: rgba(240, 107, 99, .12);
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .35);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #090C11;
    --surface: #121821;
    --surface-2: #18202B;
    --text: #F2EEE5;
    --muted: #9C968A;
    --line: #242C38;
    --gold: #D4AF5A;
    --gold-2: #F0D48A;
    --gold-soft: rgba(212, 175, 90, .12);
    --success: #3CC48A;
    --success-soft: rgba(60, 196, 138, .12);
    --danger: #F06B63;
    --danger-soft: rgba(240, 107, 99, .12);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .35);
    color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Cairo', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3, p { margin: 0; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.gold { color: var(--gold); }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 20px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[x-cloak] { display: none !important; }

/* ---------- shell ---------- */
.shell { max-width: 560px; margin: 0 auto; padding: 0 16px 112px; }
.shell.wide { max-width: 980px; }

.topbar {
    position: sticky; top: 0; z-index: 20;
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: saturate(140%) blur(14px);
    -webkit-backdrop-filter: saturate(140%) blur(14px);
    border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: 980px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 18px; letter-spacing: -.2px; }
.brand small { display: block; font-size: 10px; font-weight: 800; letter-spacing: 2.4px; color: var(--gold); line-height: 1; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; flex: none; overflow: hidden; }
.topnav { display: none; margin-inline-start: auto; gap: 4px; }
.topnav a {
    padding: 8px 14px; border-radius: 999px; font-weight: 700; color: var(--muted);
    transition: background .15s, color .15s;
}
.topnav a:hover { color: var(--text); background: var(--surface-2); }
.topnav a.active { color: var(--on-gold); background: var(--gold); }

.icon-btn {
    width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
    border: 1px solid var(--line); background: var(--surface); cursor: pointer; color: var(--text);
    transition: border-color .15s, transform .1s;
}
.icon-btn:hover { border-color: var(--gold); }
.icon-btn:active { transform: scale(.96); }
.icon-btn svg { width: 20px; height: 20px; }
.theme-toggle { margin-inline-start: auto; }

.tabbar {
    position: fixed; z-index: 30; bottom: 0; inset-inline: 0;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
    display: flex; justify-content: space-around;
}
.tabbar a {
    flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 0; border-radius: 14px; font-size: 12px; font-weight: 700; color: var(--muted);
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.active { color: var(--gold); }
.tabbar a.active .tab-pill { background: var(--gold-soft); }
.tab-pill { padding: 4px 18px; border-radius: 999px; display: grid; place-items: center; transition: background .2s; }

@media (min-width: 820px) {
    .topnav { display: flex; }
    .theme-toggle { margin-inline-start: 0; }
    .tabbar { display: none; }
    .shell { padding-bottom: 48px; }
}

.page-head { padding: 24px 0 8px; }
.page-head h1 { font-size: 26px; font-weight: 900; letter-spacing: -.4px; line-height: 1.3; }
.page-head p { color: var(--muted); }

/* ---------- cards ---------- */
.card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px; box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; }
.card.tight { padding: 14px; }
a.card { display: block; transition: border-color .15s, transform .15s; }
a.card:hover { border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); }
a.card:active { transform: scale(.99); }
.card-title { font-weight: 900; font-size: 17px; }
.section-title { font-weight: 900; font-size: 17px; margin: 28px 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title .count {
    font-size: 12px; font-weight: 800; padding: 1px 9px; border-radius: 999px; background: var(--surface-2);
    border: 1px solid var(--line); color: var(--muted);
}

.gold-card {
    position: relative; overflow: hidden; border-radius: 24px; padding: 22px;
    background: linear-gradient(135deg, #8E6B26 0%, #C9A04A 45%, #E9CF86 100%);
    color: var(--on-gold); box-shadow: 0 14px 34px rgba(169, 130, 47, .28);
}
.gold-card::after {
    content: ""; position: absolute; inset: -40% -20% auto auto; width: 260px; height: 260px; border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, .35), transparent 65%); pointer-events: none;
}
.gold-card .muted { color: rgba(21, 17, 10, .7); }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 52px; padding: 0 22px; border-radius: 14px; border: 1px solid transparent;
    font-weight: 800; font-size: 16px; cursor: pointer; white-space: nowrap;
    transition: transform .1s, filter .15s, background .15s, border-color .15s, opacity .15s;
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn:active { transform: scale(.98); }
.btn[disabled], .btn.disabled { opacity: .45; pointer-events: none; }
.btn-block { width: 100%; }
.btn-sm { height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn-gold { background: linear-gradient(135deg, #B8913E, #D9B866); color: var(--on-gold); box-shadow: 0 6px 18px rgba(184, 145, 62, .3); }
.btn-gold:hover { filter: brightness(1.05); }
.btn-dark { background: var(--text); color: var(--bg); }
.btn-outline { background: transparent; border-color: var(--line); color: var(--text); }
.btn-outline:hover { border-color: var(--gold); color: var(--gold); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn-danger:hover { background: var(--danger-soft); }
.btn .spinner { display: none; }
.btn[data-loading] .spinner, .btn.is-loading .spinner { display: inline-block; }

.spinner {
    width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */
.label { display: block; font-weight: 800; font-size: 14px; margin-bottom: 6px; }
.field {
    width: 100%; height: 52px; padding: 0 16px; border-radius: 14px;
    border: 1px solid var(--line); background: var(--surface); color: var(--text); outline: none;
    transition: border-color .15s, box-shadow .15s;
}
textarea.field { height: auto; padding: 12px 16px; }
.field::placeholder { color: var(--muted); opacity: .8; }
.field:focus { border-color: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); }
.field-icon { position: relative; }
.field-icon svg { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--muted); pointer-events: none; }
.field-icon .field { padding-inline-start: 44px; }
.field-icon .field.ltr { padding-left: 16px; padding-right: 44px; } /* LTR input (phone) inside the RTL layout */
.otp-field { text-align: center; font-size: 30px; letter-spacing: 14px; font-weight: 900; height: 64px; }
.error { color: var(--danger); font-size: 13px; font-weight: 700; margin-top: 6px; }
.alert {
    padding: 12px 14px; border-radius: 14px; font-weight: 700; font-size: 14px;
    background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
}
.alert.info { background: var(--gold-soft); color: var(--gold); border-color: color-mix(in srgb, var(--gold) 30%, transparent); }
.alert.success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
    width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
    font-size: 20px; font-weight: 800; cursor: pointer;
}
.stepper button:hover { border-color: var(--gold); color: var(--gold); }
.stepper output { min-width: 40px; text-align: center; font-size: 18px; font-weight: 900; }

/* ---------- chips & badges ---------- */
.chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px;
    font-size: 12px; font-weight: 800; background: var(--gold-soft); color: var(--gold); white-space: nowrap;
}
.chip.success { background: var(--success-soft); color: var(--success); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip .dot.live { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

.filter-chip {
    display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 14px; cursor: pointer;
}
.filter-chip svg { width: 16px; height: 16px; }
.filter-chip.on { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }

.segmented { display: inline-flex; padding: 4px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.segmented button {
    border: 0; background: transparent; padding: 7px 16px; border-radius: 10px; font-weight: 800; font-size: 14px;
    color: var(--muted); cursor: pointer;
}
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- salon list ---------- */
.salon-item, a.card.salon-item, a.card.row { display: flex; align-items: center; gap: 14px; }
.avatar {
    width: 58px; height: 58px; border-radius: 16px; flex: none; display: grid; place-items: center; overflow: hidden;
    background: var(--gold-soft); color: var(--gold); font-weight: 900; font-size: 22px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 72px; height: 72px; border-radius: 20px; font-size: 28px; }
.eta { text-align: center; flex: none; min-width: 56px; }
.eta b { display: block; font-size: 24px; font-weight: 900; color: var(--gold); line-height: 1.1; }
.eta span { font-size: 11px; color: var(--muted); font-weight: 700; }

/* ---------- stats ---------- */
.stat {
    border-radius: 18px; padding: 14px 10px; text-align: center; background: var(--surface); border: 1px solid var(--line);
}
.stat b { display: block; font-size: 34px; font-weight: 900; line-height: 1.15; letter-spacing: -1px; }
.stat span { font-size: 13px; font-weight: 700; color: var(--muted); }
.stat.gold { background: linear-gradient(135deg, #B8913E, #E3C47A); border-color: transparent; color: var(--on-gold); }
.stat.gold span { color: rgba(21, 17, 10, .72); }
.gold-card .stat { background: rgba(255, 255, 255, .22); border-color: rgba(255, 255, 255, .3); }
.gold-card .stat span { color: rgba(21, 17, 10, .72); }

/* ---------- my ticket ---------- */
.ticket-hero { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ticket-hero .stat b { font-size: 56px; }
.queue-people { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 6px; padding: 8px 0; }
.queue-people svg { width: 28px; height: 28px; color: var(--line); }
.queue-people svg.me { width: 36px; height: 36px; color: var(--gold); }
.queue-people .more { font-weight: 900; color: var(--muted); padding: 0 4px; }
.ring { position: relative; width: 84px; height: 84px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: var(--line); }
.ring .value { stroke: var(--gold); transition: stroke-dashoffset .6s ease; }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 24px; font-weight: 900; }
.called {
    text-align: center; padding: 28px 20px; border-radius: 24px;
    background: linear-gradient(135deg, #8E6B26, #C9A04A 50%, #E9CF86); color: var(--on-gold);
    animation: glow 2s ease-in-out infinite;
}
.called svg { width: 56px; height: 56px; }
.called h2 { font-size: 28px; font-weight: 900; margin-top: 6px; }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(201, 160, 74, .45); } 50% { box-shadow: 0 0 0 14px rgba(201, 160, 74, 0); } }

/* ---------- barber queue ---------- */
.q-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.q-num {
    width: 50px; height: 50px; border-radius: 14px; flex: none; display: grid; place-items: center;
    font-size: 22px; font-weight: 900; border: 1.5px solid var(--gold); color: var(--gold);
}
.q-item.hot { border-color: color-mix(in srgb, var(--gold) 60%, var(--line)); background: var(--gold-soft); }
.q-item.hot .q-num { background: linear-gradient(135deg, #B8913E, #E3C47A); color: var(--on-gold); border-color: transparent; }
.q-actions { display: flex; gap: 6px; flex: none; }
.q-actions .icon-btn.ok { color: var(--success); }
.q-actions .icon-btn.no { color: var(--danger); }
.q-actions .icon-btn.go { color: var(--gold); }

/* live timers */
.timer {
    font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; direction: ltr; unicode-bidi: isolate;
    font-weight: 900; transition: color .3s;
}
.timer.warn { color: #E08A1E; }
.timer.danger { color: var(--danger); }
.q-timer {
    flex: none; text-align: center; min-width: 78px; padding: 6px 10px; border-radius: 12px;
    background: var(--surface); border: 1px solid var(--line);
}
.q-timer .timer { display: block; font-size: 22px; line-height: 1.2; }
.q-timer small { display: block; font-size: 11px; font-weight: 700; color: var(--muted); }
.q-item.serving { border-color: color-mix(in srgb, var(--success) 55%, var(--line)); background: var(--success-soft); }
.q-item.serving .q-num { background: var(--success); color: #fff; border-color: transparent; }
@media (max-width: 480px) {
    .q-item { flex-wrap: wrap; }
    .q-item .q-timer { order: 3; }
}

.switch { position: relative; width: 56px; height: 32px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .2s; }
.switch span::after {
    content: ""; position: absolute; top: 4px; inset-inline-start: 4px; width: 24px; height: 24px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: inset-inline-start .2s;
}
.switch input:checked + span { background: var(--success); }
.switch input:checked + span::after { inset-inline-start: 28px; }

.barber-grid { display: grid; gap: 16px; }
@media (min-width: 820px) {
    .barber-grid { grid-template-columns: 360px 1fr; align-items: start; }
    .barber-grid .sticky { position: sticky; top: 84px; }
}

/* ---------- radio choice cards ---------- */
.choice-list { display: grid; gap: 8px; }
.choice {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; cursor: pointer;
    border: 1.5px solid var(--line); background: var(--surface); transition: border-color .15s, background .15s;
}
.choice:hover { border-color: color-mix(in srgb, var(--gold) 50%, var(--line)); }
.choice input[type="radio"] { width: 18px; height: 18px; accent-color: var(--gold); flex: none; margin: 0; }
.choice b { display: block; font-size: 15px; }
.choice small { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.choice.on { border-color: var(--gold); background: var(--gold-soft); }
.choice.on.danger { border-color: var(--danger); background: var(--danger-soft); }
.choice.on.danger input { accent-color: var(--danger); }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px 4px; }
.modal { max-height: calc(100vh - 32px); overflow-y: auto; }

/* ---------- modal ---------- */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 50; background: rgba(5, 7, 10, .6); backdrop-filter: blur(4px);
    display: grid; place-items: center; padding: 16px;
}
.modal { width: 100%; max-width: 380px; background: var(--surface); border-radius: 24px; padding: 22px; border: 1px solid var(--line); }
.qr-box { background: #fff; border-radius: 18px; padding: 16px; }
.qr-box svg { width: 100%; height: auto; display: block; }

/* ---------- auth ---------- */
.auth {
    min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
    background:
        radial-gradient(900px 500px at 50% -10%, color-mix(in srgb, var(--gold) 22%, transparent), transparent 70%),
        var(--bg);
}
.auth-box { width: 100%; max-width: 400px; }
.auth-logo { width: 104px; height: 104px; border-radius: 28px; margin: 0 auto; overflow: hidden; box-shadow: 0 18px 50px rgba(201, 160, 74, .35); }
.wordmark { text-align: center; margin-top: 18px; }
.wordmark b { display: block; font-size: 40px; font-weight: 900; line-height: 1.1; letter-spacing: -.5px; }
.wordmark span {
    display: block; font-size: 15px; font-weight: 800; letter-spacing: 4px;
    background: linear-gradient(90deg, #A9822F, #E3C47A, #A9822F); -webkit-background-clip: text; background-clip: text; color: transparent;
}

.empty { text-align: center; padding: 48px 16px; }
.empty svg { width: 64px; height: 64px; color: var(--line); margin: 0 auto 12px; }
.empty h3 { font-size: 18px; font-weight: 900; }

.fade-in { animation: fadeIn .35s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

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

/* WhatsApp login */
.wa-code {
    text-align: center;
    font-size: 40px;
    font-weight: 900;
    letter-spacing: 10px;
    padding: 14px 8px;
    border-radius: 16px;
    border: 1.5px dashed var(--gold, #C9A04A);
    color: var(--gold, #C9A04A);
    background: color-mix(in srgb, var(--gold, #C9A04A) 8%, transparent);
}
.wa-waiting {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 14px;
    color: var(--muted, #888);
}
