/* Mobile Login Page - Optimized CSS */
/* Mobile-first responsive design with GPU-accelerated animations */

:root {
    --orange-color: #f26c23;
    --blue-color: #0077c8;
    --green-color: #1ca760;
    --teal-blue-color: #00a2d1;
    --purple-color: #6030a3;
    
    --primary-color: var(--blue-color);
    --secondary-color: var(--orange-color);
    --accent-color: var(--green-color);
    --dark-color: #212529;
    --light-color: #f8f9fa;
    --success-color: #28a745;
    --gradient-start: var(--blue-color);
    --gradient-end: var(--purple-color);
    
    /* Mobile optimizations */
    --touch-target-min: 44px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base styles - Mobile first */
body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    color: var(--dark-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.login-container {
    max-width: 450px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem;
    background: white;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0, 119, 200, 0.12);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0, 119, 200, 0.08);
}

/* Container wrapper - desktop default */
.container {
    padding: 0;
    width: 100%;
    max-width: 100%;
    /* Add top padding for mobile apps (status bar, notch, safe area) */
    padding-top: env(safe-area-inset-top, 1rem);
    padding-top: max(env(safe-area-inset-top), 1rem);
}

/* Mobile: Add extra top padding for better spacing in apps */
@media (max-width: 576px) {
    .container {
        padding-top: max(env(safe-area-inset-top), 2rem);
        padding-bottom: 1rem;
    }
}

/* Desktop: center the login container */
@media (min-width: 577px) {
    .container {
        display: block;
        padding-top: 2rem;
        padding-bottom: 2rem;
    }
}

.login-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end));
    transform: translateZ(0);
}

/* Logo section */
.logo {
    text-align: center;
    margin-bottom: 1.5rem;
    animation: fadeInDown 0.6s ease-out;
    will-change: transform, opacity;
}

.logo h1 {
    color: var(--primary-color);
    font-weight: 800;
    margin-bottom: 0.5rem;
    font-size: 2rem;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 4px rgba(0, 119, 200, 0.1);
}

.logo p {
    color: var(--dark-color);
    font-size: 0.95rem;
    opacity: 0.75;
    line-height: 1.5;
}

/* Form title */
.form-title {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-weight: 700;
    text-align: center;
    font-size: 1.4rem;
    animation: fadeIn 0.6s ease-out;
}

/* Buttons - Enhanced for mobile */
.btn-primary,
.btn-secondary {
    border: none;
    padding: 0.875rem 1.5rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    border-radius: 50px;
    font-size: 0.95rem;
    color: white;
    text-transform: uppercase;
    min-height: var(--touch-target-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    will-change: transform;
    transform: translateZ(0);
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    box-shadow: 0 4px 12px rgba(0, 119, 200, 0.25);
}

.btn-primary:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 2px 8px rgba(0, 119, 200, 0.2);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary-color), #e55a1a);
    box-shadow: 0 4px 12px rgba(242, 108, 35, 0.25);
}

.btn-secondary:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 2px 8px rgba(242, 108, 35, 0.2);
}

.btn-primary:disabled,
.btn-secondary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Form containers - Hide OTP, MPIN, and user details forms initially */
.otp-container,
.user-details-container {
    display: none !important;
}

/* Override for visible forms */
.otp-container.form-visible,
.user-details-container.form-visible {
    display: flex !important;
    flex-direction: column;
}

/* Phone form should be visible initially */
#phone-form {
    display: block;
}

/* Ensure forms don't have default form styling */
#phone-form,
#otp-form,
#mpin-form,
#user-details-form {
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
}

/* Input styles - Mobile optimized */
.input-group {
    border-bottom: 2px solid #e0e0e0;
    transition: border-color var(--transition-fast);
    display: flex;
    align-items: stretch;
    width: 100%;
    margin-bottom: 0;
}

.input-group:focus-within {
    border-bottom-color: var(--primary-color);
}

.input-group-prepend {
    display: flex;
    margin-right: 0;
}

.input-group-text {
    background-color: transparent;
    border: none;
    border-right: none;
    font-weight: 600;
    color: var(--primary-color);
    min-height: var(--touch-target-min);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 0.75rem;
    font-size: 1rem;
    white-space: nowrap;
}

.input-group-text i {
    margin-right: 0.5rem;
}

.form-control {
    border: none;
    border-left: none;
    padding: 0.875rem 0.75rem;
    font-size: 1rem;
    border-radius: 0;
    transition: border-color var(--transition-fast);
    background: transparent;
    min-height: var(--touch-target-min);
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    width: 100%;
}

.form-control:focus {
    box-shadow: none;
    outline: none;
    border: none;
}

.form-control::placeholder {
    color: #adb5bd;
    opacity: 0.7;
}

/* Input validation states */
.form-control.is-invalid {
    border-bottom-color: #dc3545 !important;
}

.form-control.is-valid {
    border-bottom-color: var(--success-color) !important;
}

/* Real-time phone validation feedback */
#phone:valid {
    border-bottom-color: var(--success-color);
}

#phone:invalid:not(:placeholder-shown) {
    border-bottom-color: #dc3545;
}

.input-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--dark-color);
    font-size: 0.9rem;
}

/* OTP Input */
.otp-input {
    letter-spacing: 1.2rem;
    padding-left: 1.2rem;
    font-size: 1.5rem;
    text-align: center;
    border: none;
    border-bottom: 2px solid #e0e0e0;
    border-radius: 0;
    font-weight: 600;
    color: var(--primary-color);
    transition: border-color var(--transition-fast);
    background: transparent;
    min-height: var(--touch-target-min);
    width: 100%;
}

.otp-input:focus {
    border-bottom-color: var(--primary-color);
    box-shadow: none;
    outline: none;
}

/* Resend link */
.resend-link {
    color: var(--secondary-color);
    cursor: pointer;
    font-weight: 600;
    transition: color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    min-height: var(--touch-target-min);
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    margin: -0.25rem -0.5rem;
}

.resend-link:active {
    color: #e55a1a;
    transform: scale(0.95);
}

.resend-link.disabled {
    color: #6c757d;
    cursor: not-allowed;
    pointer-events: none;
}

.countdown {
    font-weight: 600;
    color: var(--primary-color);
}

/* Progress steps */
.progress-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    position: relative;
    padding: 0 0.5rem;
}

.progress-steps::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 0.5rem;
    right: 0.5rem;
    height: 3px;
    background: #e9ecef;
    z-index: 1;
    border-radius: 2px;
}

.progress-bar {
    position: absolute;
    top: 15px;
    left: 0.5rem;
    height: 3px;
    background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end));
    z-index: 2;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 2px;
    transform: translateZ(0);
}

.step {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #adb5bd;
    position: relative;
    z-index: 3;
    transition: all var(--transition-smooth);
    font-size: 0.875rem;
    transform: translateZ(0);
}

.step.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 0 0 4px rgba(0, 119, 200, 0.15);
    transform: scale(1.1);
}

.step.completed {
    background: var(--secondary-color);
    color: white;
    box-shadow: 0 0 0 4px rgba(242, 108, 35, 0.15);
}

/* Illustration */
.illustration {
    text-align: center;
    margin-bottom: 1.25rem;
    animation: fadeIn 0.6s ease-out;
}

.illustration-icon {
    font-size: 4rem;
    color: var(--primary-color);
    display: inline-block;
    transition: transform var(--transition-fast);
}

.illustration svg {
    max-width: 100px;
    height: auto;
    display: inline-block;
}

/* Gender selector */
.gender-selector {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.gender-option {
    flex: 1;
    text-align: center;
    cursor: pointer;
    padding: 1rem;
    border-radius: 12px;
    border: 2px solid #e9ecef;
    transition: all var(--transition-smooth);
    min-height: var(--touch-target-min);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transform: translateZ(0);
}

.gender-option:active {
    transform: scale(0.95);
}

.gender-option.selected {
    border-color: var(--secondary-color);
    background-color: rgba(242, 108, 35, 0.08);
    transform: scale(1.02);
}

.gender-option i {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
    transition: color var(--transition-fast);
}

.gender-option.selected i {
    color: var(--secondary-color);
}

/* Profile upload */
.profile-upload {
    text-align: center;
    margin-bottom: 1.5rem;
}

.profile-pic {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-color);
    background-color: #e9ecef;
    display: inline-block;
    position: relative;
    cursor: pointer;
    transition: transform var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.profile-pic:active {
    transform: scale(0.95);
}

.upload-icon {
    position: absolute;
    bottom: 0;
    right: 0;
    background: var(--primary-color);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    box-shadow: 0 2px 8px rgba(0, 119, 200, 0.3);
}

/* Footer */
.footer {
    text-align: center;
    margin-top: auto;
    padding-top: 1.5rem;
    color: var(--dark-color);
    font-size: 0.85rem;
    opacity: 0.7;
    padding-left: 1rem;
    padding-right: 1rem;
    padding-bottom: 1rem;
}

/* Animations - GPU accelerated */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Tablet and up */
@media (min-width: 768px) {
    .login-container {
        padding: 2.5rem;
        border-radius: 20px;
    }
    
    .logo h1 {
        font-size: 2.4rem;
    }
    
    .logo p {
        font-size: 1.1rem;
    }
    
    .form-title {
        font-size: 1.6rem;
    }
    
    .btn-primary,
    .btn-secondary {
        padding: 0.9rem 1.5rem;
    }
    
    .illustration svg {
        max-width: 120px;
    }
    
    .profile-pic {
        width: 120px;
        height: 120px;
    }
}

/* Mobile specific optimizations */
@media (max-width: 576px) {
    body {
        background: white;
        align-items: flex-start;
        padding: 0;
        margin: 0;
        /* Add safe area support for mobile apps */
        padding-top: env(safe-area-inset-top, 0);
    }
    
    .container {
        padding: 0;
        padding-top: max(env(safe-area-inset-top), 1.5rem);
        margin: 0;
        width: 100%;
        max-width: 100%;
        background: white;
        min-height: 100vh;
    }
    
    .login-container {
        padding: 1.5rem 1.25rem 0;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        border: none;
        width: 100%;
        max-width: 100%;
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    
    /* Remove top border gradient for mobile */
    .login-container::before {
        display: none;
    }
    
    .logo h1 {
        font-size: 1.75rem;
    }
    
    .logo p {
        font-size: 0.875rem;
    }
    
    .form-title {
        font-size: 1.25rem;
        margin-bottom: 1.25rem;
    }
    
    .btn-primary,
    .btn-secondary {
        padding: 0.75rem 1.25rem;
        font-size: 0.875rem;
    }
    
    .otp-input {
        font-size: 1.25rem;
        letter-spacing: 0.8rem;
        padding-left: 0.8rem;
    }
    
    .step {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
    
    /* Hide progress steps on mobile */
    .progress-steps,
    .progress-steps::before,
    .progress-bar,
    .step {
        display: none !important;
    }
    
    .illustration-icon {
        font-size: 3rem;
    }
    
    .illustration svg {
        max-width: 80px;
    }
    
    .gender-option {
        padding: 0.875rem;
    }
    
    .gender-option i {
        font-size: 1.5rem;
    }
    
    /* Mobile input improvements */
    .input-group-text {
        padding: 0.75rem 0.5rem;
        font-size: 0.95rem;
    }
    
    .form-control {
        padding: 0.75rem 0.5rem;
        font-size: 1rem;
    }
    
    .input-label {
        font-size: 0.875rem;
        margin-bottom: 0.4rem;
    }
    
    .footer {
        margin-top: 0;
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
        background: white;
        width: 100%;
    }
    
    /* Ensure content flows properly */
    .login-container > * {
        flex-shrink: 0;
    }
    
    /* Make forms take available space and layout properly */
    #phone-form {
        display: flex;
        flex-direction: column;
        flex: 1;
    }
    
    #otp-form,
    #mpin-form,
    #user-details-form {
        display: flex;
        flex-direction: column;
        flex: 1;
    }
}

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

/* Loading states */
.btn-loading {
    position: relative;
    color: transparent !important;
    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: white;
    animation: spin 0.6s linear infinite;
}

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

