/* Yaqinly — Auth UI (header island + modal + dropdown)
   Palette: --gold, --gold-light, --bg-primary, --text-primary already exist on site.
   Glass beige/or/nuit, premium spacing, RTL aware via [dir="rtl"]. */

:root {
    --auth-radius: 14px;
    --auth-radius-sm: 10px;
    --auth-glass-bg: color-mix(in srgb, var(--bg-primary, #fff) 78%, transparent);
    --auth-glass-border: color-mix(in srgb, var(--gold, #D4A574) 30%, transparent);
    --auth-shadow: 0 24px 60px -18px rgba(20, 16, 10, .35), 0 6px 18px -8px rgba(20, 16, 10, .18);
    --auth-text: var(--text-primary, #1a1410);
    --auth-text-soft: color-mix(in srgb, var(--auth-text) 65%, transparent);
    --auth-gold: var(--gold, #D4A574);
    --auth-gold-soft: color-mix(in srgb, var(--auth-gold) 18%, transparent);
}

[data-theme="dark"] {
    --auth-glass-bg: color-mix(in srgb, #161310 82%, transparent);
}

/* ────── Header island ────── */
.auth-island {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-inline-start: 4px;
    position: relative;
}

.auth-out, .auth-in { display: inline-flex; align-items: center; gap: 6px; }
.auth-in[hidden], .auth-out[hidden] { display: none !important; }

.auth-btn {
    appearance: none;
    border: 1px solid transparent;
    background: transparent;
    color: var(--auth-text);
    font: 500 13px/1 inherit;
    padding: 8px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease, color .18s ease, transform .12s ease;
    white-space: nowrap;
}
.auth-btn:hover { background: var(--auth-gold-soft); }
.auth-btn:active { transform: translateY(1px); }
.auth-btn-ghost { color: var(--auth-text); border-color: color-mix(in srgb, var(--auth-text) 14%, transparent); }
.auth-btn-gold {
    background: linear-gradient(135deg, var(--gold-light, #E8C9A0), var(--auth-gold));
    color: #1a1410;
    border-color: transparent;
    box-shadow: 0 4px 14px -6px color-mix(in srgb, var(--auth-gold) 60%, transparent);
    font-weight: 600;
}
.auth-btn-gold:hover { filter: brightness(1.05); background: linear-gradient(135deg, var(--gold-light, #E8C9A0), var(--auth-gold)); }

@media (max-width: 640px) {
    .auth-out .auth-btn-text { display: none; }
    .auth-out .auth-btn { padding: 8px 10px; }
    .auth-out .auth-btn::before {
        content: ""; display: inline-block; width: 18px; height: 18px;
        background: currentColor;
        -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10zm0 2c-4.418 0-8 2.91-8 6.5V22h16v-1.5c0-3.59-3.582-6.5-8-6.5z'/></svg>") center/contain no-repeat;
                mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10zm0 2c-4.418 0-8 2.91-8 6.5V22h16v-1.5c0-3.59-3.582-6.5-8-6.5z'/></svg>") center/contain no-repeat;
    }
}

/* ────── Trigger (logged in) ────── */
.auth-trigger {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 4px 10px 4px 4px;
    background: transparent; border: 1px solid color-mix(in srgb, var(--auth-text) 12%, transparent);
    border-radius: 999px;
    cursor: pointer;
    color: var(--auth-text);
    transition: background .18s ease, border-color .18s ease;
    font: 500 13px/1 inherit;
    max-width: 220px;
}
.auth-trigger:hover { background: var(--auth-gold-soft); border-color: var(--auth-glass-border); }
.auth-trigger[aria-expanded="true"] { background: var(--auth-gold-soft); border-color: var(--auth-glass-border); }

.auth-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--gold-light, #E8C9A0), var(--auth-gold));
    color: #1a1410;
    overflow: hidden;
    flex-shrink: 0;
}
.auth-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.auth-avatar img[hidden] { display: none; }

.auth-name {
    max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.auth-chevron { opacity: .6; transition: transform .18s ease; }
.auth-trigger[aria-expanded="true"] .auth-chevron { transform: rotate(180deg); }

@media (max-width: 640px) { .auth-name { display: none; } }

/* ────── Dropdown menu ────── */
.auth-menu {
    position: absolute;
    top: calc(100% + 10px);
    inset-inline-end: 0;
    width: 320px; max-width: calc(100vw - 24px);
    background: var(--auth-glass-bg);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border: 1px solid var(--auth-glass-border);
    border-radius: var(--auth-radius);
    box-shadow: var(--auth-shadow);
    padding: 8px;
    color: var(--auth-text);
    opacity: 0; transform: translateY(-6px) scale(.98);
    transition: opacity .18s ease, transform .22s cubic-bezier(.2,.8,.2,1);
    pointer-events: none;
    z-index: 1100;
}
.auth-menu:not([hidden]) { opacity: 1; transform: none; pointer-events: auto; }
.auth-menu[hidden] { display: none; }

.auth-menu-greeting {
    padding: 14px 14px 12px;
    border-radius: var(--auth-radius-sm);
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--auth-gold) 14%, transparent),
        color-mix(in srgb, var(--auth-gold) 4%, transparent));
    margin-bottom: 6px;
    display: flex; flex-direction: column; gap: 2px;
}
.auth-menu-salam { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--auth-text-soft); }
.auth-menu-greet-name { font-size: 16px; font-weight: 600; }
.auth-menu-time { font-size: 12px; color: var(--auth-text-soft); }

.auth-menu-section {
    padding: 6px 4px;
    border-top: 1px solid color-mix(in srgb, var(--auth-text) 8%, transparent);
}
.auth-menu-section:first-of-type { border-top: 0; }
.auth-menu-h {
    margin: 8px 10px 4px;
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
    color: var(--auth-text-soft);
}
.auth-menu-row {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 10px;
    border-radius: var(--auth-radius-sm);
    color: var(--auth-text);
    text-decoration: none;
    background: transparent; border: 0; cursor: pointer; width: 100%; text-align: start;
    font: 500 14px/1.2 inherit;
    transition: background .14s ease;
}
.auth-menu-row:hover { background: var(--auth-gold-soft); }
.auth-menu-ico { font-size: 20px; color: var(--auth-gold); flex-shrink: 0; }
.auth-menu-row-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.auth-menu-row-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-menu-row-meta { font-size: 12px; color: var(--auth-text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-menu-logout { color: #c0392b; }
.auth-menu-logout .auth-menu-ico { color: #c0392b; }

[dir="rtl"] .auth-menu { inset-inline-end: auto; inset-inline-start: 0; }

/* ────── Modal ────── */
.auth-modal[hidden] { display: none; }
.auth-modal {
    position: fixed; inset: 0;
    z-index: 1500;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    animation: authFadeIn .25s ease;
}
.auth-modal-backdrop {
    position: absolute; inset: 0;
    background: color-mix(in srgb, #0a0805 60%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.auth-modal-card {
    position: relative;
    width: min(440px, 100%);
    max-height: calc(100vh - 40px); overflow-y: auto;
    background: var(--auth-glass-bg);
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    border: 1px solid var(--auth-glass-border);
    border-radius: 20px;
    box-shadow: var(--auth-shadow);
    color: var(--auth-text);
    padding: 22px 22px 26px;
    transform: translateY(8px) scale(.98);
    animation: authPop .28s cubic-bezier(.2,.8,.2,1) .02s forwards;
}
@keyframes authFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes authPop { to { transform: none; } }

.auth-modal-close {
    position: absolute; top: 10px; inset-inline-end: 10px;
    background: transparent; border: 0; color: var(--auth-text); padding: 6px;
    border-radius: 8px; cursor: pointer; opacity: .7; transition: opacity .15s, background .15s;
}
.auth-modal-close:hover { opacity: 1; background: var(--auth-gold-soft); }

.auth-modal-head { text-align: center; margin-bottom: 18px; }
.auth-modal-mark { display: inline-flex; margin-bottom: 8px; }
.auth-modal-title { font: 600 22px/1.2 inherit; margin: 0 0 4px; }
.auth-modal-sub { color: var(--auth-text-soft); font-size: 13px; margin: 0; }

.auth-tabs {
    display: flex; gap: 2px; padding: 4px;
    background: color-mix(in srgb, var(--auth-text) 5%, transparent);
    border-radius: 12px; margin-bottom: 14px;
}
.auth-tab {
    flex: 1; appearance: none; border: 0;
    background: transparent;
    color: var(--auth-text-soft);
    padding: 8px 10px;
    border-radius: 9px; cursor: pointer;
    font: 500 12.5px/1 inherit;
    transition: background .18s, color .18s;
}
.auth-tab:hover { color: var(--auth-text); }
.auth-tab.is-active {
    background: var(--auth-glass-bg);
    color: var(--auth-text);
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.auth-pane[hidden] { display: none; }
.auth-pane {
    animation: authPaneIn .22s ease;
}
@keyframes authPaneIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.auth-pane-intro { font-size: 13px; color: var(--auth-text-soft); margin: 0 0 12px; }

.auth-form { display: flex; flex-direction: column; gap: 12px; }

.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-label { font-size: 12px; color: var(--auth-text-soft); font-weight: 500; }
.auth-field input,
.auth-field select {
    appearance: none;
    width: 100%;
    background: color-mix(in srgb, var(--bg-primary, #fff) 60%, transparent);
    color: var(--auth-text);
    border: 1px solid color-mix(in srgb, var(--auth-text) 14%, transparent);
    border-radius: var(--auth-radius-sm);
    padding: 11px 13px;
    font: 14px/1.2 inherit;
    transition: border-color .18s, background .18s, box-shadow .18s;
}
.auth-field input:focus,
.auth-field select:focus {
    outline: none;
    border-color: var(--auth-gold);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--auth-gold) 22%, transparent);
}
.auth-hint { color: var(--auth-text-soft); font-size: 11.5px; margin-top: 2px; }

.auth-row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.auth-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--auth-text-soft); cursor: pointer; }
.auth-check-block { display: flex; align-items: flex-start; gap: 10px; line-height: 1.4; }
.auth-check input { accent-color: var(--auth-gold); }
.auth-link { background: transparent; border: 0; color: var(--auth-gold); font: 500 12.5px/1 inherit; cursor: pointer; padding: 4px; }
.auth-link:hover { text-decoration: underline; }

.auth-submit {
    appearance: none; border: 0;
    padding: 12px 16px;
    border-radius: var(--auth-radius-sm);
    font: 600 14px/1 inherit;
    cursor: pointer;
    transition: filter .18s, transform .12s;
}
.auth-submit:hover { filter: brightness(1.05); }
.auth-submit:active { transform: translateY(1px); }
.auth-submit[disabled] { opacity: .6; cursor: progress; }

.auth-feedback {
    padding: 10px 12px; border-radius: 10px;
    font-size: 13px; margin-bottom: 12px;
    border: 1px solid color-mix(in srgb, var(--auth-text) 8%, transparent);
}
.auth-feedback.is-error { background: color-mix(in srgb, #c0392b 10%, transparent); border-color: color-mix(in srgb, #c0392b 30%, transparent); color: #c0392b; }
.auth-feedback.is-ok { background: color-mix(in srgb, #2ecc71 10%, transparent); border-color: color-mix(in srgb, #2ecc71 30%, transparent); color: #1f8a4c; }
.auth-feedback.is-info { background: var(--auth-gold-soft); border-color: var(--auth-glass-border); color: var(--auth-text); }

/* OAuth */
.auth-oauth { margin-top: 6px; }
.auth-oauth-divider { display: flex; align-items: center; gap: 10px; color: var(--auth-text-soft); font-size: 12px; margin: 8px 0 10px; }
.auth-oauth-divider::before, .auth-oauth-divider::after { content: ""; flex: 1; height: 1px; background: color-mix(in srgb, var(--auth-text) 12%, transparent); }
.auth-oauth-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.auth-oauth-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 12px;
    border-radius: var(--auth-radius-sm);
    background: color-mix(in srgb, var(--bg-primary, #fff) 60%, transparent);
    border: 1px solid color-mix(in srgb, var(--auth-text) 14%, transparent);
    color: var(--auth-text); cursor: pointer; font: 500 13px/1 inherit;
    transition: background .15s, border-color .15s;
}
.auth-oauth-btn:hover { background: var(--auth-gold-soft); border-color: var(--auth-glass-border); }

/* Mobile drawer auth section */
.nav-mobile-inner .auth-island { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin: 12px 16px; }
.nav-mobile-inner .auth-island .auth-btn { padding: 12px 16px; text-align: center; }
.nav-mobile-inner .auth-island .auth-out { flex-direction: column; align-items: stretch; }
.nav-mobile-inner .auth-island .auth-out .auth-btn-text { display: inline; }
.nav-mobile-inner .auth-island .auth-menu { position: static; width: 100%; box-shadow: none; }
.nav-mobile-inner .auth-island .auth-trigger { width: 100%; justify-content: flex-start; }

@media (prefers-reduced-motion: reduce) {
    .auth-modal, .auth-modal-card, .auth-pane, .auth-menu { animation: none !important; transition: none !important; }
}
/* TWOFA-BLOCK-V2 — 2FA modal styles (premium spiritual theme) */
.twofa-modal[hidden] { display: none; }
.twofa-modal .twofa-card { max-width: 540px; }

.twofa-status-card {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px;
    border: 1px solid rgba(212, 165, 116, 0.18);
    background: linear-gradient(135deg, rgba(232, 201, 160, 0.05), rgba(212, 165, 116, 0.02));
    border-radius: 14px;
    margin-bottom: 16px;
}
.twofa-status-dot {
    width: 12px; height: 12px; border-radius: 50%;
    background: #b9bdc5; box-shadow: 0 0 0 4px rgba(185, 189, 197, 0.18);
    flex: 0 0 12px;
}
.twofa-status-dot.is-on { background: #2db97a; box-shadow: 0 0 0 4px rgba(45, 185, 122, 0.22); }
.twofa-status-card strong { font-weight: 600; color: var(--text-strong, #0d1226); }
.twofa-status-card small { margin-left: auto; color: var(--text-muted, #5d6677); font-size: 12px; }

.twofa-actions { display: flex; flex-direction: column; gap: 8px; }

.twofa-steps {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-direction: column; gap: 14px;
}
.twofa-steps > li {
    display: grid; grid-template-columns: 32px 1fr; gap: 12px; align-items: start;
}
.twofa-step-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%;
    background: linear-gradient(135deg, var(--gold-light, #E8C9A0), var(--gold, #D4A574));
    color: #fff; font-weight: 700; font-size: 13px;
    box-shadow: 0 2px 8px rgba(212, 165, 116, 0.35);
}
.twofa-step-body { line-height: 1.5; color: var(--text, #2a2f3a); font-size: 14px; }

.twofa-qr-wrap {
    margin-top: 10px;
    padding: 12px;
    background: #fff;
    border: 1px solid rgba(212, 165, 116, 0.25);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 18px rgba(13, 18, 38, 0.06);
    max-width: 240px;
}
.twofa-qr-wrap svg { display: block; width: 100%; height: auto; max-width: 200px; }
.twofa-qr-fallback { color: var(--text-muted, #5d6677); font-size: 13px; margin: 0; padding: 12px; text-align: center; }

.twofa-manual { margin-top: 10px; }
.twofa-manual > summary {
    cursor: pointer; user-select: none;
    color: var(--gold-deep, #b8895a); font-size: 13px; font-weight: 500;
    padding: 6px 0;
}
.twofa-manual-text { font-size: 12px; color: var(--text-muted, #5d6677); margin: 6px 0 4px; }
.twofa-secret {
    display: inline-block;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
    font-size: 14px; letter-spacing: 0.08em;
    background: rgba(232, 201, 160, 0.12);
    border: 1px solid rgba(212, 165, 116, 0.25);
    color: var(--text-strong, #0d1226);
    padding: 6px 10px; border-radius: 6px;
    word-break: break-all;
    margin-right: 8px;
}

.twofa-verify-form { margin-top: 10px; }
.twofa-verify-form input[name="code"],
[data-twofa-form="disable"] input[name="code"] {
    text-align: center; letter-spacing: 0.4em; font-size: 22px; font-weight: 600;
    font-variant-numeric: tabular-nums;
}

[dir="rtl"] .twofa-status-card small { margin-left: 0; margin-right: auto; }
[dir="rtl"] .twofa-secret { margin-right: 0; margin-left: 8px; }
[dir="rtl"] .twofa-steps > li { grid-template-columns: 1fr 32px; }

@media (max-width: 480px) {
    .twofa-modal .twofa-card { max-width: 95vw; padding: 18px; }
    .twofa-qr-wrap { max-width: 200px; }
    .twofa-qr-wrap svg { max-width: 170px; }
}

/* Design-system alignment */
.auth-modal-card,
.auth-menu {
    background: color-mix(in srgb, var(--bg-card) 92%, transparent);
    border-color: var(--border-color);
}

.auth-label,
.auth-menu-h,
.auth-menu-time,
.auth-menu-salam,
.auth-pane-intro,
.auth-modal-sub,
.auth-hint {
    color: var(--text-muted);
}

.auth-field input,
.auth-field select,
.auth-oauth-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.auth-menu-row-title,
.auth-menu-greet-name,
.auth-modal-title,
.auth-tab.is-active,
.auth-trigger,
.auth-name {
    color: var(--text-primary);
}

.auth-trigger,
.auth-btn-ghost,
.auth-menu-row,
.auth-tab {
    border-color: var(--border-color);
}

.auth-menu-row:hover,
.auth-tab:hover,
.auth-trigger:hover,
.auth-btn-ghost:hover,
.auth-oauth-btn:hover {
    background: var(--accent-soft);
}

.auth-submit.auth-btn-gold,
.auth-btn-gold {
    background: linear-gradient(135deg, #e7cf8a, var(--accent-gold));
    color: #111;
}

.auth-tab.is-active {
    background: var(--bg-card);
}

.auth-btn:focus-visible,
.auth-trigger:focus-visible,
.auth-menu-row:focus-visible,
.auth-field input:focus-visible,
.auth-field select:focus-visible,
.auth-tab:focus-visible,
.auth-submit:focus-visible,
.auth-oauth-btn:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
}

