/**
 * Shared auth shell — login stage used by login, forgot, reset, and error pages.
 */
:root {
    --primary: #4099ff;
    --primary-dark: #2a75c7;
    --dark: #37474f;
    --light: #f4f7fa;
    --border-color: #e9ecef;
    --input-border: #dbe7f3;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    overflow-x: hidden;
}

html,
body.nex-themed.auth-shell {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    background: #ffffff;
    width: 100%;
    min-height: 100dvh;
}

body.nex-themed.auth-shell {
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    color: #0f172a;
}

.login-stage {
    position: relative;
    flex: 1 1 auto;
    width: 100%;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(24px, 5vh, 56px) clamp(20px, 4vw, 48px);
    box-sizing: border-box;
    overflow: hidden;
    color: #0f172a;
    background:
        radial-gradient(ellipse 90% 70% at 8% 100%, rgba(64, 153, 255, 0.14) 0%, transparent 55%),
        radial-gradient(ellipse 70% 55% at 100% 0%, rgba(14, 116, 144, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse 50% 40% at 70% 80%, rgba(64, 153, 255, 0.06) 0%, transparent 60%),
        linear-gradient(165deg, #eef3f8 0%, #f7fafc 45%, #e8eef5 100%);
}

.login-stage::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(15, 23, 42, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 23, 42, 0.04) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, #000 10%, transparent 75%);
    pointer-events: none;
}

.login-stage::after {
    content: '';
    position: absolute;
    width: min(560px, 70vw);
    height: min(560px, 70vw);
    border: 1px solid rgba(64, 153, 255, 0.18);
    border-radius: 50%;
    right: -12%;
    top: -18%;
    pointer-events: none;
    animation: loginRingDrift 16s ease-in-out infinite;
}

.login-stage-ring {
    position: absolute;
    width: min(380px, 50vw);
    height: min(380px, 50vw);
    border: 1px solid rgba(14, 116, 144, 0.12);
    border-radius: 50%;
    left: -8%;
    bottom: -14%;
    pointer-events: none;
    animation: loginRingDrift 20s ease-in-out infinite reverse;
}

@keyframes loginRingDrift {
    0%, 100% { transform: translate(0, 0); opacity: 0.7; }
    50% { transform: translate(-18px, 12px); opacity: 1; }
}

@keyframes loginHeroIn {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes loginAccentIn {
    from { transform: scaleX(0); opacity: 0; }
    to { transform: scaleX(1); opacity: 1; }
}

.login-stage-inner {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: clamp(28px, 4vh, 40px);
}

.login-brand {
    text-align: left;
    animation: loginHeroIn 0.7s ease-out both;
}

.login-hero-accent {
    display: block;
    width: 48px;
    height: 3px;
    background: var(--primary);
    margin: 0 0 22px;
    transform-origin: left center;
    animation: loginAccentIn 0.6s ease-out both;
}

.login-hero-title {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: clamp(40px, 7vh, 64px);
    font-weight: 800;
    letter-spacing: -0.05em;
    line-height: 0.96;
    margin: 0 0 12px;
    color: #0f172a;
}

.login-hero-tagline {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: clamp(16px, 2.2vh, 20px);
    font-weight: 600;
    color: #2a75c7;
    margin: 0 0 10px;
    line-height: 1.35;
}

.login-hero-desc {
    font-size: clamp(14px, 1.8vh, 16px);
    line-height: 1.5;
    color: #475569;
    margin: 0;
    max-width: 26rem;
}

.login-panel {
    width: 100%;
    animation: loginHeroIn 0.75s 0.12s ease-out both;
}

.login-header {
    margin-bottom: 18px;
}

.header-subtitle,
.auth-page-title {
    text-align: left;
    font-size: 1.15rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 6px;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.header-desc {
    color: #64748b;
    font-size: 13px;
    margin: 0;
    line-height: 1.5;
    font-weight: 400;
}

.login-type-switcher {
    display: flex;
    gap: 4px;
    margin-bottom: 28px;
    background: var(--light);
    border-radius: 0;
    padding: 4px;
    border: 1px solid var(--border-color);
}

.login-type-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    min-height: 42px;
    background: transparent;
    border: none;
    border-radius: 0;
    color: #64748b;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    min-width: 0;
    white-space: nowrap;
    line-height: 1;
    text-decoration: none;
}

.login-type-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(55, 71, 79, 0.08);
}

.login-type-btn i,
.login-type-btn .fas {
    margin: 0;
    font-size: 14px;
    line-height: 1;
    width: 1em;
    text-align: center;
    font-family: "Font Awesome 6 Free", "Font Awesome 5 Free" !important;
    font-weight: 900 !important;
    color: inherit;
    flex-shrink: 0;
}

.alert,
.alert-success,
.alert-error,
.alert-info {
    border-radius: 0;
    padding: 12px 16px;
    margin-bottom: 22px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    line-height: 1.45;
    border: 1px solid transparent;
}

.alert,
.alert-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

.alert-success {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #047857;
}

.alert-info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.form-group {
    margin-bottom: 22px;
}

.form-label {
    color: #1e293b;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 8px;
    display: block;
    letter-spacing: -0.1px;
}

.input-wrapper {
    position: relative;
    display: block;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 15px;
    width: 1.1em;
    text-align: center;
    z-index: 1;
    pointer-events: none;
    font-family: "Font Awesome 6 Free", "Font Awesome 5 Free" !important;
    font-weight: 900 !important;
    line-height: 1;
}

.input-wrapper:focus-within .input-icon {
    color: var(--primary);
}

.form-control {
    width: 100%;
    padding: 11px 16px 11px 42px;
    border: 1px solid var(--input-border);
    border-radius: 0;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    background: white;
    color: var(--dark);
    line-height: 1.5;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(64, 153, 255, 0.15);
    background: #fff;
}

.form-control::placeholder {
    color: #94a3b8;
}

.btn-login,
.btn-primary.auth-submit {
    width: 100%;
    padding: 12px 20px;
    min-height: 48px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: 0;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 3px 12px rgba(64, 153, 255, 0.25);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    letter-spacing: -0.1px;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    text-decoration: none;
    white-space: nowrap;
}

.btn-login:hover,
.btn-primary.auth-submit:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #1e5aa3 100%);
    transform: translateY(-1px);
    box-shadow: 0 5px 16px rgba(64, 153, 255, 0.35);
    color: #fff;
}

.btn-login i,
.btn-login .fas,
.btn-primary.auth-submit i,
.btn-primary.auth-submit .fas {
    margin: 0;
    color: inherit !important;
    font-family: "Font Awesome 6 Free", "Font Awesome 5 Free" !important;
    font-weight: 900 !important;
    line-height: 1;
}

.btn-outline-auth {
    width: 100%;
    min-height: 48px;
    padding: 12px 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    white-space: nowrap;
}

.btn-outline-auth:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #0f172a;
}

.login-footer,
.auth-footer {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 13px;
    color: #64748b;
    line-height: 1.6;
    word-break: break-word;
}

.login-footer a,
.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.login-footer a:hover,
.auth-footer a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Error pages */
.auth-error-code {
    font-size: clamp(56px, 12vh, 88px);
    font-weight: 800;
    letter-spacing: -0.06em;
    line-height: 1;
    color: #0f172a;
    margin: 0 0 12px;
}

.auth-error-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

@media (max-height: 720px) {
    .login-stage {
        align-items: flex-start;
        padding-top: max(20px, env(safe-area-inset-top));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }

    .login-stage-inner {
        gap: 22px;
    }

    .login-hero-title {
        font-size: clamp(34px, 7vh, 48px) !important;
    }
}

@media (max-width: 575.98px) {
    .login-stage {
        padding: max(20px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
        align-items: flex-start;
    }

    .login-type-btn {
        font-size: 11px;
        padding: 10px 8px;
        gap: 6px;
    }

    .form-control {
        font-size: 16px;
    }
}
