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

:root {
    --primary-color: #7E57C2;
    --secondary-color: #5C6BC0;
    --accent-color: #7986CB;
    --text-light: #f8f9fa;
    --text-dark: #212121;
    --success: #4CAF50;
    --error: #EF5350;
    --transition-speed: 0.4s;
}

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

body {
    font-family: 'Montserrat', sans-serif;
    background: linear-gradient(135deg, #1a1a2e, #16213e, #1a1a2e);
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('/static/images/chess.png') no-repeat center center;
    background-size: cover;
    opacity: 0.25;
    animation: subtle-zoom 30s infinite alternate;
}

/* Particles Container Styling */
.particles-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none; /* Allow clicks to pass through */
}

/* Enhanced Particles Container Styling */
.particles-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none; /* Allows interactions to pass through */
}

/* Particle hint text */
.particle-hint {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8rem;
    margin-top: 20px;
    opacity: 0;
    letter-spacing: 0.5px;
    animation: fadeIn 0.5s forwards 2s;
}

/* Allow mouse interactions with particles */
@media (min-width: 769px) {
    .particles-container {
        pointer-events: auto; /* Enable interaction on desktop */
    }
    
    /* Make sure container is still clickable */
    .container {
        position: relative; 
        z-index: 2;
    }
    
    /* Adjust opacity to make particles more visible */
    body::before {
        opacity: 0.2; /* Slightly dimmer background to make particles pop */
    }
}

/* Hide particles and hint on mobile devices */
@media (max-width: 768px) {
    .particles-container, 
    .particle-hint {
        display: none;
    }
}

.container {
    width: 100%;
    padding: 20px;
    position: relative;
    z-index: 2;
}

.login-box {
    background: linear-gradient(135deg, rgba(24, 24, 36, 0.95), rgba(36, 36, 54, 0.88));
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: clamp(35px, 6vh, 60px);
    border-radius: 16px;
    text-align: center;
    max-width: 450px;
    width: min(92%, 450px);
    margin: 0 auto;
    transform: translateY(0);
    animation: float 6s ease-in-out infinite;
    position: relative;
    overflow: hidden;
}

.login-box::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    transform: rotate(0deg);
    animation: rotateGradient 12s linear infinite;
    pointer-events: none;
}

.title {
    color: var(--text-light);
    font-family: 'Raleway', sans-serif;
    font-size: clamp(2.5rem, 9vw, 3.5rem);
    font-weight: 800;
    margin-bottom: clamp(15px, 3vh, 25px);
    letter-spacing: 4px;
    text-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
    background: linear-gradient(45deg, #e0e0e0, #ffffff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: shimmer 5s infinite;
}

.subtitle {
    color: var(--accent-color);
    margin-bottom: clamp(25px, 6vh, 45px);
    font-size: clamp(0.95rem, 4vw, 1.2rem);
    letter-spacing: 1px;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeUp 0.8s forwards 0.4s;
}

input {
    width: 100%;
    padding: clamp(14px, 3vh, 18px);
    margin-bottom: clamp(20px, 5vh, 35px);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-light);
    font-size: clamp(15px, 4vw, 17px);
    font-family: 'Montserrat', sans-serif;
    letter-spacing: 0.5px;
    transition: all var(--transition-speed) ease;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeUp 0.8s forwards 0.6s;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 15px rgba(126, 87, 194, 0.3);
}

input.invalid {
    border-color: var(--error);
    animation: shake 0.5s ease-in-out;
    box-shadow: 0 0 15px rgba(239, 83, 80, 0.4);
}

button {
    width: 100%;
    padding: clamp(14px, 3vh, 18px);
    border: none;
    border-radius: 12px;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    font-size: clamp(15px, 4vw, 17px);
    font-weight: 600;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    box-shadow: 0 5px 15px rgba(92, 107, 192, 0.4);
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeUp 0.8s forwards 0.8s;
}

button:hover {
    background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(92, 107, 192, 0.5);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(92, 107, 192, 0.4);
}

button::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1) translate(-50%, -50%);
    transform-origin: 50% 50%;
}

button:focus::after {
    animation: ripple 1s ease-out;
}

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

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-10px); }
    40% { transform: translateX(10px); }
    60% { transform: translateX(-7px); }
    80% { transform: translateX(7px); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes subtle-zoom {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

@keyframes shimmer {
    0% { background-position: -500px 0; }
    100% { background-position: 500px 0; }
}

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

@keyframes ripple {
    0% {
        width: 0;
        height: 0;
        opacity: 0.5;
    }
    100% {
        width: 500px;
        height: 500px;
        opacity: 0;
    }
}

/* Responsive design */
@media (max-width: 480px) {
    body {
        min-height: 100vh;
    }

    .container {
        padding: 15px;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .login-box {
        height: auto;
        padding: 30px 25px;
        animation: fadeIn 1s ease-in;
        margin: auto; /* Center horizontally */
    }

    .title {
        margin-bottom: 15px;
    }

    .subtitle {
        margin-bottom: 30px;
    }

    input, button {
        height: 55px;
        margin-bottom: 20px;
        border-radius: 10px;
    }
}

/* Hide particles on mobile devices */
@media (max-width: 768px) {
    .particles-container {
        display: none;
    }
}

/* Enhanced mobile experience */
@media (max-width: 768px) {
    /* Restore the original login box design for mobile */
    .login-box {
        background: linear-gradient(135deg, rgba(24, 24, 36, 0.95), rgba(36, 36, 54, 0.88));
        box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
        border: 1px solid rgba(255, 255, 255, 0.1);
        /* Keep original padding structure but adjust for mobile screen */
        padding: clamp(30px, 5vh, 45px);
        width: min(95%, 450px);
    }
    
    /* Keep original title styles from desktop */
    .title {
        text-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
        /* Restore shimmer animation */
        animation: shimmer 5s infinite;
    }
    
    /* Restore original button styling for mobile */
    button {
        background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
        box-shadow: 0 5px 15px rgba(92, 107, 192, 0.4);
    }
    
    button:hover, button:active {
        background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
        transform: translateY(-3px);
        box-shadow: 0 8px 25px rgba(92, 107, 192, 0.5);
    }
    
    /* Enable particles but prevent interaction */
    .particles-container {
        display: block;
        pointer-events: none;
    }
    
    /* Hide hint since it's not interactive on mobile */
    .particle-hint {
        display: none;
    }
    
    /* Keep original background opacity */
    body::before {
        opacity: 0.25;
    }
    
    /* Remove this override to keep original color scheme */
    /*
    :root {
        --primary-color: #505050;
        --secondary-color: #404040;
        --accent-color: #606060;
    }
    */
}

/* Mobile-specific animations - remove or simplify */
@keyframes mobile-zoom {
    0% { transform: scale(1); }
    100% { transform: scale(1.05); }
}

/* Remove unused animations */
@keyframes pulse-glow {
    0% { opacity: 0.2; }
    100% { opacity: 0.3; }
}

@keyframes mobile-pulse {
    0% { opacity: 0.95; }
    100% { opacity: 1; }
}

@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    100% { background-position: 0% 50%; }
}

/* Specific styles for small mobile devices */
@media (max-width: 480px) {
    body {
        min-height: 100vh;
    }

    .container {
        padding: 15px;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
    
    /* Compact login box for smaller screens */
    .login-box {
        height: auto;
        padding: 30px 20px;
        margin: auto; /* Center horizontally */
    }

    .title {
        margin-bottom: 12px;
        font-size: clamp(2.2rem, 8vw, 3rem);
    }

    .subtitle {
        margin-bottom: 22px;
    }

    input, button {
        height: 50px;
        margin-bottom: 16px;
        border-radius: 10px;
    }
}

/* ...keep existing landscape media query... */

@media (orientation: landscape) and (max-height: 600px) {
    .login-box {
        padding: 25px;
    }

    .title {
        font-size: clamp(1.8rem, 6vw, 2.5rem);
        margin-bottom: 10px;
    }

    .subtitle {
        margin-bottom: 20px;
    }

    input, button {
        height: 45px;
        margin-bottom: 15px;
        padding: 10px;
    }
}

/* Device-specific particle behaviors */
@media (min-width: 769px) {
    /* Desktop - enable interaction */
    .particles-container {
        pointer-events: auto;
        display: block !important; /* Force display on desktop */
    }
    
    /* Make sure container is still clickable */
    .container {
        position: relative; 
        z-index: 2;
    }
    
    /* Adjust opacity to make particles more visible */
    body::before {
        opacity: 0.2; /* Slightly dimmer background to make particles pop */
    }
    
    /* Show hint on desktop only */
    .particle-hint {
        display: block;
    }
}

@media (max-width: 768px) {
    /* Mobile - no interaction, but still visible */
    .particles-container {
        display: block;
        pointer-events: none;
    }
    
    /* Hide hint since it's not interactive on mobile */
    .particle-hint {
        display: none;
    }
    
    /* ...existing mobile styles... */
}
