/* CSS-only modal implementation with JavaScript fallback */
.css-modal {
    /* Hidden by default */
    opacity: 0;
    visibility: hidden;
    
    /* Fixed positioning to cover the screen */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1050;
    
    /* Layout */
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* Ensure it's over everything else */
    background-color: rgba(0, 0, 0, 0.5);
    
    /* Smooth transition */
    transition: opacity 0.3s ease;
    
    /* Add overflow handling for the modal container */
    overflow-y: auto;
    padding: 1.5rem;
}

/* Pure CSS-only modal opening using URL fragment (:target) */
.css-modal:target {
    opacity: 1;
    visibility: visible;
}

.css-modal:target .css-modal-content {
    transform: translateY(0);
}

/* Show modal when targeted with URL fragment */
.css-modal.open {
    opacity: 1;
    visibility: visible;
}

.css-modal-content {
    /* Styling */
    background-color: #fff;
    border-radius: 0.3rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    width: 50%;
    max-width: 90%;
    max-height: 90vh; /* Limit height to 90% of viewport height */
    margin: auto; /* Center in viewport */
    
    /* Animation */
    transform: translateY(-50px);
    transition: transform 0.3s ease;
    
    /* Layout */
    display: flex;
    flex-direction: column;
}


.css-modal.open .css-modal-content {
    transform: translateY(0);
} 

.css-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0; /* Prevent header from shrinking */
    /* background-color: var(--primary); */
}

.css-modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.5;
}

.css-modal-close {
    color: #000;
    opacity: 0.5;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    padding: 0;
    background-color: transparent;
    border: 0;
}

.css-modal-close:hover {
    opacity: 0.75;
    text-decoration: none;
}

.css-modal-body {
    padding: 1rem;
    flex: 1 1 auto;
    overflow-y: auto; /* Enable scrolling in the body */
    max-height: calc(90vh - 130px); /* Account for header and footer heights */
}

.css-modal-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    padding: 0.75rem;
    border-top: 1px solid #dee2e6;
    gap: 0.5rem;
    flex-shrink: 0; /* Prevent footer from shrinking */
}

/* Special CSS classes for different sized modals */
.css-modal-lg .css-modal-content {
    width: 800px;
    max-width: 95%;
}

.css-modal-sm .css-modal-content {
    width: 300px;
}

/* Prevent scrolling of body when modal is open */
body.modal-open {
    overflow: hidden;
}

/* Fallback for browsers that don't support :has() */
@supports not (selector(:has(.css-modal:target))) {
    .css-modal:target + .css-modal-no-scroll {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
}
