/**
 * Modal Fix CSS
 * 
 * This CSS file fixes issues with Bootstrap modals freezing the screen
 * by adjusting z-index values and ensuring proper positioning.
 */

/* Fix for modal z-index to ensure they appear above dropdowns */
.modal {
    z-index: 1050 !important;
    display: none;
    overflow: hidden;
    outline: 0;
}

/* Fix for modal backdrop */
.modal-backdrop {
    z-index: 1040 !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    opacity: 0.5 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: auto !important;
}

/* Ensure only one backdrop is visible */
.modal-backdrop + .modal-backdrop {
    display: none !important;
}

/* Fix for modal dialog positioning */
.modal-dialog {
    margin: 1.75rem auto;
    max-width: 500px;
    position: relative;
    pointer-events: auto;
}

/* Fix for modal content */
.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 0.3rem;
    outline: 0;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.5) !important;
}

/* Fix for modal header */
.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    border-top-left-radius: 0.3rem;
    border-top-right-radius: 0.3rem;
}

/* Fix for modal body */
.modal-body {
    position: relative;
    flex: 1 1 auto;
    padding: 1rem;
}

/* Fix for modal footer */
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 1rem;
    border-top: 1px solid #dee2e6;
    border-bottom-right-radius: 0.3rem;
    border-bottom-left-radius: 0.3rem;
}

/* Fix for modal scrolling */
.modal-open {
    overflow: hidden;
    padding-right: 0 !important;
}

/* Fix for modal animation */
.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out !important;
    transform: translate(0, -25px) !important;
}

.modal.show .modal-dialog {
    transform: translate(0, 0) !important;
}

/* Fix for modal sizes */
.modal-sm {
    max-width: 300px;
}

.modal-lg {
    max-width: 800px;
}

.modal-xl {
    max-width: 1140px;
}

/* Fix for modal close button */
.modal .close {
    float: right;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    color: #000;
    text-shadow: 0 1px 0 #fff;
    opacity: 0.5;
    padding: 0;
    background-color: transparent;
    border: 0;
    appearance: none;
}

.modal .close:hover {
    color: #000;
    text-decoration: none;
    opacity: 0.75;
}

/* Fix for modal stacking */
.modal-backdrop + .modal-backdrop {
    opacity: 0 !important;
    display: none !important;
}

/* Fix for body when modal is open */
body.modal-open {
    overflow: hidden !important;
    padding-right: 0 !important;
}

/* Ensure modals are visible and interactive */
.modal.show {
    display: block !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    pointer-events: auto !important;
}

/* Ensure modal content is interactive */
.modal-dialog {
    pointer-events: auto !important;
}

/* Ensure modal content is visible */
.modal-content {
    pointer-events: auto !important;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.5) !important;
}

/* General modal size classes are sufficient now that we've fixed the root cause */

/* Fix for modal scrollbar */
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}