.header {
    display: flex;
    align-items: center;
    padding: .5em 0;
    background-color: var(--Accent);
    height: 3em;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-sizing: border-box; /* This prevents padding from adding to width */
    width: 100%;
    overflow: visible; /* Allow children to overflow */
    box-shadow: 0 0 15px var(--Accent-dark); /* Adds soft shadow */
}

.header * {
    box-sizing: border-box; /* Apply box-sizing to all header children */
}

.header div {
    padding: .5em 0.25em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header a {
    text-decoration: none;
    text-transform: uppercase;
    color: var(--light);
    transition: color var(--transition-length);
}

.header a:hover {
    color: var(--Accent-dark);
}

.header a:active {
    color: var(--Accent-light);
}

.header img {
    height: 24px;
}

.header-logo {
    margin-left: 5em;
    margin-top: 2em;
    z-index: 1001; /* Ensure logo stays above other elements */
    flex: none;
    
}

.header-logo img {
    max-height: 70px;
    height: 70px;
    width: auto;
    filter: drop-shadow(0 0 15px var(--Accent-dark)); /* Adds soft shadow */
}

.header-nav {
    margin-left: 1em;
    display: flex;
    flex: 1;
    justify-content: center;
    gap: 0.5em;
}

/* Header Menu Styles */
.header-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 0;
    align-items: center;
}

.header-menu li {
    height: 3em;
    position: relative;
}

.header-menu > li > a {
    display: block;
    padding: 1em 1em;
    transition: all var(--transition-length);
    white-space: nowrap;
}

.header-menu > li > a:hover {
    color: var(--Accent-dark);
}

/* Header Submenu */
.header-menu .submenu {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--Accent-dark);
    width: 200px;
    display: none;
    z-index: 1000;
    overflow: visible;
}

.header-menu li:hover .submenu {
    display: block;
}

.header-menu .submenu li {
    height: auto;
    display: block;
    width: 100%;
}

.header-menu .submenu a {
    display: block;
    padding: 0.5em 1.2em;
    color: var(--Accent-light);
    font-size: 0.9em;
    transition: all var(--transition-length);
    white-space: normal; /* Allow text to wrap */
    word-wrap: break-word; /* Break long words if needed */
}

.header-menu .submenu a:hover {
    color: var(--light);
}

.header-lang {
    display: flex;
    flex: 0;
    align-items: center;
    gap: .25em;
    margin-right: var(--margin-edges);
}

.header-lang a {
    padding: 0.3em 0.6em;
    transition: all var(--transition-length);
    text-decoration: none;
}

.header-lang a:hover {
    color: var(--Accent-dark);
}

.header-lang a.active {
    display: none;
}

/* Hamburger Menu Button */
.hamburger-menu {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 30px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-right: 1em;
    z-index: 1002;
    user-select: none; /* Prevent text selection cursor */
}

.hamburger-menu span {
    display: block;
    height: 3px;
    width: 100%;
    background-color: var(--light);
    border-radius: 3px;
    transition: all 0.3s ease;
    transform-origin: center;
}

/* Hamburger animation when active */
.hamburger-menu.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.hamburger-menu.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

@media screen and (max-width: 1200px) {
    .header-logo {
        margin-left: .5em;
        margin-right: -2.5em;
    }
     .header-lang {
        margin-right: 1em;
    }
    .header-nav {
        margin-left: 0;
        gap: 0.25em;
    } 
}

/* Responsive layout */
@media screen and (max-width: 1050px) {
    .header {
        flex-wrap: nowrap;
        justify-content: space-between;
        padding: 0.5em 0;
        align-items: center;
    }

    .header-logo {
        margin-left: 0;
        margin-right: 0;
        order: 2; /* Put logo in the middle */
    }
     .header-lang {
        margin-right: 5em;
        margin-left: 0;
        order: 3; /* Keep language switcher on the right */
    }
    
    /* Show hamburger button on mobile */
    .hamburger-menu {
        display: flex;
        margin-right: 0;
        margin-left: 5em;
        order: 1; /* Put hamburger on the left */
    }
    
    div.header-nav {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        max-height: 100vh;
        overflow-y: auto;
        background-color: var(--Accent);
        transition: left 0.3s ease;
        z-index: 1002;
        padding-top: 3em;
        padding-bottom: 1em;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }
    
    .header-nav.active {
        left: 0;
    }

    /* Mobile Header Menu */
    .header-menu {
        flex-direction: column;
        width: 100%;
        padding: 1em 0;
        gap: 0;
    }

    .header-menu li {
        width: 100%;
        text-align: left;
        border-bottom: 1px solid var(--Accent-dark);
        height: auto;
    }

    .header-menu > li > a {
        padding: 1em 1.5em;
        display: block;
        width: 100%;
        border-bottom: none;
        position: relative;
        padding-right: 3em; /* Make space for the arrow */
    }

    .header-menu > li > a:hover {
        background-color: var(--Accent-dark);
        color: var(--light);
    }

    .header-menu .submenu {
        position: static;
        display: none;
        background-color: var(--Accent-dark);
        width: 100%;
        border-radius: 0;
        margin: 0;
        box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-in-out, padding 0.3s ease-in-out;
        padding: 0;
    }

    /* Disable hover on mobile - only use .active class */
    .header-menu li.active .submenu {
        display: block;
        max-height: 500px; /* Adjust based on your menu needs */
    }

    /* Add expand indicator as a separate clickable element */
    .header-menu > li > .submenu-toggle {
        position: absolute;
        right: 1em;
        top: 1em; /* Fixed position instead of centering */
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 10;
        user-select: none; /* Prevent text selection */
        -webkit-user-select: none; /* Safari */
        -moz-user-select: none; /* Firefox */
        -ms-user-select: none; /* IE/Edge */
    }

    .header-menu > li > .submenu-toggle::after {
        content: '';
        display: inline-block;
        width: 0;
        height: 0;
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
        border-top: 4px solid var(--light);
        transition: transform 0.3s ease;
    }

    .header-menu > li.active > .submenu-toggle::after {
        transform: rotate(180deg);
    }

    /* Hide the toggle for items without submenus */
    .header-menu > li:not(.has-submenu) > .submenu-toggle {
        display: none;
    }

    .header-menu .submenu a {
        padding: 0.8em 2.5em;
        font-size: 0.9em;
        border-bottom: 1px solid var(--Accent);
    }

    .header-menu .submenu a:hover {
        background-color: var(--Accent);
        color: var(--light);
    }
}

