﻿/* Bootstrap 5 JS compatibility shim for Bootstrap 2.x CSS */
/* BS5 JS uses .fade + .show instead of BS2's .fade + .in */

/* =========================================================================
   Fade compatibility — scoped to avoid breaking legacy popups
   =========================================================================
   Legacy popups have class="modal fade" but are shown via ShowCenteredDiv()
   which never adds .show. Applying opacity:0 to bare .fade would hide them.
   Instead, scope the fade only to non-modal elements and to the modal-backdrop.
   For BS5 modals the fade is handled via .modal-dialog below.
   ========================================================================= */
.fade:not(.modal):not(.modal-backdrop) {
    opacity: 0;
    transition: opacity 0.15s linear;
}

    .fade:not(.modal):not(.modal-backdrop).show {
        opacity: 1;
    }

.modal-backdrop.fade {
    opacity: 0;
    transition: opacity 0.15s linear;
}

    .modal-backdrop.fade.show {
        opacity: 0.8;
    }

/* =========================================================================
   BS5 Collapse compatibility with BS2 CSS
   =========================================================================
   BS2 CSS uses .collapse.in { height: auto } to reveal panels.
   BS5 JS adds .show instead of .in, so panels stay at height:0.
   ========================================================================= */
.collapse.show:not(.accordion-body) {
    display: block;
    height: auto !important;
    visibility: visible !important;
    overflow: visible !important;
}

/* jQuery UI accordion panels that also carry .collapse.show need only
   the .in-equivalent reveal; jQuery UI handles the rest. */
.accordion-body.collapse.show {
    display: block;
    height: auto !important;
}

/* BS5 uses .collapsing for the animation transition */
.collapsing {
    height: 0;
    overflow: hidden;
    transition: height 0.35s ease;
}

/* =========================================================================
   BS5 Modal compatibility with BS2 CSS
   =========================================================================
   BS2 positions .modal with fixed positioning and uses top:-25% -> top:50%
   slide-down animation via the .in class. BS5 JS adds .show instead of .in.

   This shim replicates the BS2 animation: the .modal starts at top:-25%
   (off-screen above) and transitions to top:50% (centered vertically).
   Horizontal centering uses transform:translateX(-50%) with left:50%.

   ALL .modal-dialog rules are scoped to .modal.show so they never affect
   legacy popups that contain a .modal-dialog child but are shown via
   ShowCenteredDiv() (which never adds .show).
   ========================================================================= */

/* Ensure hidden BS5 modals do not intercept pointer or keyboard events.
   Scoped to .modal.fade so legacy popups that only have .modal are unaffected. */
.modal.fade:not(.show) {
    pointer-events: none;
}

/* Starting position — off-screen above, centered horizontally */
.modal.fade {
    position: fixed !important;
    top: -25% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translateX(-50%);
    margin: 0 !important;
    opacity: 0;
    transition: top 0.3s ease-out, opacity 0.15s linear !important;
}

/* Final position — vertically centered, slides down from top */
.modal.show {
    position: fixed !important;
    display: block !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%);
    margin: 0 !important;
    padding: 0 !important;
    overflow-x: hidden;
    overflow-y: auto;
    pointer-events: auto;
    opacity: 1;
    transition: top 0.3s ease-out, opacity 0.15s linear !important;
}

    /* Dialog wrapper — transparent passthrough since .modal is the visual box */
    .modal.show .modal-dialog {
        position: static;
        width: auto;
        margin: 0;
        padding: 0;
        opacity: 1;
    }

/* No separate dialog animation needed — the parent .modal handles it */
.modal.fade .modal-dialog {
    opacity: 1;
}

/* Dialog panel — replicates BS2 .modal visual on the inner panel */
.modal.show .modal-dialog .modal-content {
    position: relative;
    background-color: #fff;
    border: 1px solid rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
    background-clip: padding-box;
}

/* =========================================================================
   BS5 Modal .modal-header layout fix
   =========================================================================
   Scoped to .modal.show .modal-dialog to avoid affecting legacy BS2 popups
   that also use .modal-header but are not managed by BS5.
   ========================================================================= */
.modal.show .modal-dialog .modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

    /* Override BS2 .close float since we use flexbox; reset browser button defaults */
    .modal.show .modal-dialog .modal-header .close {
        order: 1;
        float: none;
        padding: 0;
        margin: 0;
        background: transparent;
        border: 0;
        font-size: 20px;
        line-height: 1;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
    }

/* jQuery UI Dialog close button fix - Bootstrap 5 resets interfere with the sprite icon */
.ui-dialog .ui-dialog-titlebar-close {
    background: none !important;
    background-image: none !important;
    border: 1px solid transparent !important;
    padding: 0 !important;
    width: 20px !important;
    height: 20px !important;
    position: absolute !important;
    right: .3em !important;
    top: 50% !important;
    margin: -10px 0 0 0 !important;
    cursor: pointer;
    box-sizing: content-box !important;
    overflow: visible !important;
    font-size: 0 !important;
    line-height: 1 !important;
    opacity: 0.7;
}

    .ui-dialog .ui-dialog-titlebar-close:hover {
        opacity: 1;
        border-color: rgba(255,255,255,0.3) !important;
    }

    .ui-dialog .ui-dialog-titlebar-close .ui-button-text,
    .ui-dialog .ui-dialog-titlebar-close .ui-icon {
        display: none !important;
    }

    .ui-dialog .ui-dialog-titlebar-close::after {
        content: "\00d7";
        display: block;
        font-size: 18px;
        font-weight: bold;
        color: #fff;
        text-align: center;
        line-height: 20px;
        width: 20px;
        height: 20px;
        text-indent: 0;
    }

/* jQuery UI Dialog z-index fix */
.ui-dialog {
    z-index: 1100 !important;
}

.ui-widget-overlay {
    z-index: 1099 !important;
}

/* =========================================================================
   BS5 .btn-close compatibility
   =========================================================================
   BS5 JS emits <button class="btn-close"> which relies on a BS5 CSS
   background SVG that is absent in BS2.  Render the × with a pseudo-element
   instead.
   ========================================================================= */
.btn-close {
    box-sizing: content-box;
    width: 1em;
    height: 1em;
    padding: 0.25em 0.25em;
    color: #000;
    background: transparent;
    border: 0;
    border-radius: 0.25rem;
    opacity: 0.5;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    font-size: 0;
    line-height: 1;
    position: relative;
}

    .btn-close:hover {
        opacity: 0.75;
    }

    .btn-close:focus {
        opacity: 1;
        outline: 0;
        box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
    }

    .btn-close::after {
        content: "\00d7";
        font-size: 20px;
        font-weight: bold;
        line-height: 1;
        display: block;
        text-align: center;
    }

/* White variant used inside dark headers */
.btn-close-white {
    color: #fff;
}

    .btn-close-white::after {
        color: #fff;
    }

/* =========================================================================
   BS5 Popover compatibility
   ========================================================================= */
.popover {
    max-width: 476px;
    margin-top: 10px;
}

    .popover.show {
        display: block;
    }

    .popover .popover-arrow {
        position: absolute;
        display: block;
        width: 22px;
        height: 11px;
    }

        .popover .popover-arrow::before,
        .popover .popover-arrow::after {
            position: absolute;
            display: block;
            content: "";
            border-color: transparent;
            border-style: solid;
        }

/* BS5 uses .popover-header instead of BS2's .popover-title */
.popover-header {
    margin: 0;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 400;
    line-height: 18px;
    background-color: #f7f7f7;
    border-bottom: 1px solid #ebebeb;
    border-radius: 5px 5px 0 0;
}

/* BS5 uses .popover-body instead of BS2's .popover-content */
.popover-body {
    padding: 9px 14px;
}

    .popover-body ul {
        list-style: none;
        padding-left: 0;
        margin-bottom: 0;
        margin-top: 0;
    }

        .popover-body ul li {
            line-height: 24px;
        }

            .popover-body ul li a {
                display: block;
                color: #00b2e2;
                text-decoration: none;
                font-size: 14px;
                line-height: 20px;
            }

                .popover-body ul li a:hover {
                    color: #005580;
                    text-decoration: underline;
                }

/* Popover arrow positioning for all four directions */
.bs-popover-bottom > .popover-arrow,
.bs-popover-auto[data-popper-placement^="bottom"] > .popover-arrow {
    top: -11px;
}

    .bs-popover-bottom > .popover-arrow::before,
    .bs-popover-auto[data-popper-placement^="bottom"] > .popover-arrow::before {
        top: 0;
        border-width: 0 11px 11px;
        border-bottom-color: rgba(0, 0, 0, 0.25);
    }

    .bs-popover-bottom > .popover-arrow::after,
    .bs-popover-auto[data-popper-placement^="bottom"] > .popover-arrow::after {
        top: 1px;
        border-width: 0 11px 11px;
        border-bottom-color: #ffffff;
    }

.bs-popover-top > .popover-arrow,
.bs-popover-auto[data-popper-placement^="top"] > .popover-arrow {
    bottom: -11px;
}

    .bs-popover-top > .popover-arrow::before,
    .bs-popover-auto[data-popper-placement^="top"] > .popover-arrow::before {
        bottom: 0;
        border-width: 11px 11px 0;
        border-top-color: rgba(0, 0, 0, 0.25);
    }

    .bs-popover-top > .popover-arrow::after,
    .bs-popover-auto[data-popper-placement^="top"] > .popover-arrow::after {
        bottom: 1px;
        border-width: 11px 11px 0;
        border-top-color: #ffffff;
    }

.bs-popover-end > .popover-arrow,
.bs-popover-auto[data-popper-placement^="right"] > .popover-arrow {
    left: -11px;
    width: 11px;
    height: 22px;
}

    .bs-popover-end > .popover-arrow::before,
    .bs-popover-auto[data-popper-placement^="right"] > .popover-arrow::before {
        left: 0;
        border-width: 11px 11px 11px 0;
        border-right-color: rgba(0, 0, 0, 0.25);
    }

    .bs-popover-end > .popover-arrow::after,
    .bs-popover-auto[data-popper-placement^="right"] > .popover-arrow::after {
        left: 1px;
        border-width: 11px 11px 11px 0;
        border-right-color: #ffffff;
    }

.bs-popover-start > .popover-arrow,
.bs-popover-auto[data-popper-placement^="left"] > .popover-arrow {
    right: -11px;
    width: 11px;
    height: 22px;
}

    .bs-popover-start > .popover-arrow::before,
    .bs-popover-auto[data-popper-placement^="left"] > .popover-arrow::before {
        right: 0;
        border-width: 11px 0 11px 11px;
        border-left-color: rgba(0, 0, 0, 0.25);
    }

    .bs-popover-start > .popover-arrow::after,
    .bs-popover-auto[data-popper-placement^="left"] > .popover-arrow::after {
        right: 1px;
        border-width: 11px 0 11px 11px;
        border-left-color: #ffffff;
    }

/* Prevent Bootstrap modal from hiding parent scrollbar */
body.modal-open {
    overflow: auto !important;
    padding-right: 0 !important;
}
