/* Section Edit Modal Styles */

/* --- Enhanced Modal Styling --- */
.modal-body-edit-form { /* Class added to EditForm */
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Allow the form to take remaining space if .modal-body is inside it */
    overflow: hidden; /* Crucial: form itself should not scroll, .modal-body inside it will */
    min-height: 0; /* Fix for flex item overflowing in some browsers */
}

/* Outer modal wrapper (the backdrop) */
.modal.fade.show.d-block {
    display: flex !important; /* Use flex to enable vertical centering of modal-dialog */
    align-items: center; /* Vertically center modal-dialog */
    justify-content: center; /* Horizontally center modal-dialog */
    overflow-y: hidden;
    /* If modal itself is taller than screen, page might scroll.
                                  But usually, we constrain modal height. */
    position: fixed; /* Ensure it covers the whole screen */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1050; /* Bootstrap's default modal z-index, ensure it's high enough */

 
}


/* The dialog box that contains the modal content */
.modal-dialog {
    position: relative; /* For positioning within the flex container */
    margin: 0.5rem; /* Default Bootstrap margin */
    pointer-events: none; /* Allow clicks "through" to the modal if backdrop is clicked */
    width: auto; /* Let modal-content define width up to max-width */

    display: flex; /* Make .modal-dialog a flex container for .modal-content */
    flex-direction: column; /* Stack .modal-content (though .modal-content is usually singular) */
}

.modal-dialog-scrollable .modal-content {
    max-height: calc(100vh - 3.5rem);
}

.modal-dialog-scrollable .modal-body {
    overflow-y: auto;
}
.modal-dialog-centered {
    /* Already centered by flex on .modal */
}


/* The main modal box */
.modal-content {
    position: relative;
    display: flex;
    flex-direction: column; /* CRUCIAL: Stack header, body, footer vertically */
    width: 100%; /* Take up width of modal-dialog */
    pointer-events: auto; /* Re-enable pointer events for the content */
    background-color: var(--card-bg, #fff);
    background-clip: padding-box;
    border: 1px solid rgba(0,0,0,.2);
    border-radius: var(--border-radius, 0.3rem);
    outline: 0;
    /* CRUCIAL for scrollable body: Define a max height for the entire modal content.
       The body will then take up the remaining space and scroll. */
    max-height: 90vh; /* Example: Modal content won't exceed 90% of viewport height */
    /* You can also use a pixel value: max-height: 700px; */
    overflow: hidden; /* Prevent .modal-content itself from showing scrollbars */

    }

/* Modal Header */
.modal-header {
    display: flex;
    align-items: flex-start; /* Align title and close button */
    justify-content: space-between;
    padding: 1rem 1.5rem; /* Your desired padding */
    border-bottom: 1px solid var(--border-color);
    border-top-left-radius: calc(var(--border-radius) - 1px); /* Match content rounding */
    border-top-right-radius: calc(var(--border-radius) - 1px);
    flex-shrink: 0; /* PREVENT HEADER FROM SHRINKING */
    background-color: var(--primary-color); /* From your previous styling */
    color: white;
}

    .modal-header .modal-title {
        margin-bottom: 0;
        line-height: 1.5;
        font-size: 1.25rem; /* Your preferred title size */
    }

    .modal-header .btn-close { /* Assuming Bootstrap's default close button markup */
        padding: 0.5rem;
        margin: -0.5rem -0.5rem -0.5rem auto;
        background: transparent escape("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;
        border: 0;
        border-radius: .25rem;
        opacity: .8;
    }

        .modal-header .btn-close:hover {
            opacity: 1;
        }


/* Modal Body - THIS IS WHERE THE SCROLLING HAPPENS */
.modal-body {
    position: relative; /* For potential absolute positioned elements inside */
    flex-grow: 1; /* CRUCIAL: Allows body to take up available vertical space */
    padding: 1.5rem; /* Your desired padding */
    overflow-y: auto; /* CRUCIAL: Adds vertical scrollbar ONLY to the body when content overflows */
   
}

    /* Styles for content within _SectionEditModal's body */
    .modal-body fieldset { /* Your .editor-section in the modal */
        margin-bottom: 1.5rem;
        padding: 1rem 0.25rem; /* Adjust padding if needed */
        border: none; /* Remove border if already wrapped by modal border */
        background-color: transparent;
        box-shadow: none;
    }

        .modal-body fieldset legend {
            font-size: 1.15rem; /* Slightly smaller legend in modal */
            color: var(--primary-color);
            border-bottom: 1px solid #e0e0e0;
            margin-bottom: 1rem;
            padding-bottom: 0.5rem;
            font-weight: 600;
        }

    .modal-body .form-group label {
        font-size: 0.9rem;
        margin-bottom: 0.25rem;
    }

    .modal-body .form-control {
        font-size: 0.95rem; /* Ensure form controls are not too large */
    }


/* Modal Footer */
.modal-footer {
    display: flex;
    flex-wrap: wrap; /* In case of many buttons */
    align-items: center; /* Vertically align items */
    justify-content: flex-end; /* Align buttons to the right */
    padding: 1rem 1.5rem; /* Your desired padding */
    border-top: 1px solid var(--border-color);
    border-bottom-right-radius: calc(var(--border-radius) - 1px); /* Match content rounding */
    border-bottom-left-radius: calc(var(--border-radius) - 1px);
    flex-shrink: 0; /* PREVENT FOOTER FROM SHRINKING */
    background-color: var(--light-color); /* Optional footer background */
}

    .modal-footer > :not(:first-child) {
        margin-left: .25rem;
    }
    /* Spacing for buttons */
    .modal-footer > :not(:last-child) {
        margin-right: .25rem;
    }


.modal-content-flex-form { /* Class applied to EditForm if it IS the modal-content */
    display: flex;
    flex-direction: column;
    max-height: 90vh; /* Overall constraint */
    overflow: hidden; /* Prevent this from scrolling */
    /* Add other .modal-content styles like background, border, radius */
    background-color: var(--card-bg, #fff);
    border: 1px solid rgba(0,0,0,.2);
    border-radius: var(--border-radius, 0.3rem);
}

    /* The direct children of the form are now .modal-header, .modal-body, .modal-footer */
    .modal-content-flex-form > .modal-header {
        flex-shrink: 0;
    }

    .modal-content-flex-form > .modal-body {
        flex-grow: 1;
        overflow-y: auto;
        padding: 1.5rem; /* Ensure padding is here */
    }

    .modal-content-flex-form > .modal-footer {
        flex-shrink: 0;
    }


.btn-danger {
    transition: all 0.2s ease;
}

    .btn-danger:hover {
        transform: scale(1.05);
    }
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Responsive adjustments for modal on smaller screens */
@media (max-width: 575.98px) { /* Bootstrap's sm breakpoint, adjust as needed */
    .modal-dialog {
        margin: 0.5rem; /* Less margin on small screens */
        /* The modal-content max-height will ensure it fits */
    }

    .modal-content {
        max-height: 95vh; /* Allow modal to take up almost full height */
    }

    .modal-header, .modal-body, .modal-footer {
        padding: 1rem; /* Reduce padding */
    }

        .modal-header .modal-title {
            font-size: 1.1rem;
        }

    .modal-footer {
        justify-content: center; /* Center buttons on small screens */
    }
}



/* styles.css */
.modal-dialog.modal-my-large {
    max-width: 500px; /* Default for small screens */
}

@media (min-width: 768px) { /* md breakpoint */
    .modal-dialog.modal-my-large {
        max-width: 720px; /* Wider on medium screens */
    }
}

@media (min-width: 992px) { /* lg breakpoint */
    .modal-dialog.modal-my-large {
        max-width: 900px; /* Even wider on large screens */
    }
}

@media (min-width: 1200px) { /* xl breakpoint */
    .modal-dialog.modal-my-large {
        max-width: 1100px; /* Max out similar to a wide container */
    }
}


