/**
 * Professional Login Page CSS
 * assets/css/login.css
 * Version: 3.2 - Fixed Icon Container Alignment (Complete Fix)
 */

/* Login Page Layout */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    background-attachment: fixed;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    position: relative;
    overflow: hidden;
}

/* Animated background elements */
.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 20% 50%, rgba(59, 130, 246, 0.05) 0%, transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(16, 185, 129, 0.03) 0%, transparent 50%),
                radial-gradient(circle at 40% 80%, rgba(99, 102, 241, 0.04) 0%, transparent 50%);
    animation: backgroundFloat 20s ease-in-out infinite;
    pointer-events: none;
}

@keyframes backgroundFloat {
    0%, 100% { transform: translate(-2%, -2%) rotate(0deg); }
    25% { transform: translate(-1%, -3%) rotate(1deg); }
    50% { transform: translate(-3%, -1%) rotate(-1deg); }
    75% { transform: translate(-1%, -2%) rotate(0.5deg); }
}

/* Main Login Container */
.login-container {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 24px;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 480px;
    width: 100%;
    padding: 0;
    overflow: hidden;
    position: relative;
    animation: containerSlideIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes containerSlideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Login Header */
.login-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white;
    padding: 3rem 2.5rem 2.5rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.login-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(59, 130, 246, 0.1) 50%, transparent 70%);
    animation: headerShimmer 3s ease-in-out infinite;
}

@keyframes headerShimmer {
    0%, 100% { transform: translateX(-100%); }
    50% { transform: translateX(100%); }
}

.login-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    box-shadow: 
        0 10px 25px rgba(59, 130, 246, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
    z-index: 1;
    animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.login-icon i {
    font-size: 2rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.login-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

.login-subtitle {
    font-size: 1rem;
    opacity: 0.9;
    margin: 0;
    font-weight: 400;
    position: relative;
    z-index: 1;
}

/* Login Body */
.login-body {
    padding: 2.5rem;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
}

/* Form Styling */
.login-form {
    margin: 0;
}

.form-group:not(:last-child) {
    margin-bottom: 1.75rem;
}

.form-label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    letter-spacing: 0.025em;
}

.required {
    color: #ef4444;
    margin-left: 2px;
}

/* Enhanced Input Groups - COMPLETELY FIXED ALIGNMENT */
.input-group {
    position: relative;
    display: flex;
    align-items: stretch;
    border-radius: 12px;
    background: white;
    border: 2px solid #e2e8f0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    height: 56px; /* Fixed height for consistency */
}

.input-group:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.input-group:focus-within {
    border-color: #3b82f6;
    box-shadow: 
        0 0 0 4px rgba(59, 130, 246, 0.1),
        0 8px 25px rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
}

.input-group-icon {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-right: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    min-width: 56px;
    max-width: 56px;
    flex-shrink: 0;
    transition: all 0.3s ease;
    /* Remove any potential padding/margin issues */
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    /* Ensure no gaps */
    height: 100%;
    position: relative;
}

.input-group:focus-within .input-group-icon {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-color: #3b82f6;
}

.input-group-icon i {
    font-size: 1.125rem;
    color: #64748b;
    transition: all 0.3s ease;
    /* Center the icon perfectly */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.input-group:focus-within .input-group-icon i {
    color: #3b82f6;
    transform: scale(1.1);
}

.form-control {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 1.25rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--input-text);
    flex: 1;
    height: 100%;
    /* Remove any potential margin/padding issues */
    margin: 0;
    box-sizing: border-box;
    /* Ensure proper alignment */
    display: flex;
    align-items: center;
    outline: none;
    border-radius: 0;
}

.form-control::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.form-control:focus {
    outline: none;
    color: var(--input-text);
}

/* Field validation states */
.form-control.is-valid {
    color: #059669;
}

.form-control.is-invalid {
    color: #dc2626;
}

.input-group:has(.form-control.is-valid) {
    border-color: #10b981;
    background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
}

.input-group:has(.form-control.is-invalid) {
    border-color: #ef4444;
    background: linear-gradient(135deg, #fef2f2 0%, #fff1f2 100%);
}

/* Field error messages */
.field-error {
    display: none;
    color: #dc2626;
    font-size: 0.8rem;
    margin-top: 0.5rem;
    font-weight: 500;
}

.form-control.is-invalid + .field-error,
.form-control.is-invalid ~ .field-error {
    display: block;
}

.form-text {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 0.5rem;
    font-weight: 400;
}

/* Premium Login Button */
.btn-login {
    width: 100%;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 8px 25px rgba(59, 130, 246, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.btn-login::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn-login:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    transform: translateY(-2px);
    box-shadow: 
        0 12px 35px rgba(59, 130, 246, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-login:hover::before {
    left: 100%;
}

.btn-login:active {
    transform: translateY(-1px);
}

.btn-login:disabled,
.btn-login.btn-disabled {
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-login:disabled:hover,
.btn-login.btn-disabled:hover {
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
    transform: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-login.loading {
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
    cursor: wait;
    position: relative;
}

.btn-login.loading .btn-text {
    opacity: 0.7;
}

.btn-login.loading::after {
    content: '';
    position: absolute;
    right: 1rem;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.loading-overlay.show {
    display: flex;
}

.loading-content {
    background: white;
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    text-align: center;
    max-width: 320px;
    animation: slideInScale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideInScale {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.loading-content .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

.loading-content div:last-child {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

/* Enhanced Alerts */
.alert {
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    border: none;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: alertSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.alert i {
    font-size: 1.125rem;
    flex-shrink: 0;
}

.alert-success {
    background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
    border-left: 4px solid #10b981;
    color: #065f46;
}

.alert-success i {
    color: #10b981;
}

.alert-danger {
    background: linear-gradient(135deg, #fef2f2 0%, #fff1f2 100%);
    border-left: 4px solid #ef4444;
    color: #991b1b;
}

.alert-danger i {
    color: #ef4444;
}

.alert-warning {
    background: linear-gradient(135deg, #fffbeb 0%, #fefce8 100%);
    border-left: 4px solid #f59e0b;
    color: #92400e;
}

.alert-warning i {
    color: #f59e0b;
}

/* Dark Theme Support */
[data-theme="dark"] .login-page {
    background: linear-gradient(135deg, #000000 0%, #0f172a 50%, #1e293b 100%);
}

[data-theme="dark"] .login-container {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(51, 65, 85, 0.5);
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(51, 65, 85, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .login-body {
    background: rgba(30, 41, 59, 0.8);
}

[data-theme="dark"] .input-group {
    background: #334155;
    border-color: #475569;
}

[data-theme="dark"] .input-group:hover {
    border-color: #64748b;
}

[data-theme="dark"] .input-group:focus-within {
    border-color: #3b82f6;
    background: #334155;
}

[data-theme="dark"] .input-group-icon {
    background: linear-gradient(135deg, #475569 0%, #334155 100%);
    border-color: #475569;
}

[data-theme="dark"] .input-group:focus-within .input-group-icon {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
}

[data-theme="dark"] .input-group-icon i {
    color: #94a3b8;
}

[data-theme="dark"] .input-group:focus-within .input-group-icon i {
    color: white;
}

[data-theme="dark"] .turnstile-container {
    background: linear-gradient(135deg, #334155 0%, #475569 100%);
    border-color: #475569;
}

[data-theme="dark"] .loading-content {
    background: #1e293b;
    color: #f1f5f9;
    border: 1px solid #334155;
}

[data-theme="dark"] .loading-content .spinner {
    border-color: #475569;
    border-top-color: #3b82f6;
}

/* Responsive Design */
@media (max-width: 640px) {
    .login-page {
        padding: 1rem;
    }
    
    .login-container {
        border-radius: 16px;
        margin: 0;
    }
    
    .login-header {
        padding: 2rem 1.5rem 1.5rem;
    }
    
    .login-body {
        padding: 1.5rem;
    }
    
    .login-icon {
        width: 64px;
        height: 64px;
        margin-bottom: 1rem;
    }
    
    .login-icon i {
        font-size: 1.5rem;
    }
    
    .login-title {
        font-size: 1.5rem;
    }
    
    .login-subtitle {
        font-size: 0.9rem;
    }
    
    .input-group {
        height: 48px; /* Adjusted for mobile */
    }
    
    .input-group-icon {
        width: 48px;
        min-width: 48px;
        max-width: 48px;
    }
    
    .form-control {
        padding: 0 1rem;
        font-size: 0.9rem;
    }
    
    .btn-login {
        padding: 0.875rem 1.25rem;
    }
}

@media (max-width: 480px) {
    .login-container {
        max-width: none;
        margin: 0.5rem;
        border-radius: 12px;
    }
    
    .form-group:not(:last-child) {
        margin-bottom: 1.25rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .login-container {
        border: 2px solid #000;
    }
    
    .input-group {
        border-width: 2px;
    }
    
    .btn-login {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .login-container,
    .login-icon,
    .input-group,
    .btn-login,
    .alert,
    .loading-content {
        animation: none;
        transition: none;
    }
    
    .login-page::before {
        animation: none;
    }
    
    .login-header::before {
        animation: none;
    }
    
    .btn-login::before {
        transition: none;
    }
}