/* =========================================================
   PNH Related Product Data — Modal tabs
   Loads only on WooCommerce single-product pages.
   ========================================================= */

body.pnh-related-modal-open {
    overflow: hidden !important;
}

.pnh-related-modal[hidden] {
    display: none !important;
}

.pnh-related-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(14px, 3vw, 32px);
}

.pnh-related-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(18, 31, 25, 0.58);
    backdrop-filter: blur(2px);
}

.pnh-related-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(980px, 100%);
    max-height: min(88vh, 920px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--global-palette9, #fff);
    color: var(--global-palette3, #25302b);
    border-radius: 14px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.pnh-related-modal__header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(35, 65, 52, 0.14);
    background: var(--global-palette8, #f5f7f5);
}

.pnh-related-modal__title {
    margin: 0 !important;
    padding: 0 !important;
    font-size: clamp(1.15rem, 2vw, 1.45rem) !important;
    line-height: 1.25 !important;
    color: inherit !important;
}

.pnh-related-modal__close {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(35, 65, 52, 0.22);
    border-radius: 50%;
    background: #fff;
    color: var(--global-palette3, #25302b);
    font-family: Arial, sans-serif;
    font-size: 28px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
}

.pnh-related-modal__close:hover,
.pnh-related-modal__close:focus-visible {
    border-color: var(--global-palette-btn-bg, #2f8f46);
    color: var(--global-palette-btn-bg, #2f8f46);
    outline: none;
}

.pnh-related-modal__body {
    flex: 1 1 auto;
    min-height: 180px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: clamp(20px, 4vw, 38px);
    -webkit-overflow-scrolling: touch;
}

.pnh-related-modal__body > :first-child,
.pnh-related-modal__body .pnh-related-modal__content > :first-child {
    margin-top: 0 !important;
}

.pnh-related-modal__body > :last-child,
.pnh-related-modal__body .pnh-related-modal__content > :last-child {
    margin-bottom: 0 !important;
}

.pnh-related-modal__loading {
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--global-palette4, #65716b);
    text-align: center;
}

.pnh-related-modal__spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(47, 143, 70, 0.18);
    border-top-color: var(--global-palette-btn-bg, #2f8f46);
    border-radius: 50%;
    animation: pnh-related-modal-spin .75s linear infinite;
}

@keyframes pnh-related-modal-spin {
    to { transform: rotate(360deg); }
}

.pnh-related-modal__error {
    padding: 18px 20px;
    border-left: 4px solid #b42318;
    background: #fff6f5;
    border-radius: 8px;
}

/* Multiple selected Clinic/Therapist records. */
.pnh-related-modal__item + .pnh-related-modal__item {
    margin-top: 34px;
    padding-top: 30px;
    border-top: 1px solid rgba(35, 65, 52, 0.14);
}

.pnh-related-modal__item-title {
    margin-top: 0 !important;
}

/* Keep large standalone-page layouts sensible inside a dialog. */
.pnh-related-modal__body .alignwide,
.pnh-related-modal__body .alignfull {
    max-width: 100% !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

@media (max-width: 767px) {
    /*
     * Keep the mobile experience as a true modal rather than a full-screen
     * sheet.  The visible dimmed product page around the dialog reinforces
     * that the visitor has not navigated away from the treatment page.
     */
    .pnh-related-modal {
        align-items: center;
        justify-content: center;
        padding:
            max(18px, env(safe-area-inset-top))
            12px
            max(18px, env(safe-area-inset-bottom));
    }

    .pnh-related-modal__backdrop {
        background: rgba(18, 31, 25, 0.62);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }

    .pnh-related-modal__dialog {
        width: min(94vw, 680px);
        height: auto;
        max-height: 88dvh;
        border-radius: 14px;
        box-shadow: 0 18px 55px rgba(0, 0, 0, 0.34);
    }

    .pnh-related-modal__header {
        padding: 14px 15px;
    }

    .pnh-related-modal__title {
        font-size: 1.08rem !important;
    }

    .pnh-related-modal__close {
        width: 38px;
        height: 38px;
        font-size: 26px;
    }

    .pnh-related-modal__body {
        min-height: 0;
        padding: 18px 16px 24px;
    }
}

@media (max-width: 380px) {
    .pnh-related-modal {
        padding-left: 9px;
        padding-right: 9px;
    }

    .pnh-related-modal__dialog {
        width: 96vw;
        max-height: 90dvh;
        border-radius: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pnh-related-modal__spinner {
        animation-duration: 1.5s;
    }
}
