/* ==========================================================================
   Modal Component - Theme Aware
   ========================================================================== */

/* Modal overlay - covers entire screen */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
}

.modal-overlay.hidden {
    display: none;
}

/* Backdrop */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgb(0 0 0 / 0.4);
    backdrop-filter: blur(4px);
}

.dark .modal-backdrop {
    background-color: rgb(0 0 0 / 0.6);
}

/* Modal content panel - Light theme */
.modal-content {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 100%;
    max-width: 42rem;
    height: 85vh;
    height: 85dvh;
    background: linear-gradient(to bottom, #ffffff, #f9fafb);
    border-top-left-radius: 1.5rem;
    border-top-right-radius: 1.5rem;
    border: 1px solid rgb(229 231 235 / 0.5);
    border-bottom: none;
    box-shadow: 0 -10px 40px -10px rgb(0 0 0 / 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modal-slide-up 0.3s cubic-bezier(0.32, 0.72, 0, 1) forwards;
}

/* Dark theme modal content */
.dark .modal-content {
    background: linear-gradient(to bottom, rgb(17 24 39), rgb(0 0 0));
    border: 1px solid rgb(31 41 55 / 0.5);
    border-bottom: none;
    box-shadow: 0 -10px 40px -10px rgb(0 0 0 / 0.5);
}

/* Slide up animation (enter) */
@keyframes modal-slide-up {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* Slide down animation (exit) */
@keyframes modal-slide-down {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(100%);
    }
}

/* Closing state */
.modal-overlay.is-closing .modal-content {
    animation: modal-slide-down 0.25s cubic-bezier(0.32, 0.72, 0, 1) forwards;
}

.modal-overlay.is-closing .modal-backdrop {
    opacity: 0;
    transition: opacity 0.25s ease-out;
}

/* ==========================================================================
   Desktop Styles (lg: 1024px+)
   ========================================================================== */

@media (min-width: 1024px) {
    .modal-content {
        position: fixed;
        top: 50%;
        bottom: auto;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%);
        width: 90%;
        max-width: 48rem;
        height: auto;
        max-height: 80vh;
        max-height: 80dvh;
        border-radius: 1.5rem;
        border: 1px solid rgb(229 231 235 / 0.5);
        box-shadow:
            0 25px 50px -12px rgb(0 0 0 / 0.15),
            0 0 0 1px rgb(0 0 0 / 0.03);
        animation: modal-scale-in 0.25s cubic-bezier(0.32, 0.72, 0, 1) forwards;
    }

    .dark .modal-content {
        border: 1px solid rgb(31 41 55 / 0.5);
        box-shadow:
            0 25px 50px -12px rgb(0 0 0 / 0.5),
            0 0 0 1px rgb(255 255 255 / 0.05);
    }

    @keyframes modal-scale-in {
        from {
            transform: translate(-50%, -50%) scale(0.95);
            opacity: 0;
        }
        to {
            transform: translate(-50%, -50%) scale(1);
            opacity: 1;
        }
    }

    @keyframes modal-scale-out {
        from {
            transform: translate(-50%, -50%) scale(1);
            opacity: 1;
        }
        to {
            transform: translate(-50%, -50%) scale(0.95);
            opacity: 0;
        }
    }

    .modal-overlay.is-closing .modal-content {
        animation: modal-scale-out 0.2s cubic-bezier(0.32, 0.72, 0, 1) forwards;
    }
}

/* ==========================================================================
   Extra Large Desktop (xl: 1280px+)
   ========================================================================== */

@media (min-width: 1280px) {
    .modal-content {
        max-width: 56rem;
    }
}
