/**
 * WebApp Authentication Framework - Modern Dark Theme
 * Ultra-modern, sleek, professional design with advanced animations
 * 
 * @version 2.0.0
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* CSS Variables for easy customization */
.webapp-auth-preload-active #webapp-auth-preload,
#webapp-auth-preload {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0a0a0f; /* fallback to dark bg */
    z-index: 9998; /* slightly below auth container */
}

.webapp-auth-container.theme-modern-dark {
    /* Primary Colors */
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
    --secondary-gradient: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
    --accent-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --danger-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    
    /* Background Colors */
    --dark-bg: #0a0a0f;
    --card-bg: rgba(15, 15, 23, 0.95);
    --glass-bg: rgba(255, 255, 255, 0.02);
    --overlay-bg: rgba(0, 0, 0, 0.9);
    
    /* Border Colors */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --border-focus: rgba(99, 102, 241, 0.5);
    
    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    --text-accent: #6366f1;
    
    /* Status Colors */
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --info-color: #3b82f6;
    
    /* Input Colors */
    --input-bg: rgba(255, 255, 255, 0.03);
    --input-border: rgba(255, 255, 255, 0.1);
    --input-focus: rgba(99, 102, 241, 0.3);
    
    /* Shadow Colors */
    --shadow-primary: rgba(99, 102, 241, 0.25);
    --shadow-dark: rgba(0, 0, 0, 0.5);
    --shadow-glow: rgba(99, 102, 241, 0.15);
    
    /* Animation Variables */
    --animation-speed: 0.3s;
    --animation-curve: cubic-bezier(0.4, 0, 0.2, 1);
    --bounce-curve: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Reset and base styles */
.webapp-auth-container.theme-modern-dark * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.webapp-auth-container.theme-modern-dark {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--dark-bg);
    color: var(--text-primary);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    overflow: hidden;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Animated background with particles */
.webapp-auth-container.theme-modern-dark::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 25% 25%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(217, 70, 239, 0.06) 0%, transparent 50%),
        linear-gradient(135deg, rgba(6, 182, 212, 0.02) 0%, rgba(59, 130, 246, 0.02) 100%);
    animation: authBackgroundFloat 25s ease-in-out infinite;
    z-index: -2;
}

.webapp-auth-container.theme-modern-dark::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(99, 102, 241, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(217, 70, 239, 0.02) 0%, transparent 50%);
    animation: authParticleFloat 30s ease-in-out infinite reverse;
    z-index: -1;
}

@keyframes authBackgroundFloat {
    0%, 100% { 
        transform: translate(0, 0) rotate(0deg) scale(1);
        opacity: 1;
    }
    25% { 
        transform: translate(-10px, -10px) rotate(90deg) scale(1.05);
        opacity: 0.8;
    }
    50% { 
        transform: translate(10px, -5px) rotate(180deg) scale(0.95);
        opacity: 1;
    }
    75% { 
        transform: translate(-5px, 10px) rotate(270deg) scale(1.02);
        opacity: 0.9;
    }
}

@keyframes authParticleFloat {
    0%, 100% { 
        transform: translate(0, 0) scale(1);
        opacity: 0.5;
    }
    33% { 
        transform: translate(15px, -20px) scale(1.1);
        opacity: 0.7;
    }
    66% { 
        transform: translate(-10px, 15px) scale(0.9);
        opacity: 0.6;
    }
}

/* Auth Screen */
.webapp-auth-container.theme-modern-dark .auth-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100vw;
    padding: 2rem;
    overflow-y: auto;
    opacity: 1;
    transition: opacity var(--animation-speed) var(--animation-curve);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.webapp-auth-container.theme-modern-dark .auth-container {
    text-align: center;
    max-width: 420px;
    width: 100%;
    animation: authSlideInUp 1s var(--bounce-curve);
    position: relative;
}

@keyframes authSlideInUp {
    from {
        opacity: 0;
        transform: translateY(60px) scale(0.95);
        filter: blur(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}







/* Form */
.webapp-auth-container.theme-modern-dark .auth-form {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 28px;
    padding: 2.5rem 2rem;
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    box-shadow: 
        0 40px 80px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 0 50px var(--shadow-glow);
    position: relative;
    overflow: hidden;
    transition: all var(--animation-speed) var(--animation-curve);
}

.webapp-auth-container.theme-modern-dark .auth-form:hover {
    border-color: var(--border-hover);
    box-shadow: 
        0 50px 100px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        0 0 60px var(--shadow-glow);
    transform: translateY(-2px);
}

.webapp-auth-container.theme-modern-dark .auth-form::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-gradient);
    opacity: 0.8;
}

.webapp-auth-container.theme-modern-dark .auth-form::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent, rgba(99, 102, 241, 0.03), transparent);
    animation: authFormRotate 20s linear infinite;
    z-index: -1;
}

@keyframes authFormRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Form Groups */
.webapp-auth-container.theme-modern-dark .form-group {
    margin-bottom: 2rem;
    text-align: left;
    position: relative;
}

.webapp-auth-container.theme-modern-dark .form-group:last-of-type {
    margin-bottom: 2.5rem;
}

.webapp-auth-container.theme-modern-dark .form-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    transition: color var(--animation-speed) var(--animation-curve);
}

/* Input Container */
.webapp-auth-container.theme-modern-dark .input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.webapp-auth-container.theme-modern-dark .form-input {
    width: 100%;
    padding: 1.25rem 3.5rem 1.25rem 1.25rem;
    border: 2px solid var(--input-border);
    border-radius: 20px;
    font-size: 1rem;
    outline: none;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--text-primary);
    transition: all var(--animation-speed) var(--animation-curve);
    font-weight: 500;
    letter-spacing: 0.01em;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.webapp-auth-container.theme-modern-dark .form-input::placeholder {
    color: var(--text-muted);
    opacity: 0.8;
    transition: opacity var(--animation-speed) var(--animation-curve);
}

.webapp-auth-container.theme-modern-dark .form-input:focus {
    border-color: var(--text-accent);
    box-shadow: 
        0 0 0 4px var(--input-focus),
        0 8px 25px rgba(99, 102, 241, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    background: var(--glass-bg);
    transform: translateY(-1px);
}

.webapp-auth-container.theme-modern-dark .form-input:focus::placeholder {
    opacity: 0.5;
    transform: translateX(4px);
}

.webapp-auth-container.theme-modern-dark .form-input.valid {
    border-color: var(--success-color);
    box-shadow: 
        0 0 0 4px rgba(16, 185, 129, 0.15),
        0 8px 25px rgba(16, 185, 129, 0.1);
}

.webapp-auth-container.theme-modern-dark .form-input.invalid {
    border-color: var(--error-color);
    box-shadow: 
        0 0 0 4px rgba(239, 68, 68, 0.15),
        0 8px 25px rgba(239, 68, 68, 0.1);
    animation: authInputShake 0.5s ease-in-out;
}

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

/* Input Icon */
.webapp-auth-container.theme-modern-dark .input-icon {
    position: absolute;
    right: 1.25rem;
    color: var(--text-muted);
    pointer-events: none;
    transition: all var(--animation-speed) var(--animation-curve);
    z-index: 1;
}

.webapp-auth-container.theme-modern-dark .form-input:focus + .input-icon {
    color: var(--text-accent);
    transform: scale(1.1);
}

.webapp-auth-container.theme-modern-dark .form-input.valid + .input-icon {
    color: var(--success-color);
}

.webapp-auth-container.theme-modern-dark .form-input.invalid + .input-icon {
    color: var(--error-color);
}

/* Input Help */
.webapp-auth-container.theme-modern-dark .input-help {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
    opacity: 0.8;
    transition: all var(--animation-speed) var(--animation-curve);
    font-weight: 400;
    letter-spacing: 0.01em;
}

.webapp-auth-container.theme-modern-dark .input-help.error {
    color: var(--error-color);
    opacity: 1;
    font-weight: 500;
}

/* Submit Button */
.webapp-auth-container.theme-modern-dark .auth-button {
    width: 100%;
    background: var(--primary-gradient);
    border: none;
    border-radius: 20px;
    padding: 1.25rem 2rem;
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all var(--animation-speed) var(--animation-curve);
    box-shadow: 
        0 12px 30px var(--shadow-primary),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 64px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-size: 0.95rem;
}

.webapp-auth-container.theme-modern-dark .auth-button::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.6s ease;
}

.webapp-auth-container.theme-modern-dark .auth-button:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 
        0 20px 40px var(--shadow-primary),
        0 0 0 1px rgba(255, 255, 255, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.webapp-auth-container.theme-modern-dark .auth-button:hover:not(:disabled)::before {
    left: 100%;
}

.webapp-auth-container.theme-modern-dark .auth-button:active:not(:disabled) {
    transform: translateY(-1px) scale(1.01);
}

.webapp-auth-container.theme-modern-dark .auth-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.webapp-auth-container.theme-modern-dark .auth-button.loading {
    pointer-events: none;
}

/* Button Content */
.webapp-auth-container.theme-modern-dark .button-text {
    transition: opacity var(--animation-speed) var(--animation-curve);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.webapp-auth-container.theme-modern-dark .button-loader {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
}

.webapp-auth-container.theme-modern-dark .spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: authSpin 1s linear infinite;
}

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

/* Modal */
.webapp-auth-container.theme-modern-dark .auth-modal {
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--overlay-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s var(--animation-curve);
}

.webapp-auth-container.theme-modern-dark .auth-modal.show {
    opacity: 1;
    visibility: visible;
}

.webapp-auth-container.theme-modern-dark .modal-content {
    background: var(--card-bg);
    padding: 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 28px;
    width: 100%;
    max-width: 460px;
    text-align: center;
    box-shadow: 
        0 50px 100px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 0 60px var(--shadow-glow);
    position: relative;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    transform: translateY(30px) scale(0.95);
    transition: transform 0.4s var(--bounce-curve);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
}

.webapp-auth-container.theme-modern-dark .auth-modal.show .modal-content {
    transform: translateY(0) scale(1);
}

/* Modal Header */
.webapp-auth-container.theme-modern-dark .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.webapp-auth-container.theme-modern-dark .modal-title {
    color: var(--text-primary);
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}

.webapp-auth-container.theme-modern-dark .modal-close {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--animation-speed) var(--animation-curve);
    width: 44px;
    height: 44px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.webapp-auth-container.theme-modern-dark .modal-close:hover {
    background: var(--border-color);
    color: var(--text-primary);
    transform: scale(1.1);
    border-color: var(--border-hover);
}

/* Modal Body */
.webapp-auth-container.theme-modern-dark .modal-body {
    margin-bottom: 2.5rem;
}

.webapp-auth-container.theme-modern-dark .modal-icon {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    animation: authModalIconPulse 2s ease-in-out infinite;
}

.webapp-auth-container.theme-modern-dark .modal-icon.error {
    color: var(--error-color);
}

.webapp-auth-container.theme-modern-dark .modal-icon.success {
    color: var(--success-color);
}

.webapp-auth-container.theme-modern-dark .modal-icon.warning {
    color: var(--warning-color);
}

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

.webapp-auth-container.theme-modern-dark .modal-message {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 1.1rem;
    font-weight: 400;
    letter-spacing: 0.01em;
}

/* Modal Footer */
.webapp-auth-container.theme-modern-dark .modal-footer {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.webapp-auth-container.theme-modern-dark .modal-button {
    border: none;
    border-radius: 16px;
    padding: 1rem 2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--animation-speed) var(--animation-curve);
    min-width: 120px;
    font-size: 1rem;
    letter-spacing: 0.01em;
    position: relative;
    overflow: hidden;
}

.webapp-auth-container.theme-modern-dark .modal-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.6s ease;
}

.webapp-auth-container.theme-modern-dark .modal-button:hover::before {
    left: 100%;
}

.webapp-auth-container.theme-modern-dark .modal-button.primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 8px 20px var(--shadow-primary);
}

.webapp-auth-container.theme-modern-dark .modal-button.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px var(--shadow-primary);
}

.webapp-auth-container.theme-modern-dark .modal-button.secondary {
    background: var(--glass-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.webapp-auth-container.theme-modern-dark .modal-button.secondary:hover {
    background: var(--border-color);
    transform: translateY(-1px);
    border-color: var(--border-hover);
}

/* Focus states for accessibility */
.webapp-auth-container.theme-modern-dark .form-input:focus,
.webapp-auth-container.theme-modern-dark .auth-button:focus,
.webapp-auth-container.theme-modern-dark .modal-button:focus,
.webapp-auth-container.theme-modern-dark .modal-close:focus {
    outline: none;
}

.webapp-auth-container.theme-modern-dark .modal-button:focus {
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.3);
}

/* Loading states */
.webapp-auth-container.theme-modern-dark .form-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Responsive Design */
@media (max-width: 768px) {
    .webapp-auth-container.theme-modern-dark .auth-screen {
        padding: 1.5rem;
    }
    
    .webapp-auth-container.theme-modern-dark .auth-container {
        max-width: 100%;
    }
    
    .webapp-auth-container.theme-modern-dark .auth-form {
        padding: 2rem 1.5rem;
        border-radius: 24px;
    }
    
    .webapp-auth-container.theme-modern-dark .form-input {
        padding: 1rem 3rem 1rem 1rem;
        font-size: 0.95rem;
    }
    
    .webapp-auth-container.theme-modern-dark .auth-button {
        padding: 1rem 1.5rem;
        min-height: 56px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .webapp-auth-container.theme-modern-dark .auth-screen {
        padding: 1rem;
    }
    
    .webapp-auth-container.theme-modern-dark .auth-form {
        padding: 1.5rem;
        border-radius: 20px;
    }
    
    .webapp-auth-container.theme-modern-dark .form-input {
        padding: 0.875rem 2.5rem 0.875rem 0.875rem;
        font-size: 0.9rem;
        border-radius: 16px;
    }
    
    .webapp-auth-container.theme-modern-dark .auth-button {
        padding: 0.875rem 1.25rem;
        min-height: 52px;
        border-radius: 16px;
    }
    
    .webapp-auth-container.theme-modern-dark .modal-content {
        padding: 2rem 1.5rem;
        margin: 1rem;
        border-radius: 24px;
    }
    
    .webapp-auth-container.theme-modern-dark .modal-footer {
        flex-direction: column;
    }
    
    .webapp-auth-container.theme-modern-dark .modal-button {
        width: 100%;
    }
    

}

/* Ultra-wide screens */
@media (min-width: 1920px) {
    .webapp-auth-container.theme-modern-dark .auth-container {
        max-width: 500px;
    }
    
    .webapp-auth-container.theme-modern-dark .auth-form {
        padding: 3rem 2.5rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .webapp-auth-container.theme-modern-dark {
        --border-color: rgba(255, 255, 255, 0.3);
        --text-secondary: rgba(255, 255, 255, 0.9);
        --input-border: rgba(255, 255, 255, 0.4);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .webapp-auth-container.theme-modern-dark *,
    .webapp-auth-container.theme-modern-dark *::before,
    .webapp-auth-container.theme-modern-dark *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
    .webapp-auth-container.theme-modern-dark {
        --dark-bg: #000000;
        --card-bg: rgba(10, 10, 15, 0.98);
    }
}

/* Print styles */
@media print {
    .webapp-auth-container.theme-modern-dark {
        display: none !important;
    }
}

/* Custom scrollbar */
.webapp-auth-container.theme-modern-dark ::-webkit-scrollbar {
    width: 8px;
}

.webapp-auth-container.theme-modern-dark ::-webkit-scrollbar-track {
    background: var(--glass-bg);
    border-radius: 4px;
}

.webapp-auth-container.theme-modern-dark ::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
    transition: background var(--animation-speed) var(--animation-curve);
}

.webapp-auth-container.theme-modern-dark ::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* Selection styles */
.webapp-auth-container.theme-modern-dark ::selection {
    background: rgba(99, 102, 241, 0.3);
    color: var(--text-primary);
}

.webapp-auth-container.theme-modern-dark ::-moz-selection {
    background: rgba(99, 102, 241, 0.3);
    color: var(--text-primary);
}