/**
 * Authentication Modal Styles
 *
 * Design principles:
 * - Consistent with main design system
 * - Accessible contrast ratios (WCAG AA)
 * - Smooth transitions and microinteractions
 * - Mobile-first responsive design
 */

/* =============================================================================
   AUTH MODAL BASE
   ============================================================================= */

.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.auth-modal.open {
    opacity: 1;
    visibility: visible;
}

.auth-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.auth-modal-container {
    position: relative;
    width: 100%;
    max-width: 420px;
    margin: var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.25s ease;
}

.auth-modal.open .auth-modal-container {
    transform: translateY(0) scale(1);
}

.auth-modal-close {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.auth-modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-glass);
}

.auth-modal-close:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-muted);
}

/* =============================================================================
   HEADER
   ============================================================================= */

.auth-modal-header {
    padding: var(--space-8) var(--space-6) var(--space-4);
    text-align: center;
}

.auth-modal-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.auth-modal-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    word-break: break-word;
}

/* =============================================================================
   ALERT MESSAGES
   ============================================================================= */

.auth-alert {
    margin: 0 var(--space-6) var(--space-4);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: 13px;
    text-align: center;
    display: none;
}

.auth-alert.visible {
    display: block;
}

.auth-alert.error {
    background: var(--error-muted);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error);
}

.auth-alert.success {
    background: var(--success-muted);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success);
}

/* =============================================================================
   FORMS
   ============================================================================= */

.auth-forms {
    padding: 0 var(--space-6) var(--space-6);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

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

.auth-form .form-group {
    margin-bottom: var(--space-4);
}

.auth-form .form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.auth-form .form-label .required {
    color: var(--error);
}

.auth-form .form-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-form .form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

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

.auth-form .form-input.error {
    border-color: var(--error);
}

.auth-form .form-input.error:focus {
    box-shadow: 0 0 0 3px var(--error-muted);
}

.auth-form .form-input.valid {
    border-color: var(--success);
}

.auth-form .form-error {
    font-size: 12px;
    color: var(--error);
    margin-top: var(--space-2);
    display: none;
}

.auth-form .form-error.visible {
    display: block;
}

/* =============================================================================
   FORGOT PASSWORD LINK
   ============================================================================= */

.auth-forgot-link {
    display: inline-block;
    margin-top: var(--space-2);
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s ease;
}

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

/* =============================================================================
   FORM DESCRIPTION (used in forgot password flow)
   ============================================================================= */

.auth-form-description {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: var(--space-5);
}

/* =============================================================================
   RESET CODE INPUT
   ============================================================================= */

.auth-form .form-input[inputmode="numeric"] {
    text-align: center;
    letter-spacing: 0.5em;
    font-size: 20px;
    font-weight: 600;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

/* =============================================================================
   SUCCESS VIEW
   ============================================================================= */

.auth-success-icon {
    width: 56px;
    height: 56px;
    margin: var(--space-4) auto var(--space-5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: var(--success);
    background: var(--success-muted);
    border: 2px solid rgba(16, 185, 129, 0.3);
    border-radius: 50%;
    animation: fadeIn 0.3s ease;
}

.auth-success-message {
    font-size: 15px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: var(--space-6);
    line-height: 1.5;
}

/* =============================================================================
   BACK BUTTON
   ============================================================================= */

.auth-back-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    padding: 0;
    background: none;
    border: none;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s ease;
}

.auth-back-btn:hover {
    color: var(--text-primary);
}

/* =============================================================================
   SUBMIT BUTTON
   ============================================================================= */

.auth-submit-btn {
    width: 100%;
    padding: var(--space-3) var(--space-5);
    margin-top: var(--space-4);
    font-size: 15px;
    font-weight: 500;
    color: white;
    background: var(--gradient-accent);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.auth-submit-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.auth-submit-btn:active:not(:disabled) {
    transform: translateY(0);
}

.auth-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-submit-btn.loading {
    position: relative;
    color: transparent;
}

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

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

/* =============================================================================
   FOOTER
   ============================================================================= */

.auth-modal-footer {
    padding: var(--space-5) var(--space-6);
    text-align: center;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-tertiary);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.auth-toggle-text {
    font-size: 14px;
    color: var(--text-muted);
}

.auth-toggle-link {
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--accent);
    cursor: pointer;
    transition: color 0.15s ease;
}

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

/* =============================================================================
   PASSWORD STRENGTH METER
   ============================================================================= */

.password-strength-container {
    margin-top: var(--space-3);
}

.password-strength {
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.strength-bar-container {
    height: 4px;
    background: var(--border-default);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: var(--space-2);
}

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

.strength-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

.strength-label {
    font-size: 12px;
    font-weight: 500;
}

.strength-message {
    font-size: 12px;
    color: var(--text-muted);
}

.strength-suggestions {
    margin: var(--space-2) 0 0 0;
    padding-left: var(--space-4);
    list-style: disc;
    font-size: 11px;
    color: var(--text-muted);
}

.strength-suggestions li {
    margin-bottom: 2px;
}

/* =============================================================================
   TURNSTILE
   ============================================================================= */

.turnstile-container {
    margin: var(--space-4) 0;
    display: flex;
    justify-content: center;
}

/* Hide the container when not needed */
.turnstile-container:empty {
    display: none;
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 480px) {
    .auth-modal-container {
        margin: var(--space-2);
        max-width: none;
        border-radius: var(--radius-lg);
    }

    .auth-modal-header {
        padding: var(--space-6) var(--space-5) var(--space-3);
    }

    .auth-forms {
        padding: 0 var(--space-5) var(--space-5);
    }

    .auth-modal-footer {
        padding: var(--space-4) var(--space-5);
        border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    }

    .auth-modal-title {
        font-size: 20px;
    }
}

/* =============================================================================
   FOCUS VISIBLE (Keyboard Navigation)
   ============================================================================= */

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

.auth-form .form-input:focus-visible {
    outline: none;
}
