/* General Header Styles */
.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #ffffff;
    padding: 10px 0;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    box-sizing: border-box;
    height: 100px;
    padding-left: 10%;
    padding-right: 10%;
}

/* Logo Box */
.logo-box {
    flex: 1;
}

/* Search Box */
.search-box {
    flex: 2;
    margin: 0 20px;
}

/* Search Input */
.search-box input[type="text"] {
    width: 100%;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-size: 1em;
}

/* Top Right Box */
.top-right-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
}

/* Header Links */
.header-links {
    display: flex;
    justify-content: flex-end;
    width: 100%;
}

.header-table {
    width: auto;
}

.header-table-cell {
    padding: 5px;
}

.header-table-cell a {
    color: #000000;
    text-decoration: none;
    font-weight: bold;
}

/* Welcome Message */
.welcome-message {
    color: #000000;
    text-align: left;
    align-self: flex-start;
    margin-top: 5px;
}

/* Auth Links */
.auth-links {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 5px;
}

.auth-link {
    color: #225522;
    text-decoration: none;
    font-weight: bold;
}

.auth-link:hover {
    color: #1b441a;
}

.separator {
    color: #000000;
    font-weight: bold;
}

/* Adjust logo size */
.logo {
    width: 150px;
    height: auto;
}

/* Navigation Bar */
nav {
    background-color: #B7D3A8;
    padding: 10px 0;
    text-align: left;
    margin-top: 100px;
    padding-left: 10%;
    padding-right: 10%;
}

nav .nav-content {
    display: flex;
    align-items: center;
}

nav a {
    color: #ffffff;
    margin: 0 15px;
    text-decoration: none;
    font-weight: bold;
    position: relative;
}

/* Categories Dropdown */
.categories {
    position: relative;
    display: inline-block;
}

.categories .dropdown-content {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 250px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
    left: 0;
    top: 100%;
}

.categories:hover .dropdown-content,
.categories .dropdown-toggle:focus + .dropdown-content {
    display: block;
}

/* Subcategory Dropdown */
.subcategory-dropdown {
    position: relative;
}

.subcategory-dropdown .sub-dropdown-content {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    background-color: #f9f9f9;
    min-width: 250px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 2;
}

.subcategory-dropdown:hover .sub-dropdown-content,
.subcategory-dropdown .sub-dropdown-content.show {
    display: block;
}

.sub-dropdown-content a {
    color: #225522;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
    white-space: nowrap;
}

.sub-dropdown-content a:hover {
    background-color: #ddd;
}

/* Active Link Styling */
nav a.active {
    background-color: #225522;
    color: #ffffff;
}

/* Add arrow indicator for categories with subcategories */
.subcategory-dropdown > a.main-category-link.has-subcategories::after {
    content: ' '; /* Right arrow */
    margin-left: 5px;
    font-size: 0.8em;
    color: #ffffff;
}

/* Mobile Styles */
@media (max-width: 768px) {
    .header-container,
    .top-right-box,
    .header-table {
        display: none; /* Hide the original header elements on mobile */
    }

    .mobile-header {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        background-color: #ffffff;
        box-sizing: border-box;
    }

    .mobile-header-top {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px;
        box-sizing: border-box;
    }

    .mobile-logo-container {
        flex: 1;
    }

    .mobile-logo {
        width: 100px; /* Smaller logo for mobile */
        height: auto;
        margin: 0; /* Remove all padding */
    }

    .mobile-search-container {
        flex: 3;
        display: flex;
        justify-content: flex-end;
    }

    .mobile-search-input {
        width: 100%;
        padding: 8px;
        border-radius: 4px;
        border: 1px solid #ddd;
    }

    .mobile-header-bottom {
        display: flex;
        justify-content: space-around;
        padding: 10px;
        background-color: #f9f9f9;
        box-sizing: border-box;
        position: relative;
    }

    .dropdown-content {
        display: none;
        position: absolute;
        background-color: #f9f9f9;
        width: 100%; /* Ensure full width on mobile */
        box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
        z-index: 1001; /* Ensure it's above other content */
        left: 0;
        padding: 0;
        top: 100%; /* Display below the trigger */
    }

    .dropdown-content.show {
        display: block;
    }

    .mobile-header-bottom .dropdown-toggle:hover + .dropdown-content,
    .mobile-header-bottom .dropdown-toggle:focus + .dropdown-content,
    .mobile-header-bottom .mobile-link:hover + .dropdown-content,
    .mobile-header-bottom .mobile-link:focus + .dropdown-content {
        display: block;
    }

    .mobile-link {
        color: #225522;
        text-decoration: none;
        font-weight: bold;
        flex: 1;
        text-align: center;
    }

    .mobile-link:hover {
        color: #1b441a;
    }

    /* Ensure the navigation content is pushed down */
    nav {
        margin-top: calc(100px + 20px + 10px); /* Account for header and padding */
    }

    /* Match Categories Dropdown with Account Dropdown on Mobile */
    .categories .dropdown-content {
        width: 80vw; /* Force full width on mobile */
        left: -10%; /* Align with the parent container's padding */
        right: 0;
        box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
        background-color: #f9f9f9;
        z-index: 1001; /* Ensure it's above other content */
        top: 100%; /* Display below the Categories link */
    }

    .categories .dropdown-content a {
        color: #225522;
        padding: 12px 16px;
        text-decoration: none;
        display: block;
        text-align: left;
        white-space: nowrap;
    }

    .categories .dropdown-content a:hover {
        background-color: #ddd;
    }
}

/* Hide the mobile header on larger screens */
@media (min-width: 769px) {
    .mobile-header {
        display: none;
    }
}
