/* Base Modal Structure */
.login-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.75);
    z-index: 9999;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}

.login-modal.show {
    display: flex;
}

.login-modal-content {
    position: relative;
    background: var(--bg-secondary);
    margin: 0;
    padding: 3rem;
    width: 90%;
    max-width: 420px;
    border-radius: 16px;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    animation: modalFadeIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Header Styles */
.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
    position: relative;
}

.login-header::after {
    content: '';
    position: absolute;
    bottom: -1rem;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--episode-container), var(--visited));
    border-radius: 2px;
}

.login-header h2 {
    color: var(--text-primary);
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 400;
    line-height: 1.4;
}

/* Close Button */
.login-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
}

.login-close:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

/* Form Styles */
.login-form,
.signup-form {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.form-group {
    padding-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative;
}

.form-group label {
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.form-group input {
    padding: 1rem 1.25rem;
    border: 2px solid transparent;
    border-radius: 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Montserrat', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    outline: none;
}

.form-group input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.form-group input:focus {
    border-color: var(--episode-container);
    box-shadow: 
        0 4px 16px rgba(0, 0, 0, 0.15),
        0 0 0 3px rgba(232, 90, 90, 0.1);
    transform: translateY(-1px);
}

.form-group input:valid:not(:placeholder-shown) {
    border-color: rgba(76, 175, 80, 0.5);
}

/* Remember Me & Forgot Password */
.remember-forgot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    margin: 0.5rem 0;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s ease;
}

.remember-me:hover {
    color: var(--text-primary);
}

.remember-me input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--episode-container);
    cursor: pointer;
}

.forgot-password {
    color: var(--episode-container);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    padding: 0.25rem 0;
}

.forgot-password:hover {
    color: var(--visited);
    text-decoration: underline;
}

/* Submit Button */
.login-button {
    width: 100%;
    height: 52px;
    background: linear-gradient(135deg, var(--episode-container), var(--visited));
    color: var(--text-primary);
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    margin: 1rem 0 0.5rem 0;
    box-shadow: 0 4px 16px rgba(232, 90, 90, 0.2);
    letter-spacing: 0.02em;
}

.login-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(232, 90, 90, 0.3);
    filter: brightness(1.05);
}

.login-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(232, 90, 90, 0.2);
}

#register-button[disabled] {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    filter: grayscale(0.3) !important;
}

#register-button[disabled]:hover {
    transform: none !important;
    box-shadow: 0 4px 16px rgba(232, 90, 90, 0.2) !important;
    filter: grayscale(0.3) !important;
}

/* Divider */
.login-divider {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.login-divider::before,
.login-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--button-color), transparent);
}

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

.oauth-button {
    flex: 1;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0 1rem;
    border: 2px solid var(--button-color);
    border-radius: 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.oauth-button:hover {
    background: var(--button-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    border-color: rgba(255, 255, 255, 0.1);
}

.oauth-button svg {
    width: 20px;
    height: 20px;
    transition: transform 0.2s ease;
}

.oauth-button:hover svg {
    transform: scale(1.1);
}

/* Switch Forms Link */
.signup-link {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
}

.signup-link a {
    color: var(--episode-container);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    margin-left: 0.25rem;
    transition: all 0.2s ease;
    padding: 0.25rem 0;
    border-radius: 4px;
}

.signup-link a:hover {
    color: var(--visited);
    text-decoration: underline;
    text-underline-offset: 3px;
}



/* Form Switch Animation */
.form-switch-active {
    display: flex;
    opacity: 1;
    animation: formSlideIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.form-switch-inactive {
    display: none;
    opacity: 0;
}

/* Animations */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .login-modal-content {
        width: 85%;
        padding: 2.5rem;
    }
    
    .login-header h2 {
        font-size: 1.75rem;
    }
}

@media (max-width: 480px) {
    .login-modal {
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
    }
    
    .login-modal-content {
        padding: 2rem 1.5rem;
        width: 95%;
        max-width: none;
        max-height: 95vh;
        border-radius: 16px;
        box-shadow: 
            0 8px 32px rgba(0, 0, 0, 0.3),
            0 0 0 1px rgba(255, 255, 255, 0.05);
    }

    .login-header {
        margin-bottom: 2rem;
    }

    .login-header h2 {
        font-size: 1.5rem;
        font-weight: 600;
    }

    .login-header p {
        font-size: 0.9rem;
    }

    .login-header::after {
        width: 40px;
        height: 2px;
    }

    .login-form,
    .signup-form {
        gap: 1.5rem;
    }

    .form-group {
        gap: 0.5rem;
        padding-top: 0.25rem;
    }

    .form-group input {
        padding: 0.9rem 1rem;
        font-size: 0.95rem;
        border-radius: 10px;
    }

    .remember-forgot {
        font-size: 0.9rem;
        gap: 0.75rem;
    }

    .remember-me {
        gap: 0.5rem;
    }

    .login-button {
        height: 48px;
        font-size: 0.95rem;
        border-radius: 10px;
        margin: 0.75rem 0 0.5rem 0;
    }

    .oauth-buttons {
        gap: 0.75rem;
        margin-bottom: 1.25rem;
        flex-direction: column;
    }

    .oauth-button {
        padding: 0 1rem;
        height: 48px;
        font-size: 0.9rem;
        width: 100%;
        border-radius: 10px;
    }

    .signup-link {
        margin-top: 1.25rem;
        padding-top: 1.25rem;
        font-size: 0.9rem;
    }

    .login-close {
        top: 1rem;
        right: 1rem;
        width: 28px;
        height: 28px;
        font-size: 1.25rem;
    }
}

@media (max-width: 375px) {
    .login-modal-content {
        padding: 1.75rem 1.25rem;
        border-radius: 12px;
    }

    .login-header h2 {
        font-size: 1.35rem;
    }

    .form-group input {
        padding: 0.8rem 0.9rem;
        font-size: 0.9rem;
    }

    .login-button {
        height: 46px;
        font-size: 0.9rem;
    }

    .oauth-button {
        height: 46px;
        font-size: 0.85rem;
    }
}

@media (max-width: 320px) {
    .login-modal-content {
        width: 98%;
        padding: 1.5rem 1rem;
        margin: 0;
    }

    .login-header h2 {
        font-size: 1.25rem;
    }

    .form-group input {
        padding: 0.75rem 0.85rem;
    }
}

/* Success Message */
.success-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    padding: 2rem;
    text-align: center;
    animation: successFadeIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.success-icon {
    width: 80px;
    height: 80px;
    animation: checkmarkBounce 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
    filter: drop-shadow(0 4px 12px rgba(76, 175, 80, 0.3));
}

.success-icon svg {
    width: 100%;
    height: 100%;
}

.success-text {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    animation: textSlideUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) 0.2s both;
}

.success-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 400;
    animation: textSlideUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) 0.4s both;
    transition: opacity 0.3s ease;
}

.success-subtitle.countdown {
    animation: countdownPulse 1s ease-in-out infinite;
}

@keyframes countdownPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Success Animations */
@keyframes successFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes checkmarkBounce {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    70% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

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

/* ❄️ Winter Theme Overrides */
.winter-theme .login-button {
    background: linear-gradient(135deg, var(--episode-container), var(--visited));
    box-shadow: 0 4px 16px rgba(91, 143, 185, 0.2);
}

.winter-theme .login-button:hover {
    box-shadow: 0 6px 20px rgba(91, 143, 185, 0.3);
}

.winter-theme .login-button:active {
    box-shadow: 0 2px 8px rgba(91, 143, 185, 0.2);
}

.winter-theme #register-button[disabled] {
    box-shadow: 0 4px 16px rgba(91, 143, 185, 0.2);
}

.winter-theme #register-button[disabled]:hover {
    box-shadow: 0 4px 16px rgba(91, 143, 185, 0.2);
}

.winter-theme .form-group input:focus {
    border-color: var(--episode-container);
    box-shadow: 
        0 4px 16px rgba(0, 0, 0, 0.15),
        0 0 0 3px rgba(91, 143, 185, 0.1);
}

.winter-theme .remember-me input[type="checkbox"] {
    accent-color: var(--episode-container);
}

.winter-theme .forgot-password {
    color: var(--episode-container);
}

.winter-theme .forgot-password:hover {
    color: var(--visited);
}