/**
 * Admin auth — login & 2FA
 */

html:has(body.auth-page) {
    height: 100%;
    overflow: hidden;
}

body.auth-page {
    min-height: 100dvh;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

/* —— Login atmosphere —— */
body.auth-page--login {
    --auth-ink: #07070a;
    --auth-panel: rgba(12, 12, 16, 0.72);
    --auth-line: rgba(255, 255, 255, 0.08);
    --auth-text: rgba(236, 236, 242, 0.88);
    --auth-muted: rgba(180, 184, 198, 0.42);
    --auth-field: rgba(8, 8, 12, 0.85);
    background: radial-gradient(ellipse 90% 70% at 50% 0%, #12121a 0%, var(--auth-ink) 55%, #050508 100%);
    color: var(--auth-text);
    font-family: 'IBM Plex Sans', var(--font);
}

.auth-rain {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.auth-atmosphere {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background:
        radial-gradient(ellipse 70% 50% at 50% 110%, rgba(40, 48, 70, 0.28), transparent 60%),
        radial-gradient(ellipse 55% 40% at 50% 35%, rgba(255, 255, 255, 0.03), transparent 70%),
        linear-gradient(180deg, rgba(0, 0, 0, 0.15) 0%, rgba(0, 0, 0, 0.55) 100%);
    box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.65);
}

/* —— Top bar (2FA / shared) —— */
.auth-topbar {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 200;
    background: var(--bg-base);
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: none;
}

.auth-topbar__inner {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0 1.5rem;
    width: 100%;
}

.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    text-decoration: none;
}

/* —— Center layout —— */
.auth-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1.25rem 12vh;
    min-height: 0;
}

body.auth-page--login .auth-main {
    position: relative;
    z-index: 2;
    padding: 1.5rem 1.25rem 10vh;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    margin-top: -6vh;
    padding: 0;
    background: var(--glass-bg-elevated);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    box-shadow: none;
    overflow: hidden;
}

.auth-card--mist {
    max-width: 360px;
    margin-top: 0;
    background: var(--auth-panel);
    border: 1px solid var(--auth-line);
    border-radius: 14px;
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    overflow: visible;
    animation: authDriftIn 0.9s ease both;
}

@keyframes authDriftIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-mark {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
    padding: 1.75rem 1.5rem 0.35rem;
}

.auth-mark__icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    object-fit: cover;
    opacity: 0.92;
    filter: saturate(0.85) brightness(0.95);
}

.auth-mark__word {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.65rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: lowercase;
    color: rgba(230, 232, 240, 0.78);
}

.auth-card__header {
    padding: 1.5rem 1.5rem 0.25rem;
    text-align: center;
}

.auth-card__title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.auth-card__subtitle {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-tertiary);
}

.auth-card__body {
    padding: 1.25rem 1.5rem 1.5rem;
}

body.auth-page--login .auth-card__body {
    padding: 1.35rem 1.4rem 1.4rem;
}

/* —— Form —— */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.auth-field__label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

body.auth-page--login .auth-field__label {
    letter-spacing: 0.14em;
    color: var(--auth-muted);
    font-weight: 400;
}

.auth-field__control {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.auth-field__input {
    width: 100%;
    margin: 0;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    padding-left: 0.55rem;
    padding-right: 0.55rem;
    font-size: 14px;
    line-height: 1.25;
    font-family: inherit;
    color: var(--text-primary);
    text-indent: 0;
    background: var(--glass-bg-inset);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    -webkit-appearance: none;
    appearance: none;
    transition:
        border-color var(--duration) var(--ease-out),
        box-shadow var(--duration) var(--ease-out),
        background var(--duration) var(--ease-out);
}

body.auth-page--login .auth-field__input {
    padding: 0.72rem 0.8rem;
    color: var(--auth-text);
    background: var(--auth-field);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.auth-field__input--password {
    padding-right: 2.25rem;
}

body.auth-page--login .auth-field__input--password {
    padding-right: 2.5rem;
}

.auth-field__input--otp {
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: 0.35em;
    text-align: center;
}

.auth-field__toggle {
    position: absolute;
    right: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: color var(--duration) var(--ease-out), background var(--duration) var(--ease-out);
}

body.auth-page--login .auth-field__toggle {
    color: rgba(180, 184, 198, 0.45);
}

.auth-field__toggle:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.06);
}

body.auth-page--login .auth-field__toggle:hover {
    color: rgba(220, 224, 236, 0.8);
    background: rgba(255, 255, 255, 0.04);
}

.auth-field__toggle-icon {
    width: 17px;
    height: 17px;
    display: block;
    pointer-events: none;
}

.auth-field__toggle-icon--hide {
    display: none;
}

.auth-field__toggle.is-revealing .auth-field__toggle-icon--show {
    display: none;
}

.auth-field__toggle.is-revealing .auth-field__toggle-icon--hide {
    display: block;
}

.auth-field__input::placeholder {
    color: var(--text-tertiary);
}

.auth-field__input:hover {
    border-color: rgba(255, 255, 255, 0.14);
}

body.auth-page--login .auth-field__input:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.auth-field__input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: var(--shadow-focus);
}

body.auth-page--login .auth-field__input:focus {
    outline: none;
    border-color: rgba(190, 198, 220, 0.28);
    background: rgba(6, 6, 10, 0.92);
    box-shadow: 0 0 0 1px rgba(190, 198, 220, 0.08);
}

/* Kill Chrome/Safari white autofill flash on blur */
.auth-field__input:-webkit-autofill,
.auth-field__input:-webkit-autofill:hover,
.auth-field__input:-webkit-autofill:focus,
.auth-field__input:-webkit-autofill:active {
    -webkit-text-fill-color: rgba(236, 236, 242, 0.9) !important;
    caret-color: rgba(236, 236, 242, 0.9);
    border-color: rgba(255, 255, 255, 0.1) !important;
    transition: background-color 99999s ease-out 0s;
    box-shadow: 0 0 0 1000px #0c0c10 inset !important;
}

body.auth-page--login .auth-field__input:-webkit-autofill,
body.auth-page--login .auth-field__input:-webkit-autofill:hover,
body.auth-page--login .auth-field__input:-webkit-autofill:focus,
body.auth-page--login .auth-field__input:-webkit-autofill:active {
    -webkit-text-fill-color: rgba(236, 236, 242, 0.9) !important;
    caret-color: rgba(236, 236, 242, 0.9);
    border-color: rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 0 0 1000px #08080c inset !important;
}

.auth-field__input:autofill {
    background: #0c0c10;
    color: rgba(236, 236, 242, 0.9);
}

/* —— Messages —— */
.auth-error {
    display: none;
    margin-bottom: 0.25rem;
    padding: 0.65rem 0.85rem;
    font-size: 12px;
    line-height: 1.45;
    color: var(--error);
    background: rgba(255, 69, 58, 0.12);
    border: 1px solid rgba(255, 69, 58, 0.28);
    border-radius: var(--radius-md);
}

body.auth-page--login .auth-error {
    background: rgba(180, 50, 50, 0.12);
    border-color: rgba(180, 70, 70, 0.28);
    color: #e8a0a0;
    border-radius: 10px;
}

.auth-error.show {
    display: block;
}

.auth-info {
    padding: 0.75rem 0.85rem;
    margin-bottom: 0.25rem;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-secondary);
    background: var(--accent-subtle);
    border: 1px solid var(--accent-muted);
    border-radius: var(--radius-md);
}

.auth-info strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* —— Submit —— */
.auth-submit {
    width: 100%;
    margin-top: 0.15rem;
    padding: 0.68rem 1rem;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-lg);
    justify-content: center;
}

.auth-submit--ghost {
    margin-top: 0.2rem;
    padding: 0.62rem 1rem;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.01em;
    text-transform: none;
    color: rgba(230, 232, 240, 0.86);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 9px;
    cursor: pointer;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease;
}

.auth-submit--ghost:hover:not(:disabled) {
    color: rgba(255, 255, 255, 0.95);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.16);
}

.auth-submit--ghost:active:not(:disabled) {
    transform: scale(0.99);
}

.auth-submit:active:not(:disabled) {
    transform: scale(0.99);
}

.auth-submit:disabled,
.auth-submit.is-loading {
    opacity: 0.72;
    cursor: wait;
}

.auth-submit.is-loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid rgba(180, 188, 210, 0.25);
    border-top-color: rgba(220, 224, 236, 0.85);
    border-radius: 50%;
    animation: authSpin 0.65s linear infinite;
}

@keyframes authSpin {
    to { transform: rotate(360deg); }
}

.auth-back {
    display: block;
    margin-top: 0.85rem;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-decoration: none;
    transition: color var(--duration) var(--ease-out);
}

.auth-back:hover {
    color: var(--accent-hover);
}

.auth-countdown {
    margin-top: 0.65rem;
    text-align: center;
    font-size: 12px;
    color: var(--text-tertiary);
}

@media (max-width: 480px) {
    .auth-main {
        padding: 1rem 1rem 8vh;
        align-items: center;
    }

    .auth-card {
        margin-top: -4vh;
        border-radius: var(--radius-lg);
    }

    .auth-card--mist {
        margin-top: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-card--mist {
        animation: none;
    }
}
