:root {
    --main: #2e3a40;
    --sub-main: #465a69;
    --sub-background: #fbaa29ff;
    --sub-background-2: #acb8de;
    --dim-white: #d8f1f1;
    --devide: #dee3e9;
    --background-color: #f1f4f7;
    --hint-color: #6b7280;

    --nav-height: 64px;
    --primary-color: var(--sub-background);
    --primary-active-color: var(--sub-background);
    --text-color: var(--main);
    --background-color: #fff;
    --hover-bg-color: #f8f9fa;
    --border-color: #eee;
    --dropdown-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    --mobile-breakpoint: 1047px;
}

.active {
    background: linear-gradient(90deg, #fbaa29, #ff7f00) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

/* Basic Reset/Defaults */
.nav-container *,
.mobile-nav * {
    box-sizing: border-box;
}

/* --- Base Nav Container --- */
.nav-container {
    display: flex;
    align-items: center;
    min-height: var(--nav-height);
    position: sticky; /* Make nav sticky */
    top: 0;
    z-index: 10;
    /* box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); */
    width: 100%; /* Ensure it takes full width */
}

/* General UL styling */
ul {
    padding: 0;
    margin: 0;
    list-style: none;
    display: flex; /* Keep for desktop */
    align-items: center;
}

/* Logo */
.nav-logo {
    margin-top: 0; /* Reset margin if alignment handled by flex */
    flex-shrink: 0;
    padding: 0 15px;
    display: flex; /* Align items vertically if needed */
    align-items: center;
}
.nav-logo a {
    text-decoration: none;
    color: inherit;
    display: inline-block;
}
.nav-logo img {
    height: 20px;
    vertical-align: middle;
}

/* Search Icon */
.search a,
.mobile-search a {
    color: var(--text-color);
    font-size: 18px;
    text-decoration: none;
    display: flex; /* Helps center icon if needed */
    align-items: center;
    padding: 10px; /* Clickable area */
}
.search {
    padding: 0 15px; /* Spacing */
}

/* --- Desktop Navigation --- */
.desktop-nav {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    height: var(--nav-height); /* Ensure consistent height */
}
.desktop-nav .nav-links-desktop {
    justify-content: center;
    flex-grow: 1;
    height: 100%; /* Fill height */
}

.nav-item {
    position: relative;
    margin: 0 5px;
    height: 100%; /* Ensure li fills height */
    display: flex; /* Align content vertically */
    align-items: center;
}

/* Desktop Links & Dropdown Toggles */
.desktop-nav .nav-link,
.desktop-nav .dropdown-toggle {
    display: flex;
    align-items: center;
    padding: 0 15px; /* Padding inside link, not on li */
    text-decoration: none;
    color: var(--text-color);
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s ease, background-color 0.2s ease;
    white-space: nowrap;
    height: 100%; /* Fill height */
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}
.desktop-nav .nav-link:hover,
.desktop-nav .dropdown-toggle:hover {
    color: var(--primary-color);
    background-color: var(--hover-bg-color);
}
/* Active link style (applied via JS style prop, but can add base style) */
/* .nav-link[aria-current="page"] { ... } */

/* Desktop Dropdown Menu */
.desktop-nav .dropdown-toggle .dropdown-icon {
    margin-left: 8px;
    font-size: 12px;
    transition: transform 0.2s ease;
}
.desktop-nav .dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: var(--dropdown-shadow);
    min-width: 200px; /* Slightly wider */
    z-index: 11;
    padding: 8px 0; /* Padding inside dropdown */
    flex-direction: column;
    align-items: stretch;
    max-height: calc(100vh - var(--nav-height) - 20px); /* Limit height */
    overflow-y: auto;
}

@supports (height: 100dvh) {
    .desktop-nav .dropdown-menu {
        max-height: calc(100dvh - var(--nav-height) - 20px);
    }
}

.desktop-nav .dropdown-menu.show {
    display: flex;
}

.desktop-nav .dropdown-item {
    width: 100%;
    margin: 0;
}
.desktop-nav .dropdown-item .nav-link, /* Target NavLink */
.desktop-nav .dropdown-item a {
    padding: 10px 20px; /* Consistent padding */
    color: var(--text-color);
    font-size: 13px;
    font-weight: 400;
    width: 100%;
    text-align: left;
    height: auto;
    display: block;
    white-space: normal;
    background: none; /* Ensure no inherited background */
    border: none; /* Ensure no inherited border */
}
.desktop-nav .dropdown-item .nav-link:hover,
.desktop-nav .dropdown-item a:hover {
    background-color: var(--hover-bg-color);
    color: var(--primary-active-color);
}

/* --- Mobile Navigation Trigger & Top Bar --- */

/* Hamburger button */
.hamburger {
    display: none; /* Hidden by default */
    position: absolute;
    top: 0;
    left: 10px;
    width: var(--nav-height); /* Square touch target */
    height: var(--nav-height);
    font-size: 15px;
    cursor: pointer;
    z-index: 10;
    color: var(--text-color);
    background: none; /* Reset button styles */
    border: none;
    padding: 0;
    /* display: flex is set in media query */
    align-items: center;
    justify-content: center;
}

.hamburger-icon {
    background: linear-gradient(90deg, #fbaa29, #ff7f00);
    padding: 11px 16px;
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.hamburger-icon svg {
    fill: white;
}

.mobile-search {
    display: none; /* Hidden by default */
    position: absolute;
    top: 0;
    right: 0;
    width: var(--nav-height);
    height: var(--nav-height);
    cursor: pointer;
    z-index: 12;
    /* display: flex is set in media query */
    align-items: center;
    justify-content: center;
}

.mobile-search i {
    font-size: 15px;
}

.mobile-logo {
    display: none; /* Hidden by default */
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 11;
    /* display: block is set in media query */
}
.mobile-logo img {
    height: 20px; /* Ensure consistent size */
}

/* --- Mobile Slide-out Panel --- */
.overlay {
    position: fixed;
    inset: 0; /* Covers entire viewport */
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 13;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s; /* Delay visibility change */
}
/* Corrected overlay visibility logic - place overlay sibling correctly or use :has */
/* Option 1: Place <div class="overlay"></div> immediately AFTER <div class="mobile-nav"> */
.mobile-nav.open + .overlay {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0s linear 0s;
}
/* Option 2: Using :has (less browser support) */
/* .overlay:has(+ .mobile-nav.open) { ... } */

.mobile-nav {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: -100%;
    width: min(85vw, 320px); /* Use min() for responsive width */
    height: 100vh; /* Full viewport height */
    background: #ffffff;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.2);
    transition: left 0.35s cubic-bezier(0.25, 0.1, 0.25, 1), visibility 0.35s;
    z-index: 14;
    overflow: hidden; /* Prevent content bleed during transition */
    visibility: hidden; /* Hide when closed */
}

@supports (height: 100dvh) {
    .mobile-nav {
        height: 100dvh; /* preferred */
    }
}

.mobile-nav.open {
    left: 0;
    visibility: visible;
    overflow-y: auto; /* Allow scrolling for content */
}

/* Mobile Nav Header */
.mobile-nav-head {
    flex-shrink: 0;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    border-bottom: 1px solid var(--border-color);
}
.mobile-nav-head .nav-logo img {
    height: 17px;
}
.mobile-nav-head .close-btn {
    font-size: 15px;
    cursor: pointer;
    color: #555;
    padding: 10px;
    background: none; /* Reset button */
    border: none;
}

/* Mobile Nav Links Area */
.mobile-nav .nav-links-mobile {
    flex-grow: 1;
    overflow-y: auto; /* Allow this section to scroll if needed */
    padding: 15px 0;
    /* These are UL defaults, but being explicit */
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%; /* Ensure UL takes width */
}

.mobile-nav .nav-item {
    margin: 0;
    border-bottom: 1px solid var(--border-color);
    /* Ensure li doesn't have strange positioning */
    position: static;
    display: block; /* Let it take full width for block children */
    width: 100%;
}
.mobile-nav .nav-item:last-child {
    border-bottom: none;
}

/* Mobile Links & Dropdown Toggles */
.mobile-nav .nav-link,
.mobile-nav .dropdown-toggle {
    display: flex; /* Use flex for layout */
    justify-content: space-between; /* Push icon to end */
    align-items: center;
    padding: 15px 20px;
    font-size: 14px;
    color: var(--text-color);
    width: 100%;
    text-align: left;
    height: auto;
    background: none; /* Reset button styles */
    border: none;
    cursor: pointer;
    font-family: inherit;
    /* Ensure no relative positioning here */
    position: static;
}
.mobile-nav .nav-link:hover,
.mobile-nav .dropdown-toggle:hover {
    background-color: var(--hover-bg-color);
    color: var(--primary-color);
}

/* == VERIFY THIS SECTION == */
/* Mobile Dropdown Menu */
.mobile-nav .dropdown-menu {
    /* CRITICAL: Ensure this is static */
    position: static;
    display: none; /* Hide by default */
    flex-direction: column; /* Set default flex direction */

    /* Reset any potential absolute positioning artifacts */
    left: auto;
    right: auto;
    top: auto;
    bottom: auto;
    transform: none;

    /* Reset margin/padding */
    padding: 0;
    margin: 0;

    /* Visual styles */
    width: 100%; /* Take full width of parent li */
    background-color: #fdfdfd; /* Slightly off-white */
    border: none;
    box-shadow: none;
    border-radius: 0;
    border-top: 1px solid var(--border-color); /* Separator from parent */
    max-height: none; /* Remove height limits */
    overflow-y: visible; /* Allow content to flow */
}

.mobile-nav .dropdown-menu.show {
    /* CRITICAL: Ensure this display property is winning */
    display: flex;
    /* flex-direction: column; is inherited */
}
/* == END VERIFY SECTION == */

.mobile-nav .dropdown-item {
    border-bottom: 1px dashed #e0e0e0; /* Dashed separator */
    /* Ensure li item itself isn't positioned */
    position: static;
    width: 100%;
    margin: 0;
}
.mobile-nav .dropdown-item:last-child {
    border-bottom: none;
}
.mobile-nav .dropdown-item a {
    /* Target NavLink */
    padding: 12px 20px 12px 35px; /* Indent */
    font-size: 13px; /* Was different from toggle, unifying */
    font-weight: 400;
    color: #555; /* Slightly muted color */
    display: block; /* Ensure takes full width */
    text-decoration: none; /* Remove underline */
    position: static; /* Ensure no relative positioning */
}
.mobile-nav .dropdown-item a:hover {
    background-color: var(--hover-bg-color);
    color: var(--primary-active-color);
}

/* === Mobile Navigation Footer Styling === */

/* Mobile Nav Footer Container */
.mobile-nav-foot {
    flex-shrink: 0; /* Prevent shrinking if parent is flex */
    min-height: 60px; /* Example height, replace var(--nav-height) */
    display: flex;
    flex-wrap: wrap; /* Allow buttons to wrap on very small screens */
    justify-content: center; /* Center buttons horizontally */
    align-items: center;
    gap: 0.75rem; /* Space between buttons */
    padding: 1rem; /* Generous padding */
    border-top: 1px solid #e9ecef; /* Light border, replace var(--border-color-light) */
    background-color: #ffffff; /* White background, replace var(--background-color-white) */
}

/* Mobile Nav Action Button Base Style */
.mobile-nav-action {
    display: inline-flex; /* Use inline-flex for better alignment */
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.25rem; /* Adjusted padding */
    margin: 0; /* Remove margin, rely on gap */
    text-decoration: none;
    font-size: 13px; /* Match base font size */
    font-weight: 600; /* Bold button text */
    border-radius: 6px; /* Consistent radius, replace var(--border-radius-std) */
    border: 1px solid transparent; /* Base border */
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease,
        color 0.2s ease, box-shadow 0.2s ease;
    text-align: center;
    flex-grow: 1; /* Allow buttons to grow evenly */
    flex-basis: 100px; /* Minimum starting basis */
    max-width: 180px; /* Prevent buttons getting too wide */
}

/* Style for the Primary Action (e.g., Sign Up) - Solid Brand Color */
/* Target Sign Up button */
.mobile-nav-action[href="/register"] {
    background-color: #fbaa29; /* Brand color */
    border-color: #fbaa29; /* Brand color */
    color: #ffffff; /* White text */
}

.mobile-nav-action[href="/register"]:hover {
    background-color: #e09a25; /* Darker brand color */
    border-color: #e09a25; /* Darker brand color */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.mobile-nav-action[href="/register"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(251, 170, 41, 0.3); /* Brand focus ring */
}

/* Style for the Secondary Action (e.g., Login) - Outline */
/* Target Login button */
.mobile-nav-action[href="/login"] {
    background-color: transparent;
    border-color: #fbaa29; /* Brand color border */
    color: #fbaa29; /* Brand color text */
}

.mobile-nav-action[href="/login"]:hover {
    background-color: #fef9f0; /* Very light brand tint background */
    border-color: #e09a25; /* Darker brand border */
    color: #e09a25; /* Darker brand color text */
}

.mobile-nav-action[href="/login"]:focus-visible {
    outline: none;
    border-color: #e09a25; /* Darker brand border on focus */
    box-shadow: 0 0 0 3px rgba(251, 170, 41, 0.3); /* Brand focus ring */
}

/* Disabled State Styles (Add if NavLinks can be disabled) */
/*
  .mobile-nav-action:disabled,
  .mobile-nav-action[aria-disabled="true"] {
      background-color: #e9ecef !important;
      border-color: #e9ecef !important;
      color: #adb5bd !important;
      cursor: not-allowed;
      opacity: 0.7;
      box-shadow: none;
  }
  */
/* --- Responsive Breakpoint --- */
@media screen and (max-width: 1047px) {
    /* Use variable: var(--mobile-breakpoint) if defined */
    .desktop-nav {
        display: none;
    }

    .hamburger,
    .mobile-search,
    .mobile-logo {
        display: flex; /* Use flex for centering icons */
    }
    .mobile-logo {
        display: block; /* Or flex if needed for alignment */
    }

    .nav-container {
        justify-content: center; /* Center mobile logo */
        position: relative; /* Ensure absolute positioning works within */
    }
}

/* --- Accessibility: Focus Visible --- */
/* Add a clear focus outline for keyboard users */
/* Target elements that are typically focusable */
.nav-container a:focus-visible,
.nav-container button:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25); /* Optional subtle glow */
    border-radius: 2px; /* Optional: match element radius */
}
/* Adjust specificity if needed */
