/* 
    auth.css 
    Shared styles for authentication/login pages (Deck Access, Console Sign In, Register, Setup)
*/

* {
    box-sizing: border-box;
}

body.auth-page {
    margin: 0;
    padding: 48px 20px;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-main);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    /* Add this so the absolute banner positions relative to body */
}

body.auth-page #global-banner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
}

.auth-theme-controls {
    position: absolute;
    top: 24px;
    left: 24px;
    z-index: 50;
}

.auth-theme-controls .accent-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    cursor: pointer;
    border: 1.5px solid var(--border);
    transition: transform 0.2s ease, background-color 0.3s ease;
}

.auth-theme-controls .accent-dot:hover {
    transform: scale(1.3);
}

.auth-page .wrap {
    max-width: 500px;
    width: 100%;
}

.auth-page .logo {
    width: 48px;
    height: 48px;
    margin-bottom: 20px;
}

.auth-page .logo img {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 6px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.auth-page h1 {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0 0 8px;
    text-align: left;
    /* override layout.css right-align if it accidentally leaks */
    color: var(--fg);
    /* override layout.css brand color */
    width: auto;
    /* override layout 100% width */
    cursor: default;
    /* override layout cursor: pointer */
}

/* Ensure no hover effect on h1 */
.auth-page h1:hover {
    opacity: 1;
}

.auth-page p {
    margin: 0 0 18px;
    color: var(--muted-foreground);
}

.auth-page form {
    border: 1px solid var(--border);
    background: rgba(var(--bg-rgb), 0.6);
    border-radius: 12px;
    padding: 24px;
}

.auth-page .form-group {
    margin-bottom: 16px;
}

.auth-page label {
    display: block;
    font-size: 13px;
    color: var(--muted-foreground);
    margin-bottom: 8px;
    font-family: var(--font-mono);
}

/* Base input styling for auth forms */
.auth-page input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-sans);
    transition: border-color 0.2s ease;
}

.auth-page input:focus {
    outline: none;
    border-color: var(--brand);
}

.auth-page button.submit-btn,
.auth-page form>button[type="submit"] {
    margin-top: 12px;
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: var(--brand);
    color: var(--bg);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-main);
    transition: opacity 0.2s ease;
}

.auth-page button.submit-btn:hover,
.auth-page form>button[type="submit"]:hover {
    opacity: 0.85;
}

/* Alert Boxes */
.auth-alert {
    margin-bottom: 16px;
    padding: 12px;
    border-radius: 10px;
    font-size: 14px;
    display: none;
}

.auth-alert.error {
    display: block;
    background: rgba(220, 38, 38, 0.1);
    color: #DC2626;
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.auth-page .error {
    /* For standard deck error display */
    margin-top: 12px;
    padding: 12px;
    border-radius: 10px;
    font-size: 14px;
    background: rgba(220, 38, 38, 0.1);
    color: #DC2626;
    border: 1px solid rgba(220, 38, 38, 0.2);
    display: none;
    /* Hide by default */
}

.auth-page .hint {
    margin-top: 24px;
    font-size: 13px;
    color: var(--muted-foreground);
    text-align: left;
    /* Unify alignment */
}

.auth-page .hint a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.auth-page .hint a:hover {
    color: var(--brand);
}

/* Specifics for Registration */
.pw-strength {
    height: 4px;
    background: var(--muted);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.pw-strength-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease, background 0.3s ease;
    width: 0;
}

.pw-strength-bar.weak {
    width: 25%;
    background: #ff3b30;
}

.pw-strength-bar.fair {
    width: 50%;
    background: #ff9500;
}

.pw-strength-bar.good {
    width: 75%;
    background: #ffcc00;
}

.pw-strength-bar.strong {
    width: 100%;
    background: #34c759;
}

.form-hint {
    font-size: 12px;
    color: var(--muted-foreground);
    margin-top: 6px;
}

/* Specifics for Setup (2FA) */
.setup-card {
    border: 1px solid var(--border);
    background: rgba(var(--bg-rgb), 0.6);
    border-radius: 12px;
    padding: 24px;
}

.success-icon {
    font-size: 48px;
    margin-bottom: 16px;
    color: var(--brand);
}

.success-spinner {
    display: flex;
    justify-content: center;
}

.spin-svg {
    animation: spin 1s linear infinite;
}

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

/* ─── Error Shake Animation ─── */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    50%,
    90% {
        transform: translateX(-4px);
    }

    30%,
    70% {
        transform: translateX(4px);
    }
}

.shake {
    animation: shake 0.4s ease-in-out;
}

/* Disabled button state */
.auth-page button.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ─── TOTP Setup (QR centering) ─── */
.totp-qr {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 0;
    width: 100%;
}

.totp-qr canvas,
.totp-qr img {
    max-width: 200px;
    margin: 0 auto 1.5rem;
    display: block;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* ─── Custom Form Validation ─── */

/* Hide native browser validation bubbles */
.auth-page input:invalid {
    box-shadow: none;
}

/* Show error styling only after the user has typed (not on initial load) */
.auth-page input:invalid:not(:placeholder-shown),
.auth-page input.invalid {
    border-color: #DC2626;
}

/* Custom validation message via JS-injected .field-error spans */
.auth-page .field-error {
    display: block;
    font-size: 12px;
    color: #DC2626;
    margin-top: 4px;
    font-family: var(--font-mono);
    letter-spacing: 0.01em;
}

/* Validation hint below required fields */
.auth-page input:focus:invalid:not(:placeholder-shown) {
    border-color: #DC2626;
    outline: none;
}

@media (max-width: 480px) {
    body.auth-page {
        padding: 24px 16px;
    }

    .auth-page h1 {
        font-size: 24px;
    }

    .auth-page .wrap {
        max-width: 100%;
    }

    .auth-page input,
    .auth-page button.submit-btn,
    .auth-page form>button[type="submit"] {
        font-size: 16px;
        /* prevent iOS zoom */
        padding: 14px 12px;
    }
}