/**
 * UNERA Authentication - Enhanced Design System
 * Matches dashboard-enhanced.html and wallet-enhanced.html
 * 
 * Includes:
 * ✅ Option A: Critical Fixes (Unified design, AAA accessibility, focus states)
 * ✅ Option B: High Impact (Gradient titles, sticky CTAs, loading states, validation)
 * 
 * WCAG 2.1 AAA Compliant
 * Last Updated: January 20, 2026
 */

/* ========================================
   DESIGN SYSTEM - MATCH DASHBOARD/WALLET
   ======================================== */

:root {
    /* Primary Colors (Match Enhanced Pages) */
    --primary-green: #10B981;
    --primary-blue: #0EA5E9;
    --accent-pink: #EC4899;
    
    /* Neutral Scale */
    --neutral-900: #1F2937;
    --neutral-800: #374151;
    --neutral-700: #4B5563;
    --neutral-600: #6B7280;
    --neutral-500: #9CA3AF;
    --neutral-400: #D1D5DB;
    --neutral-300: #E5E7EB;
    --neutral-200: #F3F4F6;
    --neutral-100: #F9FAFB;
    --neutral-50: #FFFFFF;
    
    /* Semantic Colors */
    --success: #059669;
    --warning: #F59E0B;
    --error: #EF4444;
    --info: #3B82F6;
    
    /* Text Colors (AAA Contrast 7:1+) */
    --text-primary: #0F172A;     /* 13.4:1 on white */
    --text-secondary: #475569;   /* 8.5:1 on white */
    --text-tertiary: #64748B;    /* 6.2:1 on white */
    --text-disabled: #94A3B8;
    
    /* Border Colors */
    --border-subtle: #E2E8F0;
    --border-default: #CBD5E1;
    --border-strong: #94A3B8;
    
    /* Backgrounds */
    --bg-page: linear-gradient(135deg, #F3F4F6 0%, #E5E7EB 100%);
    --bg-card: #FFFFFF;
    --bg-input: #FFFFFF;
    --bg-hover: #F9FAFB;
    --bg-active: #F3F4F6;
    
    /* Gradients (Brand Identity) */
    --gradient-primary: linear-gradient(135deg, #10B981 0%, #0EA5E9 100%);
    --gradient-sky: linear-gradient(135deg, #0EA5E9 0%, #3B82F6 100%);
    --gradient-warm: linear-gradient(135deg, #F59E0B 0%, #EC4899 100%);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.15);
    --shadow-2xl: 0 25px 50px rgba(0,0,0,0.25);
    
    /* Typography */
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Z-Index */
    --z-dropdown: 1000;
    --z-sticky: 1100;
    --z-fixed: 1200;
    --z-modal-backdrop: 1300;
    --z-modal: 1400;
    --z-tooltip: 1600;
}

/* ========================================
   GLOBAL RESETS & BASE STYLES
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* ========================================
   ACCESSIBILITY - SKIP LINK
   ======================================== */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-green);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10000;
    border-radius: 0 0 8px 0;
    font-weight: 600;
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: 0;
    outline: 3px solid white;
    outline-offset: 2px;
}

/* ========================================
   FOCUS STATES (WCAG AAA)
   ======================================== */

*:focus-visible {
    outline: 3px solid var(--primary-green);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

button:focus-visible,
.btn:focus-visible {
    outline: 3px solid var(--primary-green);
    outline-offset: 3px;
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.1);
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary-green);
    outline: 2px solid var(--primary-green);
    outline-offset: 1px;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

a:focus-visible {
    outline: 2px solid var(--primary-green);
    outline-offset: 2px;
}

/* ========================================
   REDUCED MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

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

.header {
    padding: 1.375rem 2.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.688rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
}

.logo-text {
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.688rem 1.375rem;
    background: white;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
}

.back-btn:hover {
    background: var(--bg-hover);
    transform: translateX(-2px);
}

.back-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

/* ========================================
   AUTH CONTAINER - SINGLE COLUMN
   ======================================== */

.auth-container {
    max-width: 480px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Wider container for content-rich screens (KYC, onboarding, multi-step flows) */
.auth-container-wide {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

@media (max-width: 960px) {
    .auth-container-wide {
        max-width: 720px;
    }
}

@media (max-width: 768px) {
    .auth-container,
    .auth-container-wide {
        /* Allow natural height on mobile */
        min-height: auto;
        padding: 1.5rem 1rem;
        justify-content: flex-start;
    }
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius-2xl);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-lg);
    position: relative;
    width: 650px;
    max-width: 100%;
    margin: 0 auto;
}

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

.auth-header {
    text-align: center;
    margin-bottom: var(--space-8);
}

.logo-badge {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-6);
    background: var(--gradient-primary);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
}

.logo-badge svg {
    width: 36px;
    height: 36px;
    color: white;
}

/* ========================================
   GRADIENT TITLE (MATCH DASHBOARD)
   ======================================== */

.auth-title {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
    margin-bottom: var(--space-3);
}

.auth-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ========================================
   TRUST BAR - INLINE COMPACT
   ======================================== */

.trust-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: var(--space-4);
    margin: var(--space-6) 0;
    font-size: 0.813rem; /* 13px - matches form-hint */
    color: var(--text-secondary);
    text-align: center;
}

.trust-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 0.813rem; /* 13px - explicit size for consistency */
    color: var(--text-secondary);
}

.trust-item svg,
.trust-item .icon {
    width: 14px; /* Reduced to match smaller text */
    height: 14px;
    color: var(--primary-green);
    flex-shrink: 0;
}

.trust-divider {
    color: var(--neutral-400);
    user-select: none;
}

/* Mobile: Stack vertically */
@media (max-width: 640px) {
    .trust-bar {
        flex-direction: column;
        gap: var(--space-2);
    }
    
    .trust-divider {
        display: none;
    }

    /* KYC / 2FA setup: encryption + compliance lines */
    .trust-bar-minimal {
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
    }

    .trust-bar-minimal span:nth-child(2) {
        display: none;
    }
}

/* ========================================
   FORM ELEMENTS
   ======================================== */

.auth-form {
    width: 100%;
}

.form-group {
    margin-bottom: 1.5rem; /* 24px - consistent spacing between fields */
}

/* Reduce margin when error message is shown */
.form-group:has(.error-message) {
    margin-bottom: 0.75rem; /* 12px - reduced but still adequate spacing */
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2); /* 8px below label */
}

.form-hint {
    display: block;
    font-size: 0.813rem;
    color: var(--text-secondary);
    margin-top: 6px; /* 6px above hint for better grouping */
    line-height: 1.4;
}

/* ========================================
   INPUT FIELDS WITH VALIDATION
   ======================================== */

.form-input {
    width: 100%;
    height: 52px;
    padding: 0 var(--space-4);
    font-size: 1rem;
    font-family: var(--font-body);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
    line-height: 1.5;
}

.form-input::placeholder {
    color: var(--neutral-500);
}

.form-input:hover:not(:disabled) {
    border-color: var(--border-default);
}

/* Select elements - Dropdown styling */
select.form-input,
.form-select {
    padding-right: 3rem !important; /* Space for dropdown arrow */
    background-position: right 1rem center;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%236B7280" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>');
    background-repeat: no-repeat;
    cursor: pointer;
}

/* Ensure dropdown arrow shows on hover */
select.form-input:hover,
.form-select:hover {
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%2310B981" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>');
}

/* Override valid/invalid states for select to keep dropdown arrow */
select.form-input.valid,
select.form-input.invalid {
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%2310B981" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>') !important;
}

select.form-input.invalid {
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23EF4444" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>') !important;
}

/* Valid state */
.form-input.valid {
    border-color: var(--primary-green);
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%2310B981" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>');
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 3rem;
}

/* Invalid state */
.form-input.invalid {
    border-color: var(--error);
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23EF4444" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>');
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 3rem;
    animation: shake 0.4s ease-in-out;
}

/* Disabled state */
.form-input:disabled {
    background: var(--neutral-100);
    color: var(--text-disabled);
    cursor: not-allowed;
    border-color: var(--border-subtle);
}

/* Loading state */
.form-input.loading {
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%236B7280" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="2" x2="12" y2="6"/><line x1="12" y1="18" x2="12" y2="22"/><line x1="4.93" y1="4.93" x2="7.76" y2="7.76"/><line x1="16.24" y1="16.24" x2="19.07" y2="19.07"/><line x1="2" y1="12" x2="6" y2="12"/><line x1="18" y1="12" x2="22" y2="12"/><line x1="4.93" y1="19.07" x2="7.76" y2="16.24"/><line x1="16.24" y1="7.76" x2="19.07" y2="4.93"/></svg>');
    background-repeat: no-repeat;
    background-position: right 1rem center;
}

/* Shake animation for errors */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* ========================================
   ERROR MESSAGES
   ======================================== */

.error-message {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    margin-top: 8px; /* 8px above error - WCAG spacing */
    margin-bottom: 12px; /* 12px below error for clear separation */
    background: rgba(239, 68, 68, 0.05);
    border-left: 3px solid var(--error);
    border-radius: var(--radius-md);
    font-size: 0.813rem;
    color: var(--error);
    line-height: 1.4;
    animation: slideDown 0.3s ease-out;
}

.error-message::before {
    content: '⚠️';
    font-size: 0.875rem;
    flex-shrink: 0;
    line-height: 1;
}

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

/* ========================================
   SUCCESS MESSAGE (complement to .error-message)
   ======================================== */

.success-message {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    margin-top: 8px;
    margin-bottom: 12px;
    background: rgba(16, 185, 129, 0.08);
    border-left: 3px solid var(--primary-green);
    border-radius: var(--radius-md);
    font-size: 0.813rem;
    color: var(--success);
    line-height: 1.4;
    animation: slideDown 0.3s ease-out;
}

.success-message::before {
    content: '✓';
    font-size: 0.875rem;
    font-weight: 700;
    flex-shrink: 0;
    line-height: 1;
}

/* ========================================
   PROGRESS STEPPER (3-step horizontal)
   ======================================== */

.stepper {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-2);
    margin-bottom: var(--space-8);
    position: relative;
}

.stepper::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 15%;
    right: 15%;
    height: 2px;
    background: var(--border-subtle);
    z-index: 0;
}

.stepper-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    position: relative;
    z-index: 1;
    flex: 1;
}

.stepper-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 3px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--neutral-500);
    transition: all var(--transition-base);
}

.stepper-step.active .stepper-dot {
    border-color: var(--primary-green);
    color: var(--primary-green);
    background: rgba(16, 185, 129, 0.1);
}

.stepper-step.completed .stepper-dot {
    border-color: var(--primary-green);
    background: var(--primary-green);
    color: white;
    font-size: 0;
}

.stepper-step.completed .stepper-dot::after {
    content: '✓';
    font-size: 0.875rem;
    font-weight: 700;
    color: white;
}

.stepper-step.pending .stepper-dot {
    border-color: var(--border-subtle);
    background: var(--bg-card);
    color: var(--neutral-500);
}

.stepper-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
}

.stepper-step.active .stepper-label {
    color: var(--primary-green);
    font-weight: 600;
}

.stepper-step.completed .stepper-label {
    color: var(--text-secondary);
}

/* ========================================
   PASSWORD STRENGTH METER (4-segment bar)
   ======================================== */

.strength-meter {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.strength-meter-bars {
    display: flex;
    gap: 4px;
}

.strength-bar {
    height: 4px;
    flex: 1;
    background: var(--border-subtle);
    border-radius: 2px;
    transition: all var(--transition-base);
}

.strength-bar[data-level="1"].active {
    background: var(--error);
}

.strength-bar[data-level="2"].active {
    background: var(--warning);
}

.strength-bar[data-level="3"].active {
    background: #84CC16;
}

.strength-bar[data-level="4"].active {
    background: var(--primary-green);
}

.strength-meter-label {
    font-size: 0.813rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Password requirements checklist (used with strength meter) */
.requirement {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
    color: var(--text-secondary);
}

.requirement.met {
    color: var(--primary-green);
}

.requirement .req-icon {
    flex-shrink: 0;
}

/* ========================================
   PRIMARY BUTTON - ENHANCED
   ======================================== */

.submit-btn,
.btn-primary {
    width: 100%;
    height: 56px;
    padding: 0 var(--space-8);
    margin-top: 1.5rem; /* 24px - consistent spacing above submit button */
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
    position: relative;
    overflow: hidden;
}

.submit-btn:hover:not(:disabled),
.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.35);
}

.submit-btn:active:not(:disabled),
.btn-primary:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

/* Loading state */
.submit-btn.loading,
.btn-primary.loading {
    color: transparent;
    pointer-events: none;
}

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

/* Disabled state */
.submit-btn:disabled,
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Success state */
.submit-btn.success,
.btn-primary.success {
    background: var(--primary-green);
    color: white; /* Keep text visible */
}

/* Checkmark removed - text only success state */
/* This prevents overlapping with button text */

@keyframes checkmark {
    from {
        transform: translate(-50%, -50%) scale(0);
    }
    to {
        transform: translate(-50%, -50%) scale(1);
    }
}

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

/* ========================================
   SECONDARY BUTTON
   ======================================== */

.btn-secondary {
    width: 100%;
    height: 52px;
    padding: 0 var(--space-6);
    font-family: var(--font-body);
    font-size: 0.938rem;
    font-weight: 500;
    color: var(--text-primary);
    background: white;
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--primary-green);
    background: rgba(16, 185, 129, 0.03);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

/* ========================================
   SOCIAL/WALLET BUTTONS
   ======================================== */

.social-btn,
.wallet-btn {
    height: 52px;
    padding: 0 var(--space-6);
    background: white;
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    font-size: 0.938rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    position: relative;
}

.social-btn:hover:not(:disabled),
.wallet-btn:hover:not(:disabled) {
    border-color: var(--primary-green);
    background: rgba(16, 185, 129, 0.03);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.social-btn:active:not(:disabled),
.wallet-btn:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

/* Loading state */
.social-btn.loading,
.wallet-btn.loading {
    color: var(--neutral-500);
    pointer-events: none;
    border-color: var(--border-subtle);
}

.social-btn.loading .btn-icon,
.wallet-btn.loading .btn-icon {
    opacity: 0.3;
}

.social-btn.loading .btn-text,
.wallet-btn.loading .btn-text {
    color: transparent;
}

.social-btn.loading::after,
.wallet-btn.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid var(--neutral-300);
    border-top-color: var(--primary-green);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-text {
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

/* ========================================
   DIVIDER
   ======================================== */

.divider {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin: 2rem 0; /* 32px top & bottom - clear visual separation */
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

/* ========================================
   STICKY CTA ON MOBILE
   ======================================== */

@media (max-width: 768px) {
    .auth-form {
        /* Minimal padding since button is fixed at bottom */
        padding-bottom: 0;
    }
    
    .submit-btn.sticky-cta,
    .btn-primary.sticky-cta {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        margin-top: 16px;
        border-radius: 0;
        padding: 18px 1.125rem 1.125rem 1.125rem;
        z-index: var(--z-fixed);
        box-shadow: 0 -4px 16px rgba(0,0,0,0.15);
        backdrop-filter: blur(10px);
        background: linear-gradient(135deg, 
            rgba(16, 185, 129, 0.95) 0%, 
            rgba(14, 165, 233, 0.95) 100%
        );
    }
}

/* ========================================
   CHECKBOX & RADIO
   ======================================== */

.checkbox-group,
.radio-group {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

.checkbox-group {
    margin-top: 0.5rem; /* 8px above checkbox */
    margin-bottom: 1.5rem; /* 24px below checkbox - consistent with form-group */
}

/* Remember me & Forgot password row (login page) */
.remember-forgot-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.5rem; /* 8px above */
    margin-bottom: 0;
}

.remember-forgot-wrapper .checkbox-group {
    margin: 0; /* Reset margins in this context */
}

.remember-forgot-wrapper .auth-link {
    white-space: nowrap; /* Prevent link from breaking awkwardly */
}

/* Hide "Remember me" checkbox on desktop/tablet for security (only show on mobile) */
@media (min-width: 769px) {
    .remember-forgot-wrapper .checkbox-group {
        display: none;
    }
    
    /* Center forgot password link when remember me is hidden */
    .remember-forgot-wrapper {
        justify-content: flex-end;
    }
}

.checkbox-input,
.radio-input {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--primary-green);
}

.checkbox-label,
.radio-label {
    flex: 1;
    font-size: 0.813rem; /* 13px - matches form-hint for consistent hierarchy */
    line-height: 1.5;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}

/* ========================================
   LINKS
   ======================================== */

.auth-link {
    color: var(--primary-green);
    text-decoration: none;
    font-size: 0.813rem; /* 13px - matches form-hint */
    font-weight: 500;
    transition: color var(--transition-fast);
    margin-bottom: 0px;
    padding-top: 0px;
    display: flex;
    flex-wrap: wrap;
    /* margin-top: -4px; */
    vertical-align: middle;
    line-height: 22.4px;
}

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

.login-link {
    text-align: center;
    font-size: 0.813rem; /* 13px - matches form-hint for consistent hierarchy */
    color: var(--text-secondary);
    margin-top: 1.5rem; /* 24px - consistent spacing above login link */
    margin-bottom: 0;
}

.login-link a {
    color: var(--primary-green);
    text-decoration: none;
    font-weight: 600;
}

.login-link a:hover {
    text-decoration: underline;
}

/* ========================================
   PASSWORD TOGGLE
   ======================================== */

.password-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
}

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

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

/* Hide password toggle when input has validation feedback to prevent overlap with icons */
.form-input.valid ~ .password-toggle,
.form-input.invalid ~ .password-toggle,
.form-input.loading ~ .password-toggle {
    display: none !important;
}

/* Adjust password input padding when toggle is hidden */
.form-input.valid,
.form-input.invalid,
.form-input.loading {
    padding-right: 3rem !important;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

.toast-notification {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: var(--z-tooltip);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    max-width: 420px;
    min-width: 300px;
    animation: slideInRight 0.3s ease-out;
}

.toast-notification.slideOut {
    animation: slideOutRight 0.3s ease-out forwards;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Toast on mobile */
@media (max-width: 768px) {
    .toast-notification {
        top: auto;
        bottom: 2rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
    }
}

/* ========================================
   MODAL
   ======================================== */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    padding: var(--space-4);
    animation: fadeIn 0.3s ease-out;
}

.modal.show {
    display: flex;
}

.modal-overlay {
    position: absolute;
    inset: 0;
}

.modal-content {
    background: white;
    border-radius: var(--radius-2xl);
    padding: var(--space-10) var(--space-8);
    max-width: 440px;
    width: 100%;
    text-align: center;
    position: relative;
    z-index: 1;
    animation: scaleIn 0.3s ease-out;
    box-shadow: var(--shadow-2xl);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-content h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--space-3);
    color: var(--text-primary);
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: var(--space-8);
    line-height: 1.6;
}

/* Bottom sheet on mobile */
@media (max-width: 768px) {
    .modal {
        align-items: flex-end;
    }
    
    .modal-content {
        width: 100%;
        max-height: 80vh;
        border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
        animation: slideUp 0.3s ease-out;
    }
    
    /* Handle for dragging down */
    .modal-content::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: var(--neutral-400);
        border-radius: 2px;
        margin: 0 auto var(--space-4);
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.hidden { display: none !important; }
.visible { display: block !important; }

/* ========================================
   MOBILE OPTIMIZATIONS
   ======================================== */

@media (max-width: 768px) {
    .auth-container {
        padding: 1rem;
    }
    
    .auth-card {
        padding: 2rem 1.5rem;
        /* Ensure login link is visible */
        margin-bottom: 1rem;
    }
    
    .auth-title {
        font-size: 1.75rem;
    }
    
    .form-input,
    .submit-btn,
    .social-btn {
        height: 52px;
        font-size: 1rem; /* 16px prevents iOS zoom */
    }
    
    .form-group {
        margin-bottom: 1rem; /* 16px on mobile - adequate spacing */
    }

    /* Reduce when error is present on mobile */
    .form-group:has(.error-message) {
        margin-bottom: 0.5rem; /* 8px - minimum WCAG spacing */
    }

    /* Responsive error message spacing */
    .error-message {
        margin-top: 8px; /* 8px - minimum WCAG spacing */
        margin-bottom: 10px; /* 10px below error */
    }
    
    .submit-btn,
    .btn-primary {
        margin-top: 1rem; /* 16px on mobile */
    }
    
    .checkbox-group {
        margin-bottom: 1rem; /* 16px on mobile */
    }
    
    .login-link {
        margin-top: 1rem; /* 16px on mobile */
    }
    
    .divider {
        margin: 1.5rem 0; /* 24px on mobile */
    }
    
    /* Larger touch targets - WCAG 2.1 AAA */
    button,
    input:not([type="checkbox"]):not([type="radio"]),
    a,
    .clickable,
    .btn-primary,
    .btn-secondary,
    .btn-back {
        min-height: 44px;
        min-width: 44px;
    }

    /* Keep checkboxes and radio buttons small */
    input[type="checkbox"],
    input[type="radio"],
    .checkbox-input,
    .radio-input {
        width: 20px !important;
        height: 20px !important;
        min-width: 20px !important;
        min-height: 20px !important;
        flex-shrink: 0;
    }

    /* But ensure the label (clickable area) meets touch target */
    .checkbox-group,
    .radio-option {
        min-height: 44px;
        display: flex;
        align-items: center;
        cursor: pointer;
    }
}

/* Small mobile */
@media (max-width: 640px) {
    .auth-card {
        padding: 1.5rem 1.25rem;
    }

    .auth-title {
        font-size: 1.5rem;
    }

    .header {
        padding: 1rem;
    }

    .logo-text {
        font-size: 1.25rem;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .auth-container {
        padding: 0.75rem;
    }

    .auth-card {
        padding: 1.5rem 1rem;
    }

    .auth-title {
        font-size: 1.25rem;
    }

    .auth-subtitle {
        font-size: 0.875rem;
    }

    .submit-btn,
    .social-btn {
        padding: 0.875rem 1.25rem;
        font-size: 0.938rem;
    }

    /* Tighter spacing on very small screens */
    .error-message {
        margin-top: var(--space-2); /* 8px on small mobile */
    }
}

@media (max-width: 375px) {
    .auth-card {
        padding: 1.25rem 0.875rem;
    }

    .auth-title {
        font-size: 1.125rem;
    }
}

/* Images responsiveness */
img {
    max-width: 100%;
    height: auto;
}

/* ========================================
   HIGH CONTRAST MODE
   ======================================== */

@media (prefers-contrast: high) {
    .form-input {
        border-width: 2px;
    }
    
    .btn-secondary {
        border-width: 2px;
    }
    
    *:focus-visible {
        outline-width: 4px;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .trust-bar,
    .toast-notification,
    .modal,
    .skip-link {
        display: none !important;
    }
}
