:root {
    --primary: #EF4444;
    --secondary: #1D49C3;
    --tertiary: #262262;
    --quaternary: #00A4EF;
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-tertiary: #1a1a1a;
    
    --text-primary: #2C2E32;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    --glass-bg: #ffffff;
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-hover: rgba(255, 255, 255, 0.06);
    
    --shadow-sm: 0 1px 2px 0 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);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body, html {
    height: 100vh;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: linear-gradient(120deg, #fbe4e6 0%, #e6eafd 100%);
    color: var(--text-primary);
    overflow: auto; /* allow scroll if needed */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

@media (max-height: 500px) {
    .login-card {
        padding: 8px !important;
        max-height: 100vh;
    }
}

/* Animated Background */
.background-layer {
    background: linear-gradient(120deg, #fbe4e6 0%, #e6eafd 100%);
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: -10;
}

/* Main Container - Responsive */
.app-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: clamp(10px, 3vh, 20px);
    position: relative;
    z-index: 1;
    overflow-y: auto;
    max-height: 100vh;
}

/* Login Card - Responsive Sizing */
.login-card {
    background: var(--glass-bg);
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    padding: 2.5rem 2rem;
    width: 520px;
    margin: auto;
}


@media (max-width: 600px), (max-height: 600px) {
    .app-container {
        padding: 6px !important;
    }
    .login-card {
        padding: 8px !important;
        max-width: 600px !important;
        max-height: 98vh !important;
    }
}

/* Logo Section - Responsive */
.logo-section {
    text-align: center;
    margin-bottom: clamp(16px, 4vh, 40px);
    animation: logoReveal 0.8s ease-out 0.3s both;
    flex-shrink: 0;
}

@keyframes logoReveal {
    0% {
        opacity: 0;
        transform: translateY(-30px) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.logo-container {
    position: relative;
    display: inline-block;
    margin-bottom: clamp(12px, 2.5vh, 24px);
}

.logo-wrapper {
    position: relative;
    width: clamp(64px, 12vw, 88px);
    height: clamp(64px, 12vw, 88px);
    margin: 0 auto;
}

.logo-image {
    width: 250px;
    height: 70px;
    border-radius: var(--radius-lg);
    transition: var(--transition);
    position: relative;
    z-index: 2;
}

.welcome-title {
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--tertiary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    background-size: 100%;
    background-position: 0 0;
    display: inline-block;
    width: auto;
}

.welcome-subtitle {
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.ai-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: var(--secondary);
    padding: clamp(6px, 1.5vh, 8px) clamp(12px, 3vw, 16px);
    border-radius: var(--radius-full);
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    font-weight: 600;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.ai-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.2), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.ai-badge i {
    margin-right: 8px;
    animation: iconPulse 1.5s ease-in-out infinite;
}

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

/* Form Styles - Responsive */
.login-form {
    animation: formSlideUp 0.8s ease-out 0.5s both;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: clamp(16px, 3vh, 24px);
}

@keyframes formSlideUp {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-group {
    position: relative;
}

.form-label {
    display: block;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 8px;
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    letter-spacing: 0.025em;
}

.input-wrapper {
    position: relative;
}

.input-wrapper .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    font-size: clamp(0.875rem, 2.5vw, 1rem);
    color: var(--text-muted);
}

.input-wrapper .form-input {
    padding-left: 44px !important;
}

.input-wrapper:focus-within .input-icon {
    color: var(--secondary);
}

.form-input {
    width: 100%;
    padding: clamp(12px, 3vh, 16px) 20px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    color: var(--text-primary) !important;
    font-size: clamp(0.875rem, 2.5vw, 1rem);
    font-weight: 400;
    transition: var(--transition);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.form-input:focus {
    outline: none;
    border-color: var(--secondary);
    background: var(--glass-hover);
    box-shadow: 
        0 0 0 3px rgba(99, 102, 241, 0.1),
        var(--shadow-lg);
}

.form-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.password-toggle {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    padding: 4px;
    border-radius: var(--radius-sm);
}

.password-toggle:hover {
    color: var(--text-primary);
    background: var(--glass-hover);
}

/* Enhanced Buttons - Responsive */
.btn {
    width: 100%;
    padding: clamp(12px, 3vh, 16px) 24px;
    border: none;
    border-radius: var(--radius-lg);
    font-size: clamp(0.875rem, 2.5vw, 1rem);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.logo-wrapper:hover .logo-image {
    transform: perspective(600px) rotateX(10deg) rotateY(10deg) scale(1.05);
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.3), 0 0 60px rgba(6, 182, 212, 0.2);
    transition: transform 0.4s ease, box-shadow 0.4s ease;
}

/* Gradient border for Primary button */
.btn-primary{
    position: relative;
    z-index: 1;
    background: 
        linear-gradient(135deg, #fff 0 0) padding-box, /* Button fill */
        linear-gradient(90deg, var(--primary), var(--secondary), var(--tertiary)) border-box; /* Border gradient */
    border: 2px solid transparent;
    transition: background 0.3s, color 0.3s;
    box-shadow: none;
}

.btn-primary::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;
}

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

/* On hover: fill the button with the gradient */
.btn-primary:hover,
.btn-primary:focus {
    background:
        linear-gradient(90deg, var(--primary), var(--secondary), var(--tertiary)) padding-box,
        linear-gradient(90deg, var(--primary), var(--secondary), var(--tertiary)) border-box;
    color: #fff;
    border: 2px solid transparent; /* Ensures no border is visible */
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-microsoft::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;
}

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

.btn-microsoft {
    position: relative;
    z-index: 1;
    background: 
        linear-gradient(135deg, #fff 0 0) padding-box, /* Button fill */
        linear-gradient(90deg, var(--tertiary), var(--quaternary)) border-box; /* Border gradient */
    border: 2px solid transparent;
    transition: background 0.3s, color 0.3s;
    box-shadow: none;
}

/* On hover: fill the button with the gradient */
.btn-microsoft:hover,
.btn-microsoft:focus {
    background:
        linear-gradient(90deg, var(--tertiary), var(--quaternary)) padding-box,
        linear-gradient(90deg, var(--tertiary), var(--quaternary)) border-box;
    color: #fff;
    border: 2px solid transparent; /* Ensures no border is visible */
}

/* Divider - Responsive */
.divider {
    display: flex;
    align-items: center;
    margin: clamp(16px, 4vh, 32px) 0;
    color: var(--text-muted);
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    font-weight: 500;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--glass-border), transparent);
}

.divider span {
    padding: 0 20px;
    background: var(--glass-bg);
    border-radius: var(--radius-full);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
}

/* Loading State */
.btn-loading {
    pointer-events: none;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    color: white;
}

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

/* Flash Messages */
.flash-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--error);
    padding: clamp(12px, 3vh, 16px) 20px;
    border-radius: var(--radius-lg);
    margin-bottom: clamp(16px, 3vh, 24px);
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    font-weight: 500;
    display: flex;
    align-items: center;
    animation: flashSlide 0.5s ease-out;
    backdrop-filter: blur(10px);
}

@keyframes flashSlide {
    0% {
        opacity: 0;
        transform: translateX(-20px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.flash-message i {
    margin-right: 12px;
}

.flash-close {
    background: none;
    border: none;
    color: currentColor;
    margin-left: auto;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.flash-close:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Theme Toggle - Responsive */
.theme-toggle {
    display: none !important; /* Hide theme toggle*/
    position: fixed;
    top: clamp(16px, 3vh, 24px);
    right: clamp(16px, 3vw, 24px);
    width: clamp(40px, 8vw, 48px);
    height: clamp(40px, 8vw, 48px);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(10px);
    z-index: 100;
}

.theme-toggle:hover {
    background: var(--glass-hover);
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

.theme-toggle i {
    color: var(--text-primary);
    font-size: clamp(1rem, 2.5vw, 1.125rem);
    transition: var(--transition);
}

/* Responsive Breakpoints */
@media (max-height: 700px) {
    .login-card {
        padding: clamp(16px, 2vh, 24px);
        max-height: calc(100vh - 10px);
    }
    
    .logo-section {
        margin-bottom: clamp(12px, 2vh, 20px);
    }
    
    .login-form {
        gap: clamp(12px, 2vh, 16px);
    }
    
    .divider {
        margin: clamp(12px, 2vh, 20px) 0;
    }
}

@media (max-width: 600px) {
    .app-container {
        padding: 10px;
    }
    
    .login-card {
        max-width: 600px;
        padding: clamp(16px, 4vw, 24px);
    }
}

/* Very small screens */
@media (max-height: 600px) {
    .login-card {
        padding: 16px;
        gap: 8px;
    }
    
    .logo-section {
        margin-bottom: 12px;
    }
    
    .login-form {
        gap: 12px;
    }
    
    .btn {
        padding: 10px 20px;
    }
}

/* Landscape orientation */
@media (orientation: landscape) and (max-height: 500px) {
    .app-container {
        align-items: flex-start;
        padding-top: 10px;
    }
    
    .login-card {
        max-height: calc(100vh - 20px);
        overflow-y: auto;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --glass-bg: rgba(255, 255, 255, 0.1);
        --glass-border: rgba(255, 255, 255, 0.3);
        --text-secondary: #e5e5e5;
    }
}

/* Scrollbar styling for webkit browsers */
.login-card::-webkit-scrollbar {
    width: 4px;
}

.login-card::-webkit-scrollbar-track {
    background: transparent;
}

.login-card::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 2px;
}

.login-card::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Animate divider and Microsoft button */
.divider {
    opacity: 0;
    transform: translateY(30px);
    animation: formSlideUp 0.8s ease-out 0.7s both;
}

.btn-microsoft {
    opacity: 0;
    transform: translateY(30px);
    animation: formSlideUp 0.8s ease-out 0.9s both;
}

/* Hide WebKit (Chrome/Safari) built-in password reveal icon */
input[type="password"]::-webkit-credentials-auto-fill-button,
input[type="password"]::-webkit-input-decoration,
input[type="password"]::-webkit-textfield-decoration-container,
input[type="password"]::-webkit-clear-button,
input[type="password"]::-webkit-reveal-button {
    display: none !important;
}

input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
    display: none !important;
}
