/* ============================================================
   Finlet Auth — Styles
   Inherits CSS variables from styles.css
   ============================================================ */

/* ---- Layout ---- */
.auth-page {
    display: flex;
    min-height: 100vh;
    background: var(--bg-primary);
}

.auth-brand {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 48px 56px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.auth-brand::before {
    content: '';
    position: absolute;
    top: -120px;
    right: -120px;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(88, 166, 255, 0.06) 0%, transparent 70%);
    pointer-events: none;
}

.auth-brand::after {
    content: '';
    position: absolute;
    bottom: -80px;
    left: -80px;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(88, 166, 255, 0.04) 0%, transparent 70%);
    pointer-events: none;
}

.auth-brand-logo {
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.5px;
    margin-bottom: 12px;
    text-decoration: none;
}

.auth-home-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    margin-bottom: 16px;
    transition: color 0.15s;
}

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

.auth-brand-tagline {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 32px;
    max-width: 380px;
}

.auth-brand-features {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 48px;
}

.auth-feature {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.auth-feature-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
    color: var(--accent);
}

.auth-feature-text h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.auth-feature-text p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.auth-brand-social-proof {
    padding-top: 24px;
    border-top: 1px solid var(--border-light);
}

.auth-brand-social-proof p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

.auth-brand-social-proof strong {
    color: var(--text-secondary);
}

/* ---- Form Panel ---- */
.auth-form-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 40px;
    max-width: 560px;
}

.auth-form-container {
    width: 100%;
    max-width: 400px;
}

/* ---- Tabs ---- */
.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 28px;
    border-bottom: 1px solid var(--border);
}

.auth-tab {
    flex: 1;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    text-align: center;
}

.auth-tab:hover {
    color: var(--text-secondary);
}

.auth-tab:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    border-radius: 2px;
}

.auth-tab--active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ---- Forms ---- */
.auth-form {
    display: none;
}

.auth-form--active {
    display: block;
    animation: authFadeIn 0.25s ease-out;
}

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

.auth-form-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.auth-form-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.4;
}

/* ---- Form Groups ---- */
.auth-field {
    margin-bottom: 18px;
    position: relative;
}

.auth-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.auth-label .required {
    color: #f85149;
    margin-left: 2px;
}

.auth-input-wrap {
    position: relative;
}

.auth-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-input::placeholder {
    color: var(--text-muted);
}

.auth-input:hover {
    border-color: var(--text-muted);
}

.auth-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.auth-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.auth-input--error {
    border-color: #f85149;
}

.auth-input--error:focus {
    box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.15);
}

.auth-input--success {
    border-color: #3fb950;
}

/* Password visibility toggle */
.auth-password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 13px;
    line-height: 1;
    transition: color 0.15s;
}

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

.auth-password-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ---- Field Validation ---- */
.auth-field-error {
    font-size: 12px;
    color: #f85149;
    margin-top: 4px;
    min-height: 16px;
    line-height: 1.3;
    display: none;
}

.auth-field-error--visible {
    display: block;
    animation: authShake 0.3s ease-out;
}

@keyframes authShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

.auth-field-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ---- Password Strength ---- */
.auth-password-strength {
    margin-top: 8px;
    display: none;
}

.auth-password-strength--visible {
    display: block;
}

.auth-strength-bar-track {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 4px;
}

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

.auth-strength-bar-fill--weak {
    background: #f85149;
    width: 25%;
}

.auth-strength-bar-fill--fair {
    background: var(--yellow);
    width: 50%;
}

.auth-strength-bar-fill--good {
    background: #58a6ff;
    width: 75%;
}

.auth-strength-bar-fill--strong {
    background: #3fb950;
    width: 100%;
}

.auth-strength-label {
    font-size: 11px;
    font-weight: 500;
    transition: color 0.2s;
}

.auth-strength-label--weak { color: #f85149; }
.auth-strength-label--fair { color: var(--yellow); }
.auth-strength-label--good { color: #58a6ff; }
.auth-strength-label--strong { color: #3fb950; }

/* ---- Checkbox ---- */
.auth-checkbox-group {
    margin-bottom: 18px;
}

.auth-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1.4;
}

.auth-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.auth-checkbox-label a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: transparent;
    transition: text-decoration-color 0.15s;
}

.auth-checkbox-label a:hover {
    text-decoration-color: var(--accent);
}

/* ---- Buttons ---- */
.auth-btn {
    width: 100%;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-sans);
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, opacity 0.2s;
    position: relative;
    overflow: hidden;
}

.auth-btn:hover {
    background: var(--accent-hover);
}

.auth-btn:active {
    transform: scale(0.99);
}

.auth-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.auth-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.auth-btn--loading {
    color: transparent;
    pointer-events: none;
}

.auth-btn--loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: authSpin 0.6s linear infinite;
}

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

.auth-btn--secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.auth-btn--secondary:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

/* ---- Form-Level Alert ---- */
.auth-alert {
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 18px;
    display: none;
}

.auth-alert--visible {
    display: block;
    animation: authFadeIn 0.25s ease-out;
}

.auth-alert--error {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.3);
    color: #f85149;
}

.auth-alert--success {
    background: rgba(63, 185, 80, 0.1);
    border: 1px solid rgba(63, 185, 80, 0.3);
    color: #3fb950;
}

.auth-alert--warning {
    background: rgba(210, 153, 34, 0.1);
    border: 1px solid rgba(210, 153, 34, 0.3);
    color: var(--yellow);
}

.auth-alert--info {
    background: rgba(88, 166, 255, 0.1);
    border: 1px solid rgba(88, 166, 255, 0.3);
    color: var(--accent);
}

/* ---- Forgot Password Link ---- */
.auth-link-row {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 18px;
}

.auth-link {
    font-size: 13px;
    color: var(--accent);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
    transition: color 0.15s;
}

.auth-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.auth-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ---- Divider ---- */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    font-size: 12px;
    color: var(--text-muted);
}

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

/* ---- Key Display ---- */
.auth-key-display {
    display: none;
    margin-top: 16px;
}

.auth-key-display--visible {
    display: block;
    animation: authFadeIn 0.3s ease-out;
}

.auth-key-box {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 12px;
}

.auth-key-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.auth-key-value {
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-key-value code {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--accent);
    word-break: break-all;
    flex: 1;
}

.auth-key-copy {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.auth-key-copy:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.auth-key-copy:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.auth-key-warning {
    font-size: 12px;
    color: var(--yellow);
    line-height: 1.4;
    padding: 10px 12px;
    background: rgba(210, 153, 34, 0.08);
    border: 1px solid rgba(210, 153, 34, 0.2);
    border-radius: var(--radius);
}

/* ---- Success State ---- */
.auth-success {
    display: none;
    text-align: center;
    padding: 24px 0;
}

.auth-success--visible {
    display: block;
    animation: authFadeIn 0.35s ease-out;
}

.auth-success-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(63, 185, 80, 0.1);
    border: 2px solid rgba(63, 185, 80, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    animation: authCheckPop 0.4s ease-out 0.15s both;
}

@keyframes authCheckPop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.auth-success-icon svg {
    width: 28px;
    height: 28px;
    stroke: #3fb950;
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.auth-success h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.auth-success p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 20px;
}

/* ---- Back to Login ---- */
.auth-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 16px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: color 0.15s;
}

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

.auth-back-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ---- Footer ---- */
.auth-footer {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

.auth-footer a {
    color: var(--text-secondary);
}

/* ---- Google Sign-In Button ---- */
.google-signin-wrap {
    margin-bottom: 0;
}

.auth-btn--google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-weight: 500;
}

.auth-btn--google:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.auth-btn--google svg {
    flex-shrink: 0;
}

/* ---- MFA Method Tabs ---- */
.mfa-method-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.mfa-method-tab {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.mfa-method-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.mfa-method-tab--active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.mfa-input-group {
    animation: authFadeIn 0.25s ease-out;
}

/* ---- MFA Setup (Settings Page) ---- */
.mfa-method-card {
    padding: 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    margin-bottom: 12px;
}

.mfa-method-card:last-child {
    margin-bottom: 0;
}

.mfa-method-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.mfa-method-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.mfa-method-status {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
}

.mfa-method-status--enabled {
    color: #3fb950;
    background: rgba(63, 185, 80, 0.1);
}

.mfa-method-status--disabled {
    color: var(--text-muted);
    background: var(--bg-primary);
}

.mfa-method-status--unavailable {
    color: var(--text-muted);
    background: var(--bg-primary);
    opacity: 0.6;
}

.mfa-method-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 12px;
}

.mfa-setup-step {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.mfa-qr-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: #fff;
    border-radius: var(--radius);
    margin-bottom: 12px;
    width: fit-content;
}

.mfa-qr-container img {
    width: 200px;
    height: 200px;
}

.mfa-backup-codes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin: 12px 0;
}

.mfa-backup-code {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-primary);
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid var(--border);
    text-align: center;
}

/* ---- Switch Prompt (bottom link text) ---- */
.auth-switch-prompt {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 20px;
}

/* ---- 6-Segment OTP Input ---- */
.otp-input-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.otp-input {
    width: 44px;
    height: 52px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    caret-color: var(--accent);
}

.otp-input::placeholder {
    color: var(--text-muted);
    opacity: 0.4;
}

.otp-input:hover {
    border-color: var(--text-muted);
}

.otp-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.otp-input--error {
    border-color: #f85149;
}

.otp-input--error:focus {
    box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.15);
}

.otp-input--filled {
    border-color: var(--accent);
    background: rgba(88, 166, 255, 0.05);
}

.otp-separator {
    font-size: 20px;
    color: var(--text-muted);
    user-select: none;
    margin: 0 2px;
}

/* ---- Backup Codes Grid ---- */
.backup-codes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 20px 0;
}

.backup-code-item {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-align: center;
    letter-spacing: 1px;
}

.backup-codes-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.backup-codes-actions .auth-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    padding: 10px 14px;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 960px) {
    .auth-page {
        flex-direction: column;
    }

    .auth-brand {
        padding: 32px 24px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .auth-brand-tagline {
        font-size: 18px;
        margin-bottom: 20px;
    }

    .auth-brand-features {
        gap: 14px;
        margin-bottom: 24px;
    }

    .auth-brand-social-proof {
        display: none;
    }

    .auth-form-panel {
        max-width: none;
        padding: 32px 24px;
    }

    .auth-form-container {
        max-width: 400px;
        margin: 0 auto;
    }
}

/* Mobile: hide brand panel entirely so login form is visible without scrolling */
@media (max-width: 768px) {
    .auth-brand {
        display: none;
    }

    .auth-form-panel {
        padding: 24px 16px;
        min-height: 100vh;
        min-height: 100dvh;
        display: flex;
        align-items: flex-start;
        justify-content: center;
    }

    .auth-form-container {
        width: 100%;
        max-width: 400px;
        padding-top: 16px;
    }
}

@media (max-width: 480px) {
    .auth-brand-logo {
        font-size: 22px;
    }

    .auth-brand-tagline {
        font-size: 16px;
        margin-bottom: 16px;
    }

    .auth-brand-features {
        gap: 12px;
    }

    .auth-feature-icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .auth-form-panel {
        padding: 20px 16px;
    }

    .auth-form-title {
        font-size: 18px;
    }

    .auth-input {
        padding: 10px 12px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .auth-btn {
        padding: 14px 20px;
        font-size: 15px;
    }

    .otp-input {
        width: 38px;
        height: 46px;
        font-size: 18px;
    }

    .otp-input-group {
        gap: 5px;
    }

    .otp-separator {
        margin: 0;
    }

    .backup-codes-grid {
        grid-template-columns: 1fr;
    }

    .backup-codes-actions {
        flex-direction: column;
    }
}
