/**
 * Authentication System - Shared Design System
 * 
 * Centralized CSS variables and component styles for all registration pages
 * Reduces code duplication by ~70% and ensures consistent design
 * 
 * Pages using this system:
 * - /register (Business)
 * - /register-driver
 * - /register-customer  
 * - /register-role-selector
 */

/* ========================================
   CSS CUSTOM PROPERTIES (DESIGN TOKENS)
   ======================================== */

:root {
    /* --- Brand Colors --- */
    --color-primary: #4F46E5;      /* Indigo-600 */
    --color-primary-dark: #4338CA; /* Indigo-700 */
    --color-primary-light: #EEF2FF; /* Indigo-50 */
    
    /* --- Role Colors --- */
    --color-business: #7C3AED;     /* Violet-600 */
    --color-business-dark: #6D28D9; /* Violet-700 */
    --color-business-light: #F5F3FF; /* Violet-50 */
    
    --color-driver: #2563EB;       /* Blue-600 */
    --color-driver-dark: #1D4ED8;  /* Blue-700 */
    --color-driver-light: #EFF6FF; /* Blue-50 */
    
    --color-customer: #059669;     /* Emerald-600 */
    --color-customer-dark: #047857; /* Emerald-700 */
    --color-customer-light: #ECFDF5; /* Emerald-50 */
    
    /* --- Neutral Colors --- */
    --color-gray-50: #F9FAFB;
    --color-gray-100: #F3F4F6;
    --color-gray-200: #E5E7EB;
    --color-gray-300: #D1D5DB;
    --color-gray-400: #9CA3AF;
    --color-gray-500: #6B7280;
    --color-gray-600: #4B5563;
    --color-gray-700: #374151;
    --color-gray-800: #1F2937;
    --color-gray-900: #111827;
    
    --color-white: #FFFFFF;
    --color-black: #000000;
    
    /* --- Semantic Colors --- */
    --color-success: #10B981;      /* Green-500 */
    --color-success-light: #D1FAE5; /* Green-100 */
    --color-error: #EF4444;        /* Red-500 */
    --color-error-light: #FEE2E2;  /* Red-100 */
    --color-warning: #F59E0B;      /* Amber-500 */
    --color-warning-light: #FEF3C7; /* Amber-100 */
    --color-info: #3B82F6;         /* Blue-500 */
    --color-info-light: #DBEAFE;   /* Blue-100 */
    
    /* --- Spacing Scale --- */
    --space-xs: 0.5rem;    /* 8px */
    --space-sm: 0.75rem;   /* 12px */
    --space-md: 1rem;      /* 16px */
    --space-lg: 1.5rem;    /* 24px */
    --space-xl: 2rem;      /* 32px */
    --space-2xl: 3rem;     /* 48px */
    --space-3xl: 4rem;     /* 64px */
    
    /* --- Typography Scale --- */
    --font-size-xs: 0.75rem;   /* 12px */
    --font-size-sm: 0.875rem;  /* 14px */
    --font-size-base: 1rem;    /* 16px */
    --font-size-lg: 1.125rem;  /* 18px */
    --font-size-xl: 1.25rem;   /* 20px */
    --font-size-2xl: 1.5rem;   /* 24px */
    --font-size-3xl: 1.875rem; /* 30px */
    --font-size-4xl: 2.25rem;  /* 36px */
    --font-size-5xl: 3rem;     /* 48px */
    
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    
    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.75;
    
    /* --- Border Radius --- */
    --radius-sm: 0.25rem;  /* 4px */
    --radius-md: 0.375rem; /* 6px */
    --radius-lg: 0.5rem;   /* 8px */
    --radius-xl: 0.75rem;  /* 12px */
    --radius-2xl: 1rem;    /* 16px */
    --radius-full: 9999px; /* Fully rounded */
    
    /* --- Shadows --- */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* --- Transitions --- */
    --transition-fast: 150ms ease-in-out;
    --transition-base: 200ms ease-in-out;
    --transition-slow: 300ms ease-in-out;
    
    /* --- Z-Index Scale --- */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    
    /* --- Breakpoints (for JS/reference) --- */
    --breakpoint-sm: 640px;
    --breakpoint-md: 768px;
    --breakpoint-lg: 1024px;
    --breakpoint-xl: 1280px;
    --breakpoint-2xl: 1536px;
}

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

html, body {
    overflow-x: hidden;
    max-width: 100vw;
    margin: 0;
    padding: 0;
    font-family: 'Nunito', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

*, *::before, *::after {
    box-sizing: border-box;
}

/* Mobile viewport height fix (accounts for browser UI) */
html {
    height: 100%;
    height: calc(var(--vh, 1vh) * 100);
}

body {
    min-height: 100%;
    min-height: calc(var(--vh, 1vh) * 100);
}

/* ========================================
   AUTH LAYOUT SYSTEM
   ======================================== */

.auth-container {
    display: flex;
    min-height: 100vh;
    min-height: calc(var(--vh, 1vh) * 100);
    max-width: 100vw;
    overflow: hidden;
}

/* Left Panel - Information/Benefits */
.info-panel {
    flex: 0 0 40%;
    padding: var(--space-2xl);
    color: var(--color-white);
    position: relative;
    overflow-y: auto;
    max-height: 100vh;
    max-height: calc(var(--vh, 1vh) * 100);
}

/* Right Panel - Form */
.form-panel {
    flex: 1;
    background: var(--color-white);
    padding: var(--space-2xl);
    overflow-y: auto;
    max-height: 100vh;
    max-height: calc(var(--vh, 1vh) * 100);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Scrollbar Styling (Desktop) */
@media (min-width: 1024px) {
    .info-panel::-webkit-scrollbar,
    .form-panel::-webkit-scrollbar {
        width: 6px;
    }
    
    .info-panel::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.3);
        border-radius: 3px;
    }
    
    .form-panel::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.2);
        border-radius: 3px;
    }
}

/* Mobile: Stack panels vertically */
@media (max-width: 767px) {
    .auth-container {
        flex-direction: column;
    }
    
    .info-panel {
        flex: 0 0 auto;
        min-height: 30vh;
        padding: var(--space-lg);
    }
    
    .form-panel {
        flex: 1;
        padding: var(--space-lg);
        max-height: none;
    }
}

/* ========================================
   FORM COMPONENTS
   ======================================== */

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

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

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-gray-700);
    margin-bottom: var(--space-xs);
}

.form-label .required {
    color: var(--color-error);
    margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    min-height: 44px; /* Touch target size */
    padding: 0.625rem 0.875rem; /* 10px 14px */
    font-size: var(--font-size-base); /* 16px - prevents iOS zoom */
    font-family: inherit;
    color: var(--color-gray-900);
    background: var(--color-white);
    border: 1px solid var(--color-gray-300);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-input::placeholder {
    color: var(--color-gray-400);
}

/* Valid state */
.form-input.valid,
.form-select.valid {
    border-color: var(--color-success);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2310B981' viewBox='0 0 16 16'%3E%3Cpath d='M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px;
    padding-right: 2.5rem;
}

/* Invalid state */
.form-input.invalid,
.form-select.invalid {
    border-color: var(--color-error);
}

.error-message {
    display: block;
    margin-top: var(--space-xs);
    font-size: var(--font-size-sm);
    color: var(--color-error);
}

.form-helper {
    display: block;
    margin-top: var(--space-xs);
    font-size: var(--font-size-sm);
    color: var(--color-gray-500);
}

/* Textarea */
.form-textarea {
    min-height: 100px;
    resize: vertical;
}

/* Checkbox & Radio */
.form-checkbox,
.form-radio {
    width: 20px;
    height: 20px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-gray-300);
    cursor: pointer;
    transition: all var(--transition-base);
}

.form-radio {
    border-radius: var(--radius-full);
}

.form-checkbox:checked,
.form-radio:checked {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

/* Mobile: Compact spacing */
@media (max-width: 767px) {
    .form-group {
        margin-bottom: var(--space-md);
    }
    
    .form-label {
        font-size: var(--font-size-sm);
        margin-bottom: var(--space-xs);
    }
    
    .form-input,
    .form-select,
    .form-textarea {
        height: 44px; /* Minimum touch target */
        font-size: var(--font-size-base); /* 16px to prevent iOS zoom */
    }
}

/* ========================================
   BUTTONS
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    min-height: 44px; /* Touch target */
    padding: 0.625rem 1.25rem;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    text-decoration: none;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
}

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

/* Primary Button */
.btn-primary {
    color: var(--color-white);
    background: var(--color-primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Secondary Button */
.btn-secondary {
    color: var(--color-primary);
    background: var(--color-primary-light);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-gray-200);
}

/* Outline Button */
.btn-outline {
    color: var(--color-gray-700);
    background: var(--color-white);
    border: 1px solid var(--color-gray-300);
}

.btn-outline:hover:not(:disabled) {
    background: var(--color-gray-50);
    border-color: var(--color-gray-400);
}

/* Full width */
.btn-block {
    width: 100%;
}

/* Sizes */
.btn-sm {
    min-height: 36px;
    padding: 0.5rem 1rem;
    font-size: var(--font-size-sm);
}

.btn-lg {
    min-height: 52px;
    padding: 0.75rem 1.5rem;
    font-size: var(--font-size-lg);
}

/* ========================================
   CARDS & CONTAINERS
   ======================================== */

.card {
    background: var(--color-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: var(--space-lg);
    transition: all var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-xl);
    transform: translateY(-2px);
}

/* Role Card */
.role-card {
    cursor: pointer;
    border: 2px solid transparent;
    min-height: 44px; /* Touch target for entire card */
}

.role-card:hover {
    border-color: var(--color-primary);
}

.role-card.active {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

/* Category Card (Business Registration) */
.category-card {
    cursor: pointer;
    text-align: center;
    border: 2px solid var(--color-gray-200);
    transition: all var(--transition-base);
    min-height: 44px;
}

.category-card:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.category-card.active {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

/* ========================================
   GRIDS & LAYOUTS
   ======================================== */

/* Role Cards Grid */
.role-cards-grid {
    display: grid;
    gap: var(--space-lg);
}

@media (max-width: 767px) {
    .role-cards-grid {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }
}

@media (min-width: 768px) and (max-width: 1199px) {
    .role-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1200px) {
    .role-cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Category Grid (Business Registration) */
.category-grid {
    display: grid;
    gap: var(--space-sm);
}

@media (max-width: 767px) {
    .category-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .category-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .category-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ========================================
   STICKY FORM ACTIONS (MOBILE)
   ======================================== */

@media (max-width: 767px) {
    .form-actions {
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--color-white);
        padding: var(--space-md);
        box-shadow: 0 -4px 6px -1px rgb(0 0 0 / 0.1);
        z-index: var(--z-sticky);
        margin-left: calc(var(--space-lg) * -1);
        margin-right: calc(var(--space-lg) * -1);
        margin-bottom: calc(var(--space-lg) * -1);
    }
    
    .form-panel {
        padding-bottom: calc(var(--space-lg) + 80px);
    }
}

/* ========================================
   MOBILE BENEFITS BANNER
   ======================================== */

.mobile-benefits {
    display: none;
}

@media (max-width: 767px) {
    .info-panel {
        display: none; /* Hide full info panel on mobile */
    }
    
    .mobile-benefits {
        display: block;
        padding: var(--space-md);
        margin-bottom: var(--space-lg);
        border-radius: var(--radius-lg);
    }
    
    .mobile-benefits ul {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-sm);
        font-size: var(--font-size-sm);
        list-style: none;
        margin: 0;
        padding: 0;
    }
    
    .mobile-benefits li {
        display: flex;
        align-items: start;
        gap: var(--space-xs);
    }
}

@media (min-width: 768px) {
    .mobile-benefits {
        display: none;
    }
}

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

/* Text */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }
.text-3xl { font-size: var(--font-size-3xl); }

.font-normal { font-weight: var(--font-weight-normal); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }

/* Colors */
.text-primary { color: var(--color-primary); }
.text-gray-500 { color: var(--color-gray-500); }
.text-gray-600 { color: var(--color-gray-600); }
.text-gray-700 { color: var(--color-gray-700); }
.text-gray-900 { color: var(--color-gray-900); }
.text-white { color: var(--color-white); }

.bg-primary { background-color: var(--color-primary); }
.bg-primary-light { background-color: var(--color-primary-light); }
.bg-white { background-color: var(--color-white); }
.bg-gray-50 { background-color: var(--color-gray-50); }
.bg-gray-100 { background-color: var(--color-gray-100); }

/* Spacing */
.mt-1 { margin-top: var(--space-xs); }
.mt-2 { margin-top: var(--space-sm); }
.mt-3 { margin-top: var(--space-md); }
.mt-4 { margin-top: var(--space-lg); }
.mt-6 { margin-top: var(--space-xl); }

.mb-1 { margin-bottom: var(--space-xs); }
.mb-2 { margin-bottom: var(--space-sm); }
.mb-3 { margin-bottom: var(--space-md); }
.mb-4 { margin-bottom: var(--space-lg); }
.mb-6 { margin-bottom: var(--space-xl); }

.p-2 { padding: var(--space-sm); }
.p-3 { padding: var(--space-md); }
.p-4 { padding: var(--space-lg); }
.p-6 { padding: var(--space-xl); }

/* Display */
.block { display: block; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.grid { display: grid; }
.hidden { display: none; }

/* Flexbox */
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-sm); }
.gap-3 { gap: var(--space-md); }
.gap-4 { gap: var(--space-lg); }

/* Borders */
.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

/* Shadows */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* Transitions */
.transition { transition: all var(--transition-base); }
.transition-fast { transition: all var(--transition-fast); }

/* ========================================
   PASSWORD STRENGTH INDICATOR
   ======================================== */

.password-strength-meter {
    height: 4px;
    background: var(--color-gray-200);
    border-radius: var(--radius-full);
    margin-top: var(--space-xs);
    overflow: hidden;
}

.password-strength-bar {
    height: 100%;
    width: 0%;
    transition: all var(--transition-base);
    border-radius: var(--radius-full);
}

.password-strength-bar.weak {
    width: 25%;
    background: var(--color-error);
}

.password-strength-bar.fair {
    width: 50%;
    background: var(--color-warning);
}

.password-strength-bar.good {
    width: 75%;
    background: var(--color-info);
}

.password-strength-bar.strong {
    width: 100%;
    background: var(--color-success);
}

.password-requirements {
    margin-top: var(--space-sm);
    font-size: var(--font-size-sm);
}

.password-requirements li {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--color-gray-500);
    transition: color var(--transition-base);
}

.password-requirements li.met {
    color: var(--color-success);
}

/* ========================================
   FORM SUBMISSION - LOADING STATES (Phase 3)
   ======================================== */

/* Loading Spinner */
.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--color-white);
    animation: spin 0.6s linear infinite;
}

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

/* Button Loading State */
.btn.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

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

/* Submit Progress Indicator */
.submit-progress {
    margin-top: var(--space-md);
    animation: fadeIn 0.3s ease;
}

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

.progress-bar {
    height: 4px;
    background: var(--color-gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--space-xs);
}

.progress-fill {
    height: 100%;
    width: 0;
    background: var(--color-primary);
    transition: width 0.3s ease;
    border-radius: var(--radius-full);
}

.progress-text {
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--color-gray-600);
}

/* Button Disabled State (Enhanced for Terms) */
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* ========================================
   FORM AUTOSAVE INDICATOR (Phase 3)
   ======================================== */

.autosave-indicator {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: var(--color-gray-100);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    color: var(--color-gray-600);
    animation: slideIn 0.3s ease;
}

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

.autosave-indicator.saving {
    background: var(--color-info-light);
    color: var(--color-info);
}

.autosave-indicator.saved {
    background: var(--color-success-light);
    color: var(--color-success);
}

.autosave-indicator i {
    font-size: var(--font-size-xs);
}

/* ========================================
   ERROR SUMMARY (Phase 3)
   ======================================== */

.error-summary {
    background: var(--color-error-light);
    border: 1px solid var(--color-error);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
    animation: shakeError 0.4s ease;
}

@keyframes shakeError {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.error-summary-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-error);
    margin-bottom: var(--space-sm);
}

.error-summary-title i {
    font-size: var(--font-size-lg);
}

.error-summary-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.error-summary-list li {
    padding: var(--space-xs) 0;
}

.error-summary-list a {
    color: var(--color-error);
    text-decoration: none;
    font-size: var(--font-size-sm);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    transition: all var(--transition-fast);
}

.error-summary-list a:hover {
    text-decoration: underline;
    padding-left: var(--space-xs);
}

.error-summary-list a i {
    font-size: var(--font-size-xs);
}

/* ========================================
   CONDITIONAL FIELDS (Phase 3)
   ======================================== */

.conditional-field {
    overflow: hidden;
    transition: all var(--transition-base);
}

.conditional-field.hidden {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
    visibility: hidden;
}

.conditional-field.visible {
    max-height: 1000px;
    opacity: 1;
    visibility: visible;
}

/* Smooth slide animation */
@keyframes slideDown {
    from {
        max-height: 0;
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        max-height: 1000px;
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        max-height: 1000px;
        opacity: 1;
        transform: translateY(0);
    }
    to {
        max-height: 0;
        opacity: 0;
        transform: translateY(-10px);
    }
}

.conditional-field.animating-in {
    animation: slideDown 0.3s ease forwards;
}

.conditional-field.animating-out {
    animation: slideUp 0.3s ease forwards;
}

/* ========================================
   PHASE 4: MOBILE OPTIMIZATION
   ======================================== */

/**
 * Touch Target Improvements
 * - Minimum 44x44px for all interactive elements (Apple HIG)
 * - 48px on mobile for easier tapping
 * - Proper spacing to prevent accidental taps
 */

/* Ensure minimum touch targets across all interactive elements */
.btn,
.form-input,
.form-select,
.form-textarea,
.custom-checkbox-wrapper,
.category-chip,
.nav-btn,
.role-cta,
.terms-link,
input[type="submit"],
input[type="button"],
button {
    min-height: 44px;
    min-width: 44px;
}

/* Form inputs need proper height */
.form-input,
.form-select {
    min-height: 44px;
    padding: var(--space-sm) var(--space-md);
}

.form-textarea {
    min-height: 120px;
}

/* Category chips - ensure clickable area */
.category-chip {
    min-height: 44px;
    padding: var(--space-sm) var(--space-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Checkbox - expand clickable area with wrapper */
.checkbox-container {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.custom-checkbox {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

/* Mobile: Larger touch targets */
@media (max-width: 767px) {
    .btn,
    .role-cta,
    .form-input,
    .form-select {
        min-height: 48px;
        font-size: 16px; /* Prevents iOS zoom */
    }
    
    .category-chip {
        min-height: 48px;
        padding: var(--space-md) var(--space-lg);
    }
}

/**
 * Typography Optimization for Mobile
 * - 16px minimum prevents iOS zoom on focus
 * - Responsive scaling for headings
 * - Better line-height for readability
 */

/* Prevent iOS auto-zoom on input focus */
.form-input,
.form-select,
.form-textarea {
    font-size: 16px !important; /* Never below 16px */
}

/* Responsive typography scale */
@media (max-width: 767px) {
    /* Heading size adjustments */
    h1, .main-title {
        font-size: 1.75rem; /* Down from 2.5rem */
        line-height: 1.2;
        margin-bottom: var(--space-md);
    }
    
    h2, .welcome-title {
        font-size: 1.5rem; /* Down from 2rem */
        line-height: 1.3;
    }
    
    h3, .role-title {
        font-size: 1.25rem; /* Down from 1.5rem */
        line-height: 1.4;
    }
    
    /* Body text - improve readability */
    p, .benefit-content p, .info-text {
        font-size: var(--font-size-base);
        line-height: 1.6; /* Increased from 1.5 */
    }
    
    /* Small text - never below 14px */
    .text-sm, .helper-text, .form-help {
        font-size: 14px;
        line-height: 1.5;
    }
    
    /* Button text */
    .btn {
        font-size: 16px;
        padding: 12px 24px;
    }
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 991px) {
    h1, .main-title {
        font-size: 2rem;
    }
    
    h2, .welcome-title {
        font-size: 1.75rem;
    }
}

/**
 * Safe Area Insets
 * - Handles iPhone X+ notch and Dynamic Island
 * - Ensures content doesn't overlap with system UI
 */

/* Apply safe area insets to mobile navigation */
.mobile-nav,
.auth-nav {
    padding-top: max(var(--space-md), env(safe-area-inset-top));
    padding-left: max(var(--space-md), env(safe-area-inset-left));
    padding-right: max(var(--space-md), env(safe-area-inset-right));
}

/* Bottom spacing for sticky elements */
.form-actions.sticky,
.sticky-submit,
.mobile-submit-bar {
    padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
}

/* Full-height containers account for safe areas */
.auth-container,
.auth-wrapper {
    min-height: 100vh;
    min-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

/* iOS PWA mode - full safe area support */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/**
 * Viewport Height Fix
 * - Mobile browsers (especially Safari) have dynamic UI that changes vh
 * - Use custom --vh property set via JavaScript
 */

/* Will be set via JavaScript: document.documentElement.style.setProperty('--vh', `${vh}px`) */
.auth-container,
.auth-wrapper,
.full-height {
    min-height: 100vh;
    min-height: calc(var(--vh, 1vh) * 100);
}

/**
 * Mobile Keyboard Optimization
 * - Ensure form remains accessible when keyboard is open
 * - Prevent layout shifts
 * - Keep submit button visible
 */

/* Focus state with keyboard open */
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    /* Ensure focused input scrolls into view smoothly */
    scroll-margin-top: 100px;
    scroll-margin-bottom: 100px;
}

/* Sticky submit button on mobile when keyboard open */
@media (max-width: 767px) {
    .form-actions {
        position: sticky;
        bottom: 0;
        background: var(--color-white);
        padding: var(--space-md);
        padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 50;
        margin-left: calc(var(--space-md) * -1);
        margin-right: calc(var(--space-md) * -1);
        margin-bottom: calc(var(--space-md) * -1);
        width: calc(100% + var(--space-md) * 2);
    }
    
    .form-actions .btn {
        width: 100%;
    }
}

/* Input mode hints for better mobile keyboards */
/* Note: inputmode attributes should be added in HTML:
 * - inputmode="email" for email fields
 * - inputmode="tel" for phone fields
 * - inputmode="numeric" for number fields
 */

/**
 * Gesture Navigation Support
 * - Swipe-to-go-back gesture
 * - Implemented via JavaScript (see mobile-gestures.js)
 */

/* Visual feedback for swipe gesture */
.swipe-indicator {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: var(--color-primary);
    border-radius: 0 50% 50% 0;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    z-index: 1000;
}

.swipe-indicator.active {
    opacity: 0.7;
    transform: translateY(-50%) translateX(10px);
}

.swipe-indicator::after {
    content: '←';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: var(--color-white);
    font-size: 1.5rem;
}

/**
 * Performance Optimizations
 * - Hardware acceleration for animations
 * - Optimized scrolling
 */

/* Enable smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Hardware acceleration for transforms */
.btn,
.category-chip,
.role-card,
.conditional-field {
    transform: translateZ(0);
    will-change: transform;
}

/* Optimize scroll performance on mobile */
@media (max-width: 767px) {
    .form-panel,
    .info-panel {
        -webkit-overflow-scrolling: touch;
    }
}

/**
 * Additional Mobile UX Enhancements
 */

/* Tap highlight color (iOS) */
* {
    -webkit-tap-highlight-color: rgba(79, 70, 229, 0.1);
}

/* Disable text selection on buttons/interactive elements */
.btn,
.category-chip,
.custom-checkbox,
.nav-btn {
    -webkit-user-select: none;
    user-select: none;
}

/* Better focus visible for keyboard navigation */
@media (hover: none) {
    /* Touch devices */
    .btn:active,
    .category-chip:active {
        transform: scale(0.98);
    }
}

/* Landscape mode optimizations on mobile */
@media (max-width: 767px) and (orientation: landscape) {
    /* Reduce vertical spacing in landscape */
    .form-group {
        margin-bottom: var(--space-sm);
    }
    
    .main-title {
        font-size: 1.5rem;
        margin-bottom: var(--space-sm);
    }
    
    /* Make form scrollable while keeping submit visible */
    .form-panel {
        max-height: 100vh;
        overflow-y: auto;
    }
}

/* Tablet-specific optimizations */
@media (min-width: 768px) and (max-width: 1024px) {
    /* Better layout for iPads and similar tablets */
    .form-container {
        max-width: 600px;
        margin: 0 auto;
    }
    
    /* Two-column category grid on tablets */
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

@media (max-width: 767px) {
    .hide-mobile { display: none !important; }
}

@media (min-width: 768px) {
    .hide-desktop { display: none !important; }
}
