/* ============================================
   AUTHENTICATION MODAL STYLES WITH BACKGROUND IMAGE
   ============================================ */

/* Modal Overlay */
.auth-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 1rem;
}

[data-theme="dark"] .auth-modal-overlay {
    background: rgba(0, 0, 0, 0.85);
}

.auth-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Modal Container - WITH BACKGROUND IMAGE */
.auth-modal-container {
    position: relative;
    width: 100%;
    max-width: 1100px;
    height: 90vh;
    max-height: 950px;
    background: var(--primary-bg);
    border-radius: 24px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: modalSlideIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border: 2px solid var(--border-color);

    /* BACKGROUND IMAGE STYLES */
    background-image: url('../images/background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* Add a semi-transparent overlay on top of background image */
.auth-modal-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    /* Light mode overlay */
    z-index: 0;
    pointer-events: none;
}

/* Dark mode background overlay */
[data-theme="dark"] .auth-modal-container {
    background: var(--primary-bg);
    border-color: rgba(167, 139, 250, 0.3);
    box-shadow: 0 25px 80px rgba(107, 70, 193, 0.7);

    /* Same background image for dark mode */
    background-image: url('../images/background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}



@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(50px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Close Button */
.auth-modal-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 45px;
    height: 45px;
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid #ef4444;
    border-radius: 50%;
    color: #ef4444;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10001;
    backdrop-filter: blur(10px);
}

.auth-modal-close:hover {
    background: #ef4444;
    color: white;
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.auth-modal-close:active {
    transform: rotate(90deg) scale(0.95);
}

/* Iframe Styles - Must have relative position to be above background */
.auth-iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 24px;
    overflow-y: auto;
    position: relative;
    z-index: 1;
    /* Above the background overlay */
    background: transparent;
    /* Make iframe background transparent */
}

/* Loading State */
.auth-modal-container.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    border: 4px solid rgba(167, 139, 250, 0.2);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 10002;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

.auth-modal-container.loading .auth-iframe {
    opacity: 0;
}

/* ============================================
   ALTERNATIVE STYLE OPTIONS
   ============================================ */

/* Option 1: Pattern overlay on background */
.auth-modal-container.pattern-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="40" fill="rgba(107,70,193,0.03)"/></svg>');
    background-size: 100px 100px;
    z-index: 0;
    pointer-events: none;
}

/* Option 2: Gradient overlay on background */
.auth-modal-container.gradient-overlay::before {
    background: linear-gradient(135deg,
            rgba(255, 255, 255, 0.95) 0%,
            rgba(248, 249, 250, 0.95) 100%);
}

[data-theme="dark"] .auth-modal-container.gradient-overlay::before {
    background: linear-gradient(135deg,
            rgba(26, 15, 46, 0.95) 0%,
            rgba(15, 8, 32, 0.95) 100%);
}

/* Option 3: Blur effect on background image */
.auth-modal-container.blur-background {
    background-attachment: scroll;
}

.auth-modal-container.blur-background::before {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 1024px) {
    .auth-modal-container {
        max-width: 95%;
        height: 85vh;
        max-height: 700px;
        background-attachment: scroll;
        /* Better performance on mobile */
    }
}

@media (max-width: 768px) {
    .auth-modal-overlay {
        padding: 0.5rem;
    }

    .auth-modal-container {
        max-width: 100%;
        height: 95vh;
        max-height: none;
        border-radius: 20px;
        background-size: cover;
    }

    .auth-modal-close {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
        top: 1rem;
        right: 1rem;
    }

    .auth-iframe {
        border-radius: 20px;
    }
}

@media (max-width: 480px) {
    .auth-modal-overlay {
        padding: 0;
    }

    .auth-modal-container {
        border-radius: 16px;
        height: 100vh;
    }

    .auth-modal-close {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
        top: 0.75rem;
        right: 0.75rem;
    }

    .auth-iframe {
        border-radius: 16px;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus visible for keyboard navigation */
.auth-modal-close:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 3px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

    .auth-modal-overlay,
    .auth-modal-container,
    .auth-modal-close {
        animation: none !important;
        transition: opacity 0.1s ease !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .auth-modal-close {
        border-width: 3px;
    }

    .auth-modal-container {
        border-width: 3px;
    }
}

/* ============================================
   SMOOTH TRANSITIONS
   ============================================ */

.auth-modal-overlay.closing {
    animation: fadeOut 0.3s ease forwards;
}

.auth-modal-overlay.closing .auth-modal-container {
    animation: modalSlideOut 0.3s ease forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
    }
}

@keyframes modalSlideOut {
    to {
        opacity: 0;
        transform: scale(0.9) translateY(30px);
    }
}

/* ============================================
   IFRAME LOADING INDICATOR
   ============================================ */

.auth-iframe-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--secondary-bg);
    overflow: hidden;
    z-index: 10001;
}

.auth-iframe-loader::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end));
    animation: loading 1.5s ease-in-out infinite;
}

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

    100% {
        left: 100%;
    }
}

/* ============================================
   MODAL NOTIFICATION STYLES
   ============================================ */

.auth-modal-notification {
    position: fixed;
    top: 100px;
    right: 20px;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(107, 70, 193, 0.4);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    z-index: 10003;
    animation: slideInRight 0.3s ease;
}

.auth-modal-notification.success {
    background: linear-gradient(135deg, #10b981, #059669);
}

.auth-modal-notification.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.auth-modal-notification.info {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   BACKDROP BLUR EFFECT
   ============================================ */

.auth-modal-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(107, 70, 193, 0.1), transparent 70%);
    pointer-events: none;
}

[data-theme="dark"] .auth-modal-overlay::before {
    background: radial-gradient(circle at center, rgba(167, 139, 250, 0.15), transparent 70%);
}