/* CSS Variables for easy customization */
:root {
    --twr-menu-bg: #ffffff; /* Menu background */
    --twr-menu-text: #333333; /* Text color */
    --twr-menu-hover: #007bff; /* Hover/accent color */
    --twr-menu-width: 250px; /* Mobile menu width */
    --twr-transition-time: 0.3s; /* Animation speed */
}

/* Basic Reset */
.twr-site-nav {
    position: relative;
}

.twr-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.twr-menu li {
    position: relative;
}

.twr-menu a {
    text-decoration: none;
    color: var(--twr-menu-text);
    display: block;
    padding: 10px 15px;
    transition: background var(--twr-transition-time), color var(--twr-transition-time);
}

.twr-menu a:hover,
.twr-menu a:focus,
.current-menu-ancestor > a {
    /* background: var(--twr-menu-hover); */
    /* color: #ffffff; */
    font-weight: 700;
}

.rd-navbar-fixed.rd-navbar{
    position: fixed;
    z-index: 2;
}

/* Desktop: Horizontal menu with dropdowns */
@media (min-width: 769px) {
    .twr-menu {
        display: flex;
        justify-content: space-evenly;
        height: 100%;
    }

    .rd-navbar-nav-wrap:not(.rd-navbar-nav-wrap:has(.row)) .twr-site-nav{
        height: 102px;
    }

    .twr-menu .sub-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        background: var(--twr-menu-bg);
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        min-width: 420px;
        z-index: 1000;
        text-align: left;
    }
    .twr-menu>li>.sub-menu{
        transform: translate(-47px, 1px);
    }
    .twr-menu>li>.sub-menu.overflow{
        transform: translate(47px, 1px);
    }
    .twr-menu>li>.sub-menu li{
        position: relative;
    }
    .twr-menu>li>.sub-menu .sub-menu {
        transform: translate(50%, 0);
        top: 0;
    }
    .twr-menu>li{
        flex: 1;
        text-align: center;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .twr-menu>li>a{
        font-size: 20px;
        display: inline-block;
    }

    .twr-menu li:hover > .sub-menu,
    .twr-menu li:focus-within > .sub-menu {
        display: block;
    }

    .twr-menu .sub-menu li {
        margin: 0;
        background: #e6e7e6;
        border-bottom: 1px solid #cecece;

    }
    .twr-menu > li > .sub-menu > li{
        height: 55px;
        font-size: 18px;
    }
    .twr-menu > li > .sub-menu > li a{
        padding: 12px 47px;
    }

    .twr-menu-toggle {
        display: none; /* Hide burger on desktop */
    }
}

/* Mobile: Burger and side menu */
@media (max-width: 768px) {
    .twr-menu {
        position: fixed;
        top: 0;
        left: calc(var(--twr-menu-width) * -1); /* Start off-screen */
        width: var(--twr-menu-width);
        height: 100vh;
        background: var(--twr-menu-bg);
        overflow-y: auto;
        transition: left var(--twr-transition-time) ease;
        z-index: 999;
        box-shadow: 2px 0 5px rgba(0,0,0,0.2);
        padding-top: 57px;
    }

    .twr-menu.twr-menu-open {
        left: 0; /* Slide in */
    }

    .twr-menu li {
        border-bottom: 1px solid #eee;
    }

    /* Submenu as accordion */
    .twr-menu .sub-menu {
        display: none;
        background: #f9f9f9;
        padding-left: 15px;
    }

    .twr-menu .menu-item-has-children > a::after {
        content: '\25BE'; /* Down arrow */
        float: right;
    }

    .twr-menu .menu-item-has-children.twr-open > a::after {
        content: '\25B4'; /* Up arrow */
    }

    .twr-menu .menu-item-has-children.twr-open > .sub-menu {
        display: block;
    }

    /* Burger Icon */
    .twr-menu-toggle {
        display: block;
        background: none;
        border: none;
        cursor: pointer;
        position: absolute;
        top: 15px;
        left: 15px; /* Adjust as needed */
        z-index: 1000;
        width: 30px;
        height: 25px;
    }

    .twr-burger-line {
        display: block;
        width: 100%;
        height: 3px;
        background: var(--twr-menu-text);
        position: absolute;
        left: 0;
        transition: all var(--twr-transition-time) ease;
    }

    .twr-burger-line:nth-child(1) { top: 0; }
    .twr-burger-line:nth-child(2) { top: 50%; transform: translateY(-50%); }
    .twr-burger-line:nth-child(3) { bottom: 0; }

    /* Transform to X */
    .twr-menu-toggle.twr-active .twr-burger-line:nth-child(1) {
        top: 50%;
        transform: translateY(-50%) rotate(45deg);
    }

    .twr-menu-toggle.twr-active .twr-burger-line:nth-child(2) {
        opacity: 0;
    }

    .twr-menu-toggle.twr-active .twr-burger-line:nth-child(3) {
        bottom: 50%;
        transform: translateY(50%) rotate(-45deg);
    }

    /* Prevent scroll when open */
    body.twr-menu-open {
        overflow: hidden;
    }

    /* Fix - delete after finished */
    .rd-navbar-mobile-panel .rd-navbar-brand {
        padding-left: 54px;
    }

}

/* Accessibility */
.twr-menu a:focus {
    /* outline: 2px solid var(--twr-menu-hover); */
}

.twr-menu-toggle:focus {
    /* outline: 2px solid var(--twr-menu-hover); */
}