/* =========================================================
   MDRx Hover Category Mega Menu
   ========================================================= */

.cp11-category-hub {
    position: relative !important;
}

/* Closed by default */
.cp11-mega-menu {
    display: none !important;
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    width: min(1080px, calc(100vw - 48px)) !important;
    background: #ffffff !important;
    border: 1px solid #d8e1ea !important;
    border-radius: 0 0 16px 16px !important;
    box-shadow: 0 24px 60px rgba(21, 39, 73, 0.18) !important;
    overflow: hidden !important;
    z-index: 9999 !important;
}

/* Auto-open on hover, keyboard focus, or existing click state */
.cp11-category-hub:hover .cp11-mega-menu,
.cp11-category-hub:focus-within .cp11-mega-menu,
.cp11-category-hub.is-open .cp11-mega-menu,
.cp11-category-hub.open .cp11-mega-menu,
.cp11-allcat[aria-expanded="true"] + .cp11-mega-menu,
.cp11-mega-menu.is-open {
    display: block !important;
}

/* Small invisible bridge prevents dropdown closing between button and panel */
.cp11-category-hub::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: 12px;
    pointer-events: none;
}

.cp11-category-hub:hover::after,
.cp11-category-hub:focus-within::after {
    pointer-events: auto;
}

.mdrx-cat-panel {
    display: grid !important;
    grid-template-columns: 290px minmax(0, 1fr) !important;
    width: 100% !important;
    min-height: 440px !important;
    max-height: 590px !important;
    margin: 0 !important;
    background: #ffffff !important;
    color: #152749 !important;
}

/* Left parent categories */
.mdrx-cat-sidebar {
    padding: 14px 0 !important;
    background: #f7f9fb !important;
    border-right: 1px solid #e3e9ef !important;
    overflow-y: auto !important;
}

.mdrx-cat-sidebar__item {
    width: 100% !important;
    min-height: 58px !important;
    display: grid !important;
    grid-template-columns: 36px minmax(0, 1fr) 20px !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 10px 18px !important;
    border: 0 !important;
    border-left: 4px solid transparent !important;
    background: transparent !important;
    color: #334155 !important;
    text-align: left !important;
    cursor: pointer !important;
    transition: background .16s ease, color .16s ease, border-color .16s ease !important;
}

.mdrx-cat-sidebar__item:hover,
.mdrx-cat-sidebar__item:focus,
.mdrx-cat-sidebar__item.is-active {
    background: #ffffff !important;
    border-left-color: #c91322 !important;
    color: #152749 !important;
    outline: none !important;
}

.mdrx-cat-sidebar__icon {
    width: 34px !important;
    height: 34px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 9px !important;
    background: #eaf0f5 !important;
    font-size: 17px !important;
}

.mdrx-cat-sidebar__label {
    font-size: 15px !important;
    font-weight: 750 !important;
    line-height: 1.3 !important;
}

.mdrx-cat-sidebar__arrow {
    color: #94a3b8 !important;
    font-size: 22px !important;
    text-align: right !important;
}

.mdrx-cat-sidebar__item.is-active .mdrx-cat-sidebar__arrow,
.mdrx-cat-sidebar__item:hover .mdrx-cat-sidebar__arrow {
    color: #c91322 !important;
}

/* Right child-category area */
.mdrx-cat-content {
    padding: 28px 30px !important;
    background: #ffffff !important;
    overflow-y: auto !important;
}

.mdrx-cat-pane {
    display: none !important;
}

.mdrx-cat-pane.is-active {
    display: block !important;
    animation: mdrxCategoryFade .16s ease !important;
}

@keyframes mdrxCategoryFade {
    from {
        opacity: 0;
        transform: translateY(3px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mdrx-cat-pane__head {
    display: flex !important;
    align-items: flex-end !important;
    justify-content: space-between !important;
    gap: 20px !important;
    padding-bottom: 16px !important;
    margin-bottom: 22px !important;
    border-bottom: 1px solid #e5ebf1 !important;
}

.mdrx-cat-pane__eyebrow {
    display: block !important;
    margin-bottom: 5px !important;
    color: #64748b !important;
    font-size: 12px !important;
    font-weight: 800 !important;
    letter-spacing: .08em !important;
    text-transform: uppercase !important;
}

.mdrx-cat-pane__head h3 {
    margin: 0 !important;
    color: #152749 !important;
    font-size: 26px !important;
    font-weight: 850 !important;
    line-height: 1.2 !important;
}

.mdrx-cat-pane__head > a {
    display: inline-flex !important;
    align-items: center !important;
    gap: 7px !important;
    color: #c91322 !important;
    font-size: 14px !important;
    font-weight: 800 !important;
    text-decoration: none !important;
    white-space: nowrap !important;
}

.mdrx-cat-subgrid {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(170px, 1fr)) !important;
    gap: 14px !important;
}

.mdrx-cat-subitem {
    min-height: 58px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    padding: 14px 16px !important;
    border: 1px solid #e0e7ee !important;
    border-radius: 12px !important;
    background: #ffffff !important;
    color: #334155 !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    line-height: 1.35 !important;
    text-decoration: none !important;
    transition: border-color .16s ease, color .16s ease, box-shadow .16s ease !important;
}

.mdrx-cat-subitem > span:last-child {
    color: #94a3b8 !important;
    font-size: 20px !important;
}

.mdrx-cat-subitem:hover {
    border-color: #168ca8 !important;
    color: #c91322 !important;
    box-shadow: 0 8px 22px rgba(21, 39, 73, 0.08) !important;
}

.mdrx-cat-subitem:hover > span:last-child {
    color: #c91322 !important;
}

/* Hide any legacy top-tab elements if cached markup remains */
.mdrx-cat-panel__header,
.mdrx-cat-panel__tabs,
.mdrx-cat-tab,
.mdrx-cat-panel__all {
    display: none !important;
}

/* Tablet */
@media (max-width: 1000px) {
    .cp11-mega-menu {
        width: min(900px, calc(100vw - 24px)) !important;
    }

    .mdrx-cat-panel {
        grid-template-columns: 250px minmax(0, 1fr) !important;
    }

    .mdrx-cat-subgrid {
        grid-template-columns: repeat(2, minmax(160px, 1fr)) !important;
    }
}

/* Mobile and touch */
@media (max-width: 767px) {
    .cp11-mega-menu {
        position: fixed !important;
        top: 112px !important;
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        max-height: calc(100vh - 128px) !important;
        overflow-y: auto !important;
        border-radius: 14px !important;
    }

    .mdrx-cat-panel {
        grid-template-columns: 1fr !important;
        min-height: auto !important;
        max-height: none !important;
    }

    .mdrx-cat-sidebar {
        display: flex !important;
        padding: 8px !important;
        border-right: 0 !important;
        border-bottom: 1px solid #e3e9ef !important;
        overflow-x: auto !important;
    }

    .mdrx-cat-sidebar__item {
        width: auto !important;
        min-width: max-content !important;
        grid-template-columns: 30px auto !important;
        border-left: 0 !important;
        border-bottom: 3px solid transparent !important;
        border-radius: 10px !important;
    }

    .mdrx-cat-sidebar__item.is-active {
        border-bottom-color: #c91322 !important;
    }

    .mdrx-cat-sidebar__arrow {
        display: none !important;
    }

    .mdrx-cat-content {
        padding: 20px !important;
    }

    .mdrx-cat-subgrid {
        grid-template-columns: 1fr !important;
    }
}
