/* ============================================================
   Authentication UI — ARVista Premium Design System
   Matches: homepage colors, typography, glow, spacing
   Reference: Vercel, Linear, Framer aesthetics
   ============================================================ */


/* ─── Base ─────────────────────────────────────────────────── */
body.auth-page {
    margin: 0;
    padding: 0;
    background-color: var(--bg-darker);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    font-family: var(--font-family);
    color: var(--text-main);
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
}

/* ─── Background Grid + Radial Glow ────────────────────────── */
.auth-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    background-color: var(--bg-darker);
}

/* Subtle grid */
.auth-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(0,229,255,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,229,255,0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 40%, transparent 100%);
}

/* ─── Radial Glows (Reduced Intensity) ─────────────────────── */
.auth-bg::after {
    content: '';
    position: absolute;
    top: -20%;
    left: -10%;
    width: 700px;
    height: 500px;
    background: radial-gradient(ellipse, rgba(0,229,255,0.08) 0%, transparent 70%);
    pointer-events: none;
}

/* Bottom-right accent */
.auth-bg-accent {
    position: fixed;
    bottom: -15%;
    right: -10%;
    width: 500px;
    height: 400px;
    background: radial-gradient(ellipse, rgba(0,180,220,0.05) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ─── Auth Wrapper ──────────────────────────────────────────── */
.auth-wrapper {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 520px;
    margin: auto;
    padding: calc(40px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ─── Brand Logo Area ───────────────────────────────────────── */
.auth-brand {
    text-align: center;
    margin-bottom: 32px;
    text-decoration: none;
    display: block;
}

.auth-logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.auth-logo-icon {
    height: 48px;
    object-fit: contain;
}

@media (min-width: 481px) {
    .auth-logo-icon {
        height: 86px;
    }
}

.auth-brand-name {
    font-family: 'Groupe', 'Orbitron', sans-serif;
    font-size: 1.6rem;
    font-weight: 900;
    color: #fff;
    letter-spacing: 2px;
    line-height: 1;
}

.auth-brand-pk {
    color: var(--primary-accent);
}

.auth-brand-tagline {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-top: 6px;
    font-weight: 500;
}

/* ─── Card (Glassmorphism) ──────────────────────────────────── */
.auth-card {
    width: 100%;
    background: rgba(10, 10, 10, 0.75);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem 2.25rem 2rem;
    box-sizing: border-box;
    box-shadow:
        0 0 0 1px rgba(0,229,255,0.05) inset,
        0 16px 32px -16px rgba(0,0,0,0.8),
        0 32px 64px -24px rgba(0,0,0,0.9),
        0 0 100px -20px rgba(0,229,255,0.04);
    transition: box-shadow 0.3s ease;
}

/* ─── Panel system ──────────────────────────────────────────── */
.auth-panel { 
    display: none; 
    opacity: 0;
    transform: translateY(10px);
}
.auth-panel.active { 
    display: block; 
    animation: panelFadeIn 0.25s forwards ease-out;
}

@keyframes panelFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── Panel Header ──────────────────────────────────────────── */
.panel-title {
    font-family: var(--font-family);
    font-size: 1.35rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 0.35rem;
    letter-spacing: -0.3px;
}

.panel-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0 0 10px;
    line-height: 1.5;
    font-weight: 400;
}

/* ─── Alerts ────────────────────────────────────────────────── */
.auth-alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 1.25rem;
    display: none;
    font-weight: 500;
}

.auth-alert.error {
    display: block;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #fca5a5;
}

.auth-alert.success {
    display: block;
    background: rgba(0, 229, 255, 0.06);
    border: 1px solid rgba(0, 229, 255, 0.25);
    color: var(--primary-accent);
}

/* ─── Form ──────────────────────────────────────────────────── */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    position: relative;
}

.input-group label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.input-group input {
    width: 100%;
    height: 60px;
    padding: 1rem 3rem;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: #fff;
    font-family: var(--font-family);
    font-size: 0.95rem;
    transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
    box-sizing: border-box;
    -webkit-user-select: text;
    user-select: text;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-accent);
    background: rgba(0,229,255,0.04);
    box-shadow: 0 0 0 3px rgba(0,229,255,0.12);
}

.input-group input:hover:not(:focus) {
    box-shadow: 0 0 0 2px rgba(0,229,255,0.06);
}

/* ─── Input Icons & Toggles ─────────────────────────────────── */
.input-icon {
    position: absolute;
    left: 12px;
    top: 55px;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 55px;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);

    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.2s;
}

.password-toggle:hover {
    color: var(--primary-accent);
}

.password-toggle svg {
    width: 18px;
    height: 18px;
}

.input-group input::placeholder { color: rgba(255,255,255,0.2); }

/* OTP input special */
.input-otp {
    letter-spacing: 8px;
    text-align: center;
    font-size: 1.4rem !important;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ─── Primary Button ────────────────────────────────────────── */
.auth-btn {
    width: 100%;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1.5rem;
    background: var(--primary-accent);
    color: #020617;
    border: none;
    border-radius: 8px;
    font-family: var(--font-family);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.5px;

    transition: all 0.25s ease;
    box-shadow: 0 0 20px rgba(0,229,255,0.25);
    position: relative;
    overflow: hidden;
    margin-top: 20px;
}

.auth-btn:disabled {
    cursor: not-allowed !important;
    opacity: 0.8;
}

.auth-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.15) 100%);
    opacity: 0;
    transition: opacity 0.25s;
}

.auth-btn:hover:not(:disabled) {
    background: #1af0ff;
    box-shadow: 0 0 32px rgba(0,229,255,0.5), 0 4px 16px rgba(0,0,0,0.4);
    transform: translateY(-1px) scale(1.02);
}

.auth-btn:hover::after { opacity: 1; }
.auth-btn:active:not(:disabled) { transform: translateY(0) scale(1); box-shadow: 0 0 16px rgba(0,229,255,0.3); }

/* Loading spinner on button */
.auth-btn.loading {
    color: transparent;
    pointer-events: none;
}

.auth-btn.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(0,0,0,0.3);
    border-top-color: #020617;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ─── Divider ───────────────────────────────────────────────── */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 1.5rem 0;
    font-size: 0.72rem;
    color: rgba(255,255,255,0.2);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* ─── Footer Links ──────────────────────────────────────────── */
.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.auth-link {
    color: var(--primary-accent);
    text-decoration: none;
    font-weight: 500;

    transition: color 0.2s;
    background: none;
    border: none;
    font-size: inherit;
    font-family: inherit;
    padding: 0;
}

.auth-link:hover { color: #80ffff; text-decoration: underline; }

/* ─── QR Code (2FA Setup) ───────────────────────────────────── */
.qr-frame {
    display: inline-block;
    background: white;
    padding: 12px;
    border-radius: 10px;
    margin: 0.75rem 0;
    box-shadow: 0 0 24px rgba(0,229,255,0.2);
}

.qr-frame img { display: block; width: 160px; height: 160px; }

.secret-box {
    background: rgba(0,229,255,0.05);
    border: 1px solid rgba(0,229,255,0.15);
    border-radius: 6px;
    padding: 0.6rem 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--primary-accent);
    word-break: break-all;
    text-align: center;
    margin-bottom: 1rem;
    user-select: all;
    -webkit-user-select: all;
}

/* ─── Security Badge ────────────────────────────────────────── */
.auth-security-note {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    margin-top: 1.5rem;
    font-size: 0.72rem;
    color: rgba(255,255,255,0.2);
    letter-spacing: 0.5px;
}

.auth-security-note svg {
    opacity: 0.3;
    flex-shrink: 0;
}

/* ─── Password Strength Meter ───────────────────────────────── */
.password-strength {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
    display: none;
}
.password-strength.visible {
    display: flex;
}
.strength-bar {
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}
.strength-fill {
    height: 100%;
    width: 0%;
    background: #ef4444;
    transition: width 0.3s ease, background 0.3s ease;
    border-radius: 2px;
}
.strength-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.strength-weak .strength-fill { width: 33.33%; background: #ef4444; }
.strength-weak .strength-label { color: #ef4444; }
.strength-medium .strength-fill { width: 66.66%; background: #facc15; }
.strength-medium .strength-label { color: #facc15; }
.strength-strong .strength-fill { width: 100%; background: #22c55e; }
.strength-strong .strength-label { color: #22c55e; }

/* ─── Toast Notifications ───────────────────────────────────── */
.auth-toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

.auth-toast {
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-highlight);
    color: #fff;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toastSlideUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.auth-toast.toast-error {
    border-color: rgba(239, 68, 68, 0.5);
}

.auth-toast.toast-fade-out {
    animation: toastFadeOut 0.3s ease-in forwards;
}

@keyframes toastSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastFadeOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(10px) scale(0.95); }
}

/* ─── Desktop Optimization (Tighten Form) ─────────────────── */
@media (min-width: 481px) {
    .auth-wrapper {
        padding-top: calc(5px + env(safe-area-inset-top));
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
    .auth-brand {
        margin-bottom: 10px;
    }
    .auth-card {
        padding: 1.25rem 2rem 1.5rem;
    }
    .auth-form {
        gap: 16px;
    }
    .panel-subtitle {
        margin-bottom: 12px;
    }
    .input-group input {
        height: 52px;
        padding: 0.8rem 2.5rem;
    }
    .input-icon,
    .password-toggle {
        top: 51px;
    }
}

/* ─── Responsive (Mobile) ─────────────────────────────────── */
@media (max-width: 480px) {
    .auth-wrapper { padding: calc(20px + env(safe-area-inset-top)) 4% calc(20px + env(safe-area-inset-bottom)); max-width: 420px; }
    .auth-card { padding: 1.5rem 1.2rem; border-radius: 12px; }
    .auth-brand-name { font-size: 1.3rem; }
    .auth-logo-icon { height: 64px; }
}

/* ─── Success Panels ────────────────────────────────────────── */
.auth-success-panel {
    width: 100%;
    max-width: 520px;
    text-align: center;
    padding: 2.5rem 2rem;
    background: rgba(10, 10, 10, 0.75);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow:
        0 0 0 1px rgba(0,229,255,0.05) inset,
        0 16px 32px -16px rgba(0,0,0,0.8),
        0 32px 64px -24px rgba(0,0,0,0.9);
    animation: panelFadeIn 0.35s forwards ease-out;
}

.auth-success-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    display: block;
    animation: successBounce 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.15s both;
}

@keyframes successBounce {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.auth-success-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 0.5rem;
}

.auth-success-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0 0 1.75rem;
    line-height: 1.6;
}

/* ─── Inline Validation ─────────────────────────────────────── */
.input-error-msg {
    font-size: 0.72rem;
    color: #ef4444;
    margin-top: 4px;
    display: none;
    align-items: center;
    gap: 4px;
}
.input-error-msg.visible {
    display: flex;
}
.input-group input.input-invalid {
    border-color: rgba(239, 68, 68, 0.6);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}
.input-group input.input-valid {
    border-color: rgba(34, 197, 94, 0.5);
}
