/* CS Mobile — guest auth (login / password / passkey)
   Brand colors come from Settings via --brand* CSS variables (layouts.app). */

:root {
    --app-bg: #eef1f5;
    --surface: #ffffff;
    --surface-muted: #f7f8fa;
    --brand: #e30613;
    --brand-primary: var(--brand);
    --brand-secondary: #c00010;
    --brand-accent: #f06a72;
    --brand-hover: #c9000c;
    --brand-primary-hover: var(--brand-hover);
    --brand-primary-active: #9f000a;
    --brand-soft: #fff1f2;
    --brand-primary-soft: var(--brand-soft);
    --brand-primary-soft-hover: #ffe4e6;
    --brand-border: #fecdd3;
    --brand-primary-border: var(--brand-border);
    --brand-on-primary: var(--brand-contrast);
    --brand-rgb: 227, 6, 19;
    --brand-contrast: #ffffff;
    --brand-text: var(--brand-contrast);
    --primary: var(--brand);
    --primary-hover: var(--brand-hover);
    --primary-soft: var(--brand-soft);
    --primary-border: var(--brand-border);
    --accent: var(--brand);
    --text-primary: #152033;
    --text-secondary: #5b6b7c;
    --text-muted: #8a97a6;
    --border: #d8dee6;
    --danger: #d92d20;
    --success: #16875b;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 12px 32px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.12);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --cs-red: var(--brand);
    --cs-white: var(--surface);
    --cs-muted: var(--text-secondary);
    --cs-border: var(--border);
    --cs-black: var(--text-primary);
    --focus-ring: 0 0 0 3px rgba(var(--brand-rgb), 0.22);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Inter", "Segoe UI", "Noto Sans Armenian", system-ui, sans-serif;
    background: var(--app-bg);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

.shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: calc(0.65rem + var(--safe-top)) 1.25rem 0.65rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    text-decoration: none;
}
.brand:hover { text-decoration: none; color: var(--text-primary); }
.brand em { font-style: normal; color: var(--primary); }
.brand-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    display: block;
}

.content {
    width: min(1100px, 100%);
    margin: 0 auto;
    padding: 1.25rem 1rem calc(1.5rem + var(--safe-bottom));
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

/* Full-bleed login: hide chrome topbar, let the stage fill the viewport */
body.guest-auth-page .topbar { display: none; }
body.guest-auth-page .content {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    align-items: stretch;
}

.card {
    width: 100%;
    max-width: 400px;
    margin: 2rem auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.35rem 1.25rem;
    box-shadow: var(--shadow-sm);
}

.auth-error-page {
    text-align: center;
    max-width: 440px;
}
.auth-error-page .code {
    display: inline-block;
    min-width: 3.5rem;
    padding: 0.35rem 0.65rem;
    margin-bottom: 0.75rem;
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.04em;
}
.auth-error-page .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1.25rem;
}

.auth-brand-mark {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    margin-bottom: 0.85rem;
    overflow: hidden;
}
.auth-brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.card h1 {
    margin: 0 0 0.35rem;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 44px;
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
    border: 0;
    background: var(--primary);
    color: var(--brand-contrast);
    font-weight: 650;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 140ms ease, box-shadow 140ms ease, transform 140ms ease, opacity 140ms ease;
}
.btn:hover { background: var(--primary-hover); }
.btn:disabled,
.btn[aria-busy="true"] {
    opacity: 0.72;
    cursor: wait;
    transform: none;
}
.btn-primary {
    background: var(--brand-primary);
    color: var(--brand-contrast);
    box-shadow: none;
}
.btn-primary:hover {
    background: var(--brand-hover);
    color: var(--brand-contrast);
}
.btn-ghost {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    box-shadow: none;
}
.btn-ghost:hover { background: var(--surface-muted); }
.btn-sm { min-height: 40px; padding: 0.4rem 0.75rem; font-size: 0.88rem; }

.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.9rem; }
.field label { font-size: 0.85rem; color: var(--text-secondary); font-weight: 600; }
.field input {
    min-height: 44px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-primary);
    padding: 0.6rem 0.8rem;
    font-size: 0.95rem;
    width: 100%;
}
.field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.error { color: var(--danger); font-size: 0.88rem; margin: 0.35rem 0; }
.muted { color: var(--text-secondary); }

:where(a, button, input):focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* ——— Modern login page ——— */
.auth-login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding:
        calc(1rem + var(--safe-top))
        calc(1rem + var(--safe-right))
        calc(1rem + var(--safe-bottom))
        calc(1rem + var(--safe-left));
    background: var(--app-bg);
}

.auth-login-stage {
    width: min(1040px, 100%);
    margin: auto;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
    overflow: hidden;
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: none;
}

.auth-panel {
    min-width: 0;
    padding: clamp(1.5rem, 4vw, 2.75rem);
}

.auth-panel--brand {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1.25rem;
    color: var(--brand-contrast);
    background:
        radial-gradient(circle at 88% 90%, rgba(255, 255, 255, 0.18), transparent 36%),
        linear-gradient(155deg, var(--brand-secondary) 0%, var(--brand-primary) 55%, var(--brand-accent) 100%);
}

.auth-panel--brand::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: 0.14;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.28) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.28) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(to bottom, #000 30%, transparent 90%);
}

.auth-panel-logo {
    display: block;
    width: auto;
    max-width: min(220px, 70%);
    max-height: 72px;
    height: auto;
    object-fit: contain;
    margin-bottom: 1.25rem;
}

.auth-panel-name {
    margin: 0;
    font-size: clamp(1.55rem, 3vw, 2.15rem);
    line-height: 1.15;
    letter-spacing: -0.03em;
    font-weight: 750;
}

.auth-panel-legal {
    margin: 0.45rem 0 0;
    opacity: 0.88;
    font-size: 0.95rem;
    font-weight: 500;
}

.auth-panel-desc {
    margin: 1rem 0 0;
    max-width: 28rem;
    opacity: 0.86;
    font-size: 0.95rem;
    line-height: 1.6;
}

.auth-panel--form {
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--surface);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}

.auth-card-header {
    margin-bottom: 1.35rem;
    text-align: left;
}
.auth-card-logo {
    display: none;
    width: auto;
    max-width: 120px;
    max-height: 56px;
    height: auto;
    object-fit: contain;
    margin: 0 auto 1rem;
}
.auth-card-header h1 {
    margin: 0;
    font-size: clamp(1.45rem, 2.4vw, 1.8rem);
    letter-spacing: -0.025em;
    font-weight: 750;
}
.auth-card-welcome {
    margin: 0.4rem 0 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.45;
}

.auth-status {
    margin: 0 0 1rem;
    padding: 0.7rem 0.85rem;
    border-radius: var(--radius-sm);
    background: #ecfdf5;
    color: var(--success);
    font-weight: 600;
    font-size: 0.9rem;
}

.auth-alert {
    margin: 0 0 1rem;
    padding: 0.7rem 0.85rem;
    border-radius: var(--radius-sm);
    background: #fef3f2;
    border: 1px solid #fecdca;
}

.auth-form .field { margin-bottom: 1rem; }
.auth-form .field input { min-height: 48px; border-radius: 10px; }

.password-field {
    position: relative;
    display: flex;
    align-items: center;
}
.password-field input {
    padding-inline-end: 6.5rem;
}
.password-toggle {
    position: absolute;
    inset-inline-end: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    min-height: 40px;
    padding: 0.35rem 0.65rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 650;
    cursor: pointer;
}
.password-toggle:hover { color: var(--text-primary); background: var(--surface-muted); }
.password-toggle:focus-visible { box-shadow: var(--focus-ring); }

.auth-form-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem 1rem;
    margin: 0.15rem 0 1.15rem;
}
.auth-remember {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
}
.auth-remember input {
    width: 1.05rem;
    height: 1.05rem;
    accent-color: var(--brand-primary);
}

.auth-submit {
    width: 100%;
    min-height: 48px;
    border-radius: 10px;
    font-size: 1rem;
}
.auth-submit:hover { transform: translateY(-1px); }

.auth-passkey {
    width: 100%;
    min-height: 48px;
    margin-top: 0.7rem;
    border-radius: 10px;
}

.auth-hint {
    margin: 0.85rem 0 0;
    font-size: 0.84rem;
    line-height: 1.45;
}

.auth-footer {
    width: min(1040px, 100%);
    margin: 1.25rem auto 0;
    padding-top: 0.25rem;
    text-align: center;
    color: var(--text-muted);
}
.auth-footer p {
    margin: 0.15rem 0;
    font-size: 0.8rem;
    line-height: 1.45;
}
.auth-footer-copy {
    font-size: 0.76rem !important;
}
.auth-footer-copy a {
    font-weight: 650;
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 0.15em;
}
.auth-footer-copy a:hover {
    color: var(--primary);
}

@media (max-width: 900px) {
    .auth-login-stage {
        grid-template-columns: 1fr;
        border-radius: 16px;
    }
    .auth-panel--brand {
        min-height: auto;
        padding: 1.35rem 1.25rem 1.2rem;
        gap: 1rem;
    }
    .auth-panel-logo {
        max-height: 48px;
        margin-bottom: 0.75rem;
    }
    .auth-panel-name { font-size: 1.35rem; }
    .auth-panel-desc { display: none; }
    .auth-card-logo { display: none; }
    .auth-panel--form { padding: 1.35rem 1.15rem 1.5rem; }
}

@media (max-width: 560px) {
    .auth-login-page {
        padding:
            calc(0.65rem + var(--safe-top))
            calc(0.65rem + var(--safe-right))
            calc(0.85rem + var(--safe-bottom))
            calc(0.65rem + var(--safe-left));
        background: var(--surface);
    }
    .auth-login-stage {
        border: 0;
        border-radius: 0;
        box-shadow: none;
        margin: 0;
        width: 100%;
    }
    .auth-panel--brand {
        border-radius: 14px;
        margin-bottom: 0.35rem;
    }
    .auth-panel--form { padding: 1.1rem 0.35rem 0.5rem; }
    .auth-card-logo {
        display: block;
    }
    .auth-card-header { text-align: center; }
    .auth-form-row { flex-direction: column; align-items: flex-start; }
    .password-field input { padding-inline-end: 5.75rem; }
    .auth-footer { margin-top: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    .btn,
    .auth-submit { transition: none; }
    .auth-submit:hover { transform: none; }
}
