/* Header Styles */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: #0b477c;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: fixed;
    top: 0px;
    right: 0px;
    left: 0px;
    z-index: 1000;
}

header .logo img {
    height: 47px; /* Adjust the height to make the logo smaller */
    max-width: 100%;
}

header nav {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    margin-left: -10px;
}

header nav ul {
    list-style: none;
    display: flex;
    gap: 15px;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

/* Prevent horizontal overflow from nav links */
header nav ul li a {
    white-space: nowrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-decoration: none;
    color: #fff;
    font-weight: bold;
}

/* Active link state applied via JS */
header nav ul li a.active {
    color: #62c5ff !important;
}

header nav ul li a:hover {
    color: #62c5ff;
}

@media (min-width: 990px) {
    .sidenavButton {
        display: none;
    }
}

@media (max-width: 989px) {
    .sidenavButton {
        font-size: 35px;
        cursor: pointer;
        padding: 10px;
        color: #fff;
        display: block;
        margin-left: auto;
    }

    header nav ul {
        display: none;
    }

    header .logo img {
        height: 40px;
        max-width: 200px;
    }
    
    header {
        padding: 10px 15px;
    }
}

@media (max-width: 768px) {
    header {
        padding: 8px 12px;
    }
    
    header .logo img {
        height: 35px;
        max-width: 180px;
    }
    
    .sidenavButton {
        font-size: 30px;
        padding: 8px;
    }
}

@media (max-width: 480px) {
    header {
        padding: 6px 10px;
    }
    
    header .logo img {
        height: 30px;
        max-width: 150px;
    }
    
    .sidenavButton {
        font-size: 25px;
        padding: 6px;
        /* Improve touch target size */
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Additional mobile optimizations */
@media (max-width: 768px) {
    header {
        /* Optimize for mobile performance */
        will-change: auto;
        transform: translateZ(0); /* Force hardware acceleration */
    }
    
    header nav ul li a {
        /* Improve touch targets */
        padding: 8px 12px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* Style the container of the dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

/* Initially hide the dropdown submenu */
.dropdown-content {
    position: absolute;
    top: 100%;
    left: -50px;
    background-color: #115da0;
    min-width: 200px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.25);
    z-index: 1001; /* Higher than header z-index */
    padding: 0;
    margin: 0;
    list-style: none;

    /* Instead of display: none, start hidden with opacity */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;

    border-radius: 4px;
    margin-top: 2px; /* Reduce gap between dropdown and parent */
}

/* Add a down arrow to dropdown links */
.dropdown > a::after {
    content: "\25BC";  /* Unicode character for a down arrow */
    font-size: 0.7em;    /* Adjust the size relative to the text */
    margin-left: 5px;    /* Space between the text and the arrow */
    vertical-align: middle; /* Ensure the arrow aligns nicely with the text */
}


/* Style for each dropdown item */
.dropdown-content li a {
    color: white;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.dropdown:hover .dropdown-content,
.dropdown-content:hover {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s; /* Show immediately on hover */
}

/* Add delay when leaving the dropdown area */
.dropdown-content {
  transition-delay: 0.2s; /* 200ms delay before hiding */
}

/* Remove delay when hovering */
.dropdown:hover .dropdown-content,
.dropdown-content:hover {
  transition-delay: 0s;
}

/* Change background on hover for dropdown items */
.dropdown-content li a:hover {
    background-color: #f1f1f1;
}

/* Show the dropdown when hovering over the parent list item */
.dropdown:hover .dropdown-content {
    display: block;
}

/* Responsive dropdown adjustments */
@media (max-width: 989px) {
    /* Hide dropdown on mobile since we use sidebar navigation */
    .dropdown-content {
        display: none !important;
    }
    
    /* Remove dropdown arrow on mobile */
    .dropdown > a::after {
        display: none;
    }
}

@media (min-width: 990px) and (max-width: 1200px) {
    /* Adjust dropdown positioning for medium screens */
    .dropdown-content {
        left: -30px;
        min-width: 180px;
        z-index: 1001;
    }
    
    header nav ul li a {
        font-size: 0.85rem;
    }
}

@media (min-width: 1201px) {
    /* Ensure proper positioning on larger screens */
    .dropdown-content {
        left: -50px;
        min-width: 200px;
        z-index: 1001;
    }
}
