/* Shared modal primitives */
.modal .btn-close,
.offcanvas .btn-close,
#calculator_wrap > #calculator_close_btn.btn-close {
    position: relative;
    border: 0;
    background: transparent !important;
    background-image: none !important;
    box-shadow: none;
    color: #74788d;
    filter: none;
    opacity: 1;
    transition: color 0.15s ease, opacity 0.15s ease;
}

.modal .btn-close:hover,
.offcanvas .btn-close:hover,
#calculator_wrap > #calculator_close_btn.btn-close:hover {
    color: #495057;
    opacity: 1;
}

.modal .btn-close:focus,
.offcanvas .btn-close:focus,
#calculator_wrap > #calculator_close_btn.btn-close:focus {
    color: #74788d;
    box-shadow: none;
    opacity: 1;
}

.modal .btn-close::before,
.offcanvas .btn-close::before,
#calculator_wrap > #calculator_close_btn.btn-close::before {
    content: "\00d7";
    position: absolute;
    top: 50%;
    left: 50%;
    color: currentColor;
    font-size: 2.25rem;
    font-weight: 100;
    line-height: 1;
    transform: translate(-50%, -54%);
}

.modal-fullheight {
    height: 95vh;
    max-height: 95vh;
}

.modal-xxl {
    max-width: 95%;
}

.modal-dialog .modal-content {
    max-height: calc(100vh - 3.5rem);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-dialog .modal-header,
.modal-dialog .modal-footer {
    flex: 0 0 auto;
}

.modal-dialog .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-fullheight .modal-body {
    flex: 1 1 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body.dark .modal .btn-close,
body.dark .offcanvas .btn-close,
body.dark #calculator_wrap > #calculator_close_btn.btn-close {
    color: #a6b0cf;
    opacity: 1;
}

body.dark .modal .btn-close:hover,
body.dark .offcanvas .btn-close:hover,
body.dark #calculator_wrap > #calculator_close_btn.btn-close:hover {
    color: #eff2f7;
    opacity: 1;
}

body.dark .modal .btn-close:focus,
body.dark .offcanvas .btn-close:focus,
body.dark #calculator_wrap > #calculator_close_btn.btn-close:focus {
    color: #a6b0cf;
    opacity: 1;
}

@media (max-width: 767.98px) {
    body .modal {
        z-index: 1056;
    }

    .modal:not(.modal-static) .modal-dialog:not(.modal-fullscreen) {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0 !important;
    }

    .modal:not(.modal-static) .modal-content {
        height: 100dvh;
        min-height: 0;
        max-height: 100dvh;
        border: 0;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    .modal:not(.modal-static) .modal-header,
    .modal:not(.modal-static) .modal-footer {
        flex: 0 0 auto;
        flex-wrap: wrap;
        gap: 0.35rem;
    }

    .modal:not(.modal-static) .modal-footer {
        justify-content: center !important;
        align-items: stretch;
        padding: 0.65rem 0.75rem calc(0.8rem + env(safe-area-inset-bottom, 0px)) !important;
    }

    .modal:not(.modal-static) .modal-footer > .btn,
    .modal:not(.modal-static) .modal-footer > .btn-group {
        width: min(100%, 304px);
        max-width: 304px;
        margin-right: auto !important;
        margin-left: auto !important;
    }

    .modal:not(.modal-static) .modal-footer > .btn,
    .modal:not(.modal-static) .modal-footer > .btn-group > .btn {
        min-height: 36px;
        padding: 0.34rem 0.55rem;
        font-size: 12px;
        line-height: 1.15;
    }

    .modal:not(.modal-static) .modal-footer > .btn-group > .btn:not(:last-child) {
        flex: 1 1 auto;
        min-width: 0;
    }

    .modal:not(.modal-static) .modal-footer > .btn-group > .btn:last-child:not(:only-child) {
        flex: 0 0 44px;
        width: 44px;
        padding-right: 0;
        padding-left: 0;
    }

    #PurchaseCartModal .modal-footer > .btn-group > .btn:first-child,
    #mycartmod .modal-footer > .btn-group > .btn:first-child {
        flex: 1 1 46%;
        width: auto;
        padding-right: 0.55rem;
        padding-left: 0.55rem;
    }

    #PurchaseCartModal .modal-footer > .btn-group > .btn:last-child:not(:only-child),
    #mycartmod .modal-footer > .btn-group > .btn:last-child:not(:only-child) {
        flex: 1 1 54%;
        width: auto;
        padding-right: 0.55rem;
        padding-left: 0.55rem;
    }

    .modal:not(.modal-static) .modal-body {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none !important;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }
}
