/* Base styling remains unchanged */
.third-level-header {
    width: 100%;
    background-color: #416ca3;
    height: 50px; 
    font-family: 'Ubuntu', sans-serif;
}

.nav-third-level {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 45px;
}

.nav-third-level ul {
    list-style-type: none;
    display: flex;
    padding: 0;
    margin: 0;
}

.nav-third-level ul li {
    position: relative;
    margin: 0 20px;
    padding: 4px 15px;
    display: flex;
    align-items: center;
    border: 1px solid transparent;
}

.nav-third-level ul li:hover {
    background-color: #345a84;
}

.nav-third-level ul li a {
    color: white;
    text-decoration: none;
    font-size: 20px;
}

/* Dropdown menu styling */
.nav-third-level ul li > ul.submenu-third {
    visibility: hidden; /* Make submenu initially invisible */
    opacity: 0; /* Start from fully transparent */
    transition: opacity 0.5s, visibility 0.5s; /* Transition for opacity and visibility */
    display: grid; /* Always use grid to maintain layout but control display with visibility */
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 100%;
    background-color: #345a84;
    width: 600px;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    padding: 10px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    border-radius: 5px;
    z-index: 1000;
}

.nav-third-level ul li:hover > ul.submenu-third {
    visibility: visible; /* Make submenu visible on hover */
    opacity: 1; /* Fade to fully opaque */
}

.nav-third-level ul li > ul.submenu-third li {
    padding: 10px;
    position: relative; /* Necessary for absolute positioning of pseudo-elements */
}

/* Underline styling for submenu links */
.nav-third-level ul li > ul.submenu-third li a {
    color: white;
    text-decoration: none;
    display: block;
    font-size: 16px;
    padding-bottom: 5px; /* Space between text and underline */
}

.nav-third-level ul li > ul.submenu-third li a::after {
    content: '';
    position: absolute;
    left: 5%;
    right: 5%;
    bottom: 0;
    border-bottom: 1px solid #777; /* Light grey border by default */
    transition: border-color 0.3s; /* Smooth transition for the border color change */
}

/* Change border color to white on hover */
.nav-third-level ul li > ul.submenu-third li a:hover::after {
    border-bottom: 1px solid white; /* White border on hover */
}

/* Media queries for responsive adjustments */
@media (max-width: 1100px) {
    body .page-layout {
        flex-direction: column;
        align-items: center;
    }
    body .page-sidebar-container {
        width: 60%;
        order: 1;
        padding: 0 20px;
        display: block;
        margin-top: 20px;
        margin-bottom: 0;
    }
    body .content-wrapper {
        width: 100%;
        order: 2;
        padding: 20px;
    }
    body .third-level-header, .nav-third-level, .nav-main {
        display: none;
    }
}

/* Hide the redundant blue nav bar on desktop — the white logo-bar nav handles everything */
@media (min-width: 769px) {
  .third-level-header {
    display: none !important;
  }
}
