/*
 * GORP3 Header v1.0
 * Scoped to Medicalcare header/top-bar only.
 * Joomla 3.1.5, CSS only; existing Bootstrap collapse handles mobile menu.
 */
#top-float {
    background-color: #16a085;
}
#header-outer {
    border-bottom-color: #16a085;
}
#top-inner a:focus,
#header-inner a:focus,
#header-inner button:focus {
    outline: 2px solid #157d6a;
    outline-offset: 2px;
}
.gorp3-menu-toggle-text {
    display: none;
}

/* Keep the current desktop Joomla menu, including submenus and menu assignment. */
@media screen and (min-width: 768px) {
    #header-inner .navbar-toggle.gorp3-menu-toggle {
        display: none;
    }
    #header-inner .menu > li > a {
        transition: background-color .18s ease, color .18s ease;
    }
    #header-inner #toolbar .menu > li > a:hover,
    #header-inner #toolbar .menu > li > a:focus {
        background: #e0f2f1;
        color: #166657;
    }
}

@media screen and (max-width: 767px) {
    /* Previous theme used a full-width logo on phones, creating a very tall header. */
    #header-outer {
        height: auto !important;
        min-width: 0 !important;
        overflow: visible;
    }
    #header-inner {
        position: relative;
        box-sizing: border-box;
        width: 100% !important;
        min-height: 72px;
        padding: 8px 12px !important;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    #header-inner #logo {
        float: none !important;
        display: flex;
        flex: 0 1 auto;
        align-items: center;
        margin: 0 !important;
        padding: 0 !important;
        max-width: calc(100% - 106px);
        min-width: 0;
    }
    #header-inner #logo img.logo {
        display: block;
        width: auto !important;
        max-width: 100%;
        height: 54px !important;
        object-fit: contain;
    }
    /* index.php has an outer #navigation and toolbar.php has an inner #navigation. */
    #header-inner > #navigation {
        float: none !important;
        flex: 0 0 auto;
        width: auto;
        height: auto;
        margin-left: auto;
        padding: 0 !important;
        background: transparent !important;
    }
    #header-inner > #navigation > #navigation {
        float: none !important;
        height: auto;
        padding: 0 !important;
        background: transparent !important;
    }
    #header-inner span.navigation {
        display: none !important;
    }
    #header-inner .navbar-toggle.gorp3-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        float: none;
        margin: 0 !important;
        padding: 9px 11px;
        border: 1px solid #cce6df;
        border-radius: 10px;
        background: #f8fcfb;
        color: #176e5c;
        cursor: pointer;
        min-height: 44px;
    }
    #header-inner .navbar-toggle.gorp3-menu-toggle:hover,
    #header-inner .navbar-toggle.gorp3-menu-toggle:focus {
        background: #e0f2f1;
    }
    #header-inner .gorp3-menu-toggle-text {
        display: inline;
        font-size: 13px;
        line-height: 1;
        font-weight: 700;
    }
    #header-inner .gorp3-menu-bars {
        display: block;
    }
    #header-inner .gorp3-menu-bars .icon-bar {
        width: 21px;
        height: 2px;
        margin: 0;
        background: #176e5c;
        border-radius: 2px;
    }
    #header-inner .gorp3-menu-bars .icon-bar + .icon-bar {
        margin-top: 4px;
    }
    /* The dropdown overlays content and never widens the page. */
    #header-inner #toolbar.navbar-collapse {
        position: absolute;
        z-index: 999;
        top: 100%;
        left: 0;
        right: 0;
        width: 100% !important;
        box-sizing: border-box;
        margin: 0 !important;
        padding: 8px 12px;
        background: #fff !important;
        border: 1px solid #dcefe9;
        border-radius: 0 0 12px 12px;
        box-shadow: 0 10px 24px rgba(0, 0, 0, .1);
        max-height: 68vh;
        overflow-y: auto;
    }
    #header-inner #toolbar .menu,
    #header-inner #toolbar .menu ul {
        display: block;
        margin: 0;
        padding: 0;
        list-style: none;
    }
    #header-inner #toolbar .menu li {
        display: block;
        float: none !important;
        position: static;
        line-height: 1.35;
        padding: 0;
        margin: 0;
        width: auto;
    }
    #header-inner #toolbar .menu li a {
        display: block;
        box-sizing: border-box;
        padding: 12px 14px;
        color: #2c3e50 !important;
        background: transparent;
        border: 0;
        border-radius: 8px;
        font-size: 14px;
        line-height: 1.4;
        text-decoration: none;
        white-space: normal;
    }
    #header-inner #toolbar .menu li.active > a,
    #header-inner #toolbar .menu li a:hover,
    #header-inner #toolbar .menu li a:focus {
        background: #e0f2f1;
        color: #126f5d !important;
    }
    #header-inner #toolbar .menu ul {
        position: static;
        float: none;
        width: auto;
        background: #f8fcfb;
        padding-left: 10px;
    }
    #header-inner #toolbar .menu ul a {
        padding: 9px 12px;
        font-size: 13px;
    }
    /* Top-bar: keep the existing language switcher, socials, accessibility module. */
    #top-float {
        float: none;
        width: 100%;
        min-width: 0;
        padding: 5px 0;
    }
    #top-inner {
        width: 100%;
        box-sizing: border-box;
        padding: 2px 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-wrap: wrap;
        gap: 4px 14px;
        text-align: center;
    }
    #topleft, #topright {
        float: none;
        max-width: 100%;
        margin: 0;
    }
    #top-inner .menu {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        gap: 6px 14px;
        margin: 0;
        padding: 0;
    }
    #top-inner .menu li {
        float: none;
        margin: 0 !important;
    }
    #top-inner a {
        color: #fff;
    }
}

@media (prefers-reduced-motion: reduce) {
    #header-inner .menu a {
        transition: none !important;
    }
}


/* ===============================================================
   GORP3 Header v1.1 - mobile overflow fix (2026-10-10)
   Keep the menu button inside the viewport even if an old theme
   computes an oversized nested navigation container.
   =============================================================== */
@media screen and (max-width: 767px) {
    #top-outer,
    #header-outer {
        display: block;
        width: 100vw !important;
        min-width: 0 !important;
        max-width: 100vw !important;
        box-sizing: border-box;
    }

    #top-float,
    #top-inner,
    #header-inner {
        width: 100vw !important;
        max-width: 100vw !important;
        min-width: 0 !important;
        box-sizing: border-box;
    }

    #header-outer {
        position: relative;
        z-index: 50;
    }

    #header-inner {
        position: relative;
        margin-left: 0 !important;
        margin-right: 0 !important;
        min-height: 72px;
        padding: 8px 12px !important;
        overflow: visible !important;
    }

    #header-inner #logo {
        max-width: calc(100vw - 125px);
        flex: 0 1 auto;
        min-width: 0;
    }

    /* Existing index.php/toolbar.php contain two nested #navigation IDs.
       Do not allow their intrinsic menu widths to push the button sideways. */
    #header-inner > #navigation,
    #header-inner > #navigation > #navigation {
        position: static !important;
        float: none !important;
        width: 0 !important;
        min-width: 0 !important;
        max-width: 0 !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
    }

    #header-inner button.gorp3-menu-toggle {
        position: absolute !important;
        top: 50%;
        right: 12px !important;
        left: auto !important;
        z-index: 1002;
        transform: translateY(-50%);
        display: flex !important;
        width: auto;
        max-width: calc(100vw - 100px);
        margin: 0 !important;
        white-space: nowrap;
    }

    #header-inner #toolbar.navbar-collapse {
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        z-index: 1001;
        box-sizing: border-box;
        margin: 0 !important;
        overflow-x: hidden;
    }

    /* Keep the original collapse states intact. */
    #header-inner #toolbar.collapse:not(.in):not(.collapsing) {
        display: none !important;
    }

    #top-inner {
        margin: 0 !important;
        padding: 6px 12px !important;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        overflow: visible;
    }

    #top-inner #topleft,
    #top-inner #topright {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        float: none !important;
        text-align: center;
        margin: 0 !important;
    }

    #top-inner .lang-inline,
    #top-inner .mod-languages ul,
    #top-inner ul.menu {
        display: flex !important;
        justify-content: center;
        align-items: center;
        flex-wrap: wrap;
        gap: 4px 14px;
        max-width: 100%;
        margin: 0 !important;
        padding: 0 !important;
    }

    #top-inner .lang-inline li,
    #top-inner .mod-languages li,
    #top-inner ul.menu li {
        float: none !important;
        list-style: none;
        margin: 0 !important;
    }
}

/* GORP3 Header v1.3: independent submenu buttons (mobile only).
 * Links keep their normal navigation behavior. No Bootstrap submenu needed.
 */
@media screen and (max-width: 767px) {
    #header-inner #toolbar .menu li.gorp3-submenu-item {
        display: flex !important;
        flex-wrap: wrap;
        align-items: stretch;
        position: relative !important;
        width: 100%;
    }
    #header-inner #toolbar .menu li.gorp3-submenu-item > a {
        flex: 1 1 0;
        min-width: 0;
        width: auto !important;
        padding-right: 6px;
    }
    #header-inner #toolbar .menu li.gorp3-submenu-item > button.gorp3-submenu-button {
        display: flex !important;
        align-items: center;
        justify-content: center;
        flex: 0 0 44px;
        width: 44px;
        min-height: 44px;
        box-sizing: border-box;
        padding: 0;
        margin: 0;
        border: 1px solid transparent;
        border-radius: 8px;
        background: transparent;
        color: #176e5c;
        cursor: pointer;
    }
    #header-inner #toolbar .menu li.gorp3-submenu-item > button.gorp3-submenu-button:hover,
    #header-inner #toolbar .menu li.gorp3-submenu-item > button.gorp3-submenu-button:focus {
        background: #e0f2f1;
        border-color: #b9ded4;
        outline: 2px solid #176e5c;
        outline-offset: -2px;
    }
    #header-inner #toolbar .gorp3-submenu-chevron {
        display: inline-block;
        width: 8px;
        height: 8px;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: translateY(-2px) rotate(45deg);
        transition: transform .18s ease;
    }
    #header-inner #toolbar .gorp3-submenu-open > .gorp3-submenu-button .gorp3-submenu-chevron {
        transform: translateY(2px) rotate(225deg);
    }
    /* Override the old theme's permanently visible nested lists. */
    #header-inner #toolbar .menu li.gorp3-submenu-item > ul {
        display: none !important;
        flex: 0 0 100%;
        order: 2;
        position: static !important;
        left: auto !important;
        top: auto !important;
        width: 100% !important;
        box-sizing: border-box;
        margin: 0 !important;
        padding: 3px 0 4px 10px !important;
        background: #f8fcfb !important;
        border-left: 2px solid #d8ede6;
    }
    #header-inner #toolbar .menu li.gorp3-submenu-open > ul {
        display: block !important;
    }
    #header-inner #toolbar .menu li.gorp3-submenu-item > ul > li {
        margin: 0 !important;
    }
}
@media (prefers-reduced-motion: reduce) {
    #header-inner #toolbar .gorp3-submenu-chevron { transition: none; }
}
@media screen and (min-width: 768px) {
    /* Submenu arrows are a mobile-only enhancement. */
    #header-inner #toolbar .gorp3-submenu-button { display: none !important; }
}
