/* ================================
   MODAL COMPONENT - Bootstrap-inspired Minimalist Redesign
   ================================ */

/* Modal backdrop and container */
.modal {
    --pds-modal-width: 500px;
    --pds-modal-margin: 0.5rem;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(2px);
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

/* Modal dialog container */
.modal-dialog {
    position: relative;
    width: 100%;
    margin: var(--pds-modal-margin);
    transform: scale(0.95) translateY(-20px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.modal.show .modal-dialog {
    transform: scale(1) translateY(0);
    pointer-events: auto; /* Enable clicks on dialog content */
}

/* Modal content wrapper */
.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    background: var(--pds-neutral-white);
    pointer-events: auto; /* Enable clicks on dialog content */
    border: 1px solid var(--pds-neutral-grey-200);
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden; /* Important for content scrolling */
    /* max-height: inherit; */

}

/* Modal header */
.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--pds-neutral-grey-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    background: var(--pds-neutral-white);
}

.modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--pds-neutral-grey-900);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-title .icon {
    color: var(--pds-primary-500);
    font-size: 1.125rem;
}

.modal-close {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--pds-neutral-grey-600);
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
}

.modal-close:hover {
    background: var(--pds-neutral-grey-100);
    color: var(--pds-neutral-grey-800);
}

.modal-close:focus {
    outline: 2px solid var(--pds-primary-500);
    outline-offset: 2px;
}

/* Modal body */
.modal-body {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
    max-height: calc(90vh - 120px); /* Adjusted for header/footer height */
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: var(--pds-neutral-grey-100);
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--pds-neutral-grey-400);
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--pds-neutral-grey-500);
}

/* Modal footer */
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--pds-neutral-grey-200);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-shrink: 0;
}

.modal-footer.justify-start {
    justify-content: flex-start;
}

.modal-footer.justify-center {
    justify-content: center;
}

.modal-footer.justify-between {
    justify-content: space-between;
}

/* Fullscreen modal */
.modal-dialog.modal-fullscreen {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
}

.modal-fullscreen .modal-content {
    height: 100%;
    border-radius: 0;
}

/* Static backdrop effect */
.modal.static-backdrop .modal-dialog {
    animation: modal-shake 0.3s ease-in-out;
}

@keyframes modal-shake {
    0%, 100% { transform: scale(1) translateY(0); }
    25% { transform: scale(1.02) translateY(-2px); }
    75% { transform: scale(0.98) translateY(2px); }
}

/* Body class when modal is open */
body.modal-open {
    overflow: hidden;
    padding-right: 0;
}

/* Focus trap styles */
.modal-content:focus {
    outline: none;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }

    .modal-footer {
        flex-direction: column;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        width: 100%;
    }
}

/* Small screens (576px and up) */
@media (min-width: 576px) {
    .modal {
        --pds-modal-margin: 1.75rem;
    }

    .modal-dialog {
        max-width: var(--pds-modal-width);
        margin-left: auto;
        margin-right: auto;
    }

    .modal-sm {
        --pds-modal-width: 300px
    }

}

/* Medium screens (768px and up) */
@media (min-width: 768px) {
}

/* Large screens (992px and up) */
@media (min-width: 992px) {

    .modal-lg,
    .modal-xl {
        --pds-modal-width: 800px
    }
}

/* Extra large screens (1200px and up) */
@media (min-width: 1200px) {
    .modal-xl {
        --pds-modal-width: 1140px
    }
}
