/* ============ CSS VARIABLES ============ */
:root {
    /* Light Theme Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    
    --border-color: #e2e8f0;
    --border-focus: #6366f1;
    
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --primary-bg: rgba(99, 102, 241, 0.1);
    
    --secondary: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

[data-theme="dark"] {
    /* Dark Theme Colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    
    --border-color: #334155;
    --border-focus: #818cf8;
    
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --primary-light: #a5b4fc;
    --primary-bg: rgba(129, 140, 248, 0.1);
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    
    --gradient-primary: linear-gradient(135deg, #4c1d95 0%, #5b21b6 100%);
    --gradient-secondary: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

/* ============ RESET & BASE ============ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ============ LOGIN WRAPPER ============ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 1rem;
}

/* ============ ANIMATED BACKGROUND ============ */
.animated-bg {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
    overflow: hidden;
    opacity: 0.6;
}

.gradient-sphere {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    animation: float 20s infinite ease-in-out;
}

.sphere-1 {
    width: 600px;
    height: 600px;
    background: var(--gradient-primary);
    top: -200px;
    left: -200px;
    animation-delay: 0s;
}

.sphere-2 {
    width: 500px;
    height: 500px;
    background: var(--gradient-secondary);
    bottom: -150px;
    right: -150px;
    animation-delay: 5s;
}

.sphere-3 {
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: 10s;
}

[data-theme="dark"] .gradient-sphere {
    opacity: 0.3;
}

@keyframes float {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(30px, -30px) scale(1.1);
    }
    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

/* ============ LOGIN CONTAINER ============ */
.login-container {
    width: 100%;
    max-width: 1200px;
    background: var(--bg-primary);
    border-radius: 24px;
    box-shadow: var(--shadow-xl);
    display: flex;
    overflow: hidden;
    position: relative;
    z-index: 1;
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
}

/* ============ LOGIN PANELS ============ */
.login-panel {
    flex: 1;
    padding: 3rem;
}

/* Left Panel - Branding */
.login-branding {
    background: var(--gradient-secondary);
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: white;
    position: relative;
    overflow: hidden;
}

.login-branding::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><defs><pattern id="grid" width="20" height="20" patternUnits="userSpaceOnUse"><path d="M 20 0 L 0 0 0 20" fill="none" stroke="white" stroke-width="0.5" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.1;
}

.branding-content {
    position: relative;
    z-index: 1;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.logo {
    width: 48px;
    height: 48px;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.brand-name {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-tagline h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.brand-tagline p {
    font-size: 1.125rem;
    opacity: 0.9;
    line-height: 1.6;
    margin-bottom: 2rem;
}

.testimonial {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    margin: 2rem 0;
}

.testimonial-content p {
    font-style: italic;
    margin-bottom: 1rem;
    font-size: 1.125rem;
}

.testimonial-author {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.testimonial-author img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.testimonial-author strong {
    display: block;
    font-size: 0.875rem;
}

.testimonial-author span {
    font-size: 0.75rem;
    opacity: 0.8;
}

.brand-features {
    display: flex;
    gap: 2rem;
    margin-top: 2rem;
}

.feature {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.feature svg {
    width: 18px;
    height: 18px;
}

/* Right Panel - Form */
.login-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

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

/* ============ THEME TOGGLE ============ */
.theme-toggle {
    position: absolute;
    top: 2rem;
    right: 2rem;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.theme-icon-light,
.theme-icon-dark {
    position: absolute;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

[data-theme="light"] .theme-icon-dark {
    opacity: 0;
    transform: rotate(180deg);
}

[data-theme="dark"] .theme-icon-light {
    opacity: 0;
    transform: rotate(-180deg);
}

/* ============ FORM STYLES ============ */
.form-header {
    margin-bottom: 2rem;
}

.form-header h3 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

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

/* Alert Container */
#alertContainer {
    margin-bottom: 1rem;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideDown 0.3s ease;
}

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

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

.alert-info {
    background: var(--primary-bg);
    border: 1px solid var(--primary-light);
    color: var(--primary);
}

.alert.fade-out {
    animation: fadeOut 0.3s ease;
}

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

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

/* OAuth Buttons */
.oauth-buttons {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.oauth-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.oauth-btn:hover {
    background: var(--bg-tertiary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.oauth-btn svg {
    width: 20px;
    height: 20px;
}

/* Divider */
.divider {
    position: relative;
    text-align: center;
    margin: 2rem 0;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-color);
}

.divider span {
    background: var(--bg-primary);
    padding: 0 1rem;
    color: var(--text-tertiary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: relative;
}

/* Form Groups */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.forgot-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
}

.forgot-link:hover {
    text-decoration: underline;
}

/* Input Wrapper */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input {
    width: 100%;
    padding: 0.75rem 1rem;
    padding-left: 2.75rem;
    padding-right: 2.75rem;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: 12px;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--border-focus);
    background: var(--bg-primary);
    box-shadow: 0 0 0 4px var(--primary-bg);
}

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

.input-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-tertiary);
    width: 18px;
    height: 18px;
}

/* Password Toggle */
.toggle-password {
    position: absolute;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.25rem;
    transition: color 0.3s ease;
}

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

.toggle-password .show-icon,
.toggle-password .hide-icon {
    width: 18px;
    height: 18px;
}

.toggle-password .hide-icon {
    display: none;
}

.toggle-password.showing .show-icon {
    display: none;
}

.toggle-password.showing .hide-icon {
    display: block;
}

/* Error Messages */
.error-message {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--error);
    min-height: 1rem;
}

/* Checkbox */
.form-options {
    margin-bottom: 1.5rem;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.checkbox-wrapper input[type="checkbox"] {
    position: absolute;
    opacity: 0;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    margin-right: 0.5rem;
    position: relative;
    transition: all 0.3s ease;
}

.checkbox-wrapper input[type="checkbox"]:checked + .checkbox-custom {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-wrapper input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 6px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Submit Button */
.submit-btn {
    width: 100%;
    padding: 0.875rem;
    background: var(--gradient-secondary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

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

.btn-text {
    display: inline-block;
    transition: opacity 0.3s ease;
}

.btn-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.submit-btn.loading .btn-text {
    opacity: 0;
}

.submit-btn.loading .btn-loader {
    opacity: 1;
}

.spinner {
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

.spinner circle {
    stroke-dasharray: 100;
    stroke-dashoffset: 75;
    transform-origin: center;
}

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

/* Form Footer */
.form-footer {
    margin-top: 2rem;
    text-align: center;
}

.security-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-tertiary);
    font-size: 0.75rem;
    margin-bottom: 1rem;
}

.security-note svg {
    width: 14px;
    height: 14px;
}

.footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.footer-links a {
    color: var(--text-tertiary);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: var(--primary);
}

.footer-links span {
    color: var(--text-tertiary);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 968px) {
    .login-container {
        flex-direction: column;
        max-width: 500px;
    }
    
    .login-branding {
        padding: 2rem;
        min-height: auto;
    }
    
    .brand-tagline h2 {
        font-size: 1.75rem;
    }
    
    .testimonial {
        display: none;
    }
    
    .brand-features {
        justify-content: center;
    }
    
    .login-form-panel {
        padding: 2rem;
    }
    
    .theme-toggle {
        top: 1rem;
        right: 1rem;
    }
}

@media (max-width: 640px) {
    .login-wrapper {
        padding: 0;
        align-items: stretch;
    }
    
    .login-container {
        border-radius: 0;
        min-height: 100vh;
        max-width: 100%;
    }
    
    .login-branding {
        display: none;
    }
    
    .login-form-panel {
        flex: 1;
        display: flex;
        align-items: center;
    }
    
    .oauth-buttons {
        flex-direction: column;
    }
    
    .gradient-sphere {
        filter: blur(100px);
    }
}