.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0); /* Start with transparent */
    backdrop-filter: blur(4px);
    animation: modalBackgroundFadeIn 0.3s ease-out forwards; /* Add animation */
}

.modal.closing {
    animation: modalBackgroundFadeOut 0.3s ease-out forwards;
}

.modal-content.closing {
    animation: modalSlideOut 0.3s ease-out forwards;
}

@keyframes modalBackgroundFadeIn {
    from {
        background-color: rgba(0, 0, 0, 0); /* Transparent */
    }
    to {
        background-color: rgba(0, 0, 0, 0.5); /* Darkened background */
    }
}

@keyframes modalBackgroundFadeOut {
    from {
        background-color: rgba(0, 0, 0, 0.5); /* Darkened background */
    }
    to {
        background-color: rgba(0, 0, 0, 0); /* Transparent */
    }
}

.modal-content {
    background-color: var(--background);
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

/* Modal Size Variants */
.modal-content.modal-large {
    width: 95%;
    max-width: 1200px;
    max-height: 90vh;
    margin: 2% auto;
}

.modal-content.modal-medium {
    width: 80%;
    max-width: 600px;
    max-height: 75vh;
    margin: 8% auto;
}

.modal-content.modal-compact {
    width: 60%;
    max-width: 400px;
    max-height: 60vh;
    margin: 15% auto;
}

.modal-content.modal-auto {
    width: auto;
    min-width: 300px;
    max-width: 90vw;
    height: auto;
    min-height: 200px;
    max-height: 85vh;
    margin: 5% auto 5% auto;
    display: flex;
    flex-direction: column;
}

.modal-content.modal-auto .modal-body {
    flex: 1;
    min-height: auto;
    max-height: none;
    overflow: visible;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes modalSlideOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }
}

.modal-header {
    background-color: var(--secondary);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ddd;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5em;
    font-weight: 600;
}

.close-btn {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: white;
    opacity: 0.8;
    transition: opacity 0.2s;
    line-height: 1;
    padding: 0 5px;
}

.close-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.modal-body {
    padding: 20px;
    max-height: calc(85vh - 80px);
    overflow-y: auto;
}

/* Auto modal body adjustments */
.modal-content.modal-auto .modal-body {
    max-height: calc(90vh - 80px);
    overflow-y: auto;
    flex-shrink: 0;
}