/**
 * TrailLab Navigation Menu Styles
 * Styled according to design with red theme color
 */

:root {
    --primary-color: #D32F2F;
    --primary-hover: #B71C1C;
    --background-light: #F9FAFB;
    --text-dark: #111827;
    --border-light: #E5E7EB;
}

/* Navigation Container - Fixed with glass effect */
.traillab-navigation {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
    background-color: rgba(255, 255, 255, 0.8);
    border-bottom: 1px solid var(--border-light);
    transition: all 0.3s ease;
    min-height: 80px;
    overflow: visible;
}

/* Offset navigation when WP admin bar is visible (admin users only) */
body.admin-bar .traillab-navigation {
    top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar .traillab-navigation {
        top: 46px;
    }
}

.traillab-nav-container {
    max-width: 1280px; /* max-w-7xl */
    margin: 0 auto;
    padding: 0 1rem; /* px-4 */
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 80px; /* h-20 - fixed height */
    min-height: 80px;
    box-sizing: border-box;
}

@media (min-width: 640px) {
    .traillab-nav-container {
        padding: 0 1.5rem; /* sm:px-6 */
    }
}

@media (min-width: 1024px) {
    .traillab-nav-container {
        padding: 0 2rem; /* lg:px-8 */
    }
}

/* Logo Section - Keep existing logo, don't modify */
.traillab-nav-logo {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.5rem; /* gap-2 */
}

.traillab-logo-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-dark);
    transition: opacity 0.3s ease;
}

.traillab-logo-link:hover {
    opacity: 0.8;
}

.traillab-logo-img {
    display: block;
    max-height: 32px;
    max-width: 150px;
    width: auto;
    height: auto;
}

.traillab-logo-text {
    color: var(--text-dark);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Menu Section - Center */
.traillab-nav-menu {
    flex: 1 1 auto;
    display: none; /* Hidden on mobile */
    justify-content: center;
    align-items: center;
}

@media (min-width: 768px) {
    .traillab-nav-menu {
        display: flex;
    }
}

.traillab-menu-list {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 2rem; /* space-x-8 */
    align-items: center;
}

.traillab-menu-list li {
    margin: 0;
    padding: 0;
    position: relative;
}

.traillab-menu-list a {
    color: var(--text-dark);
    text-decoration: none;
    font-size: 0.875rem; /* text-sm */
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em; /* tracking-widest */
    padding: 0.5rem 0;
    position: relative;
    transition: color 0.3s ease;
    display: block;
}

.traillab-menu-list a:hover,
.traillab-menu-list a:focus {
    color: var(--primary-color);
}

/* Active menu item - red text with bottom border */
.traillab-menu-list .current-menu-item > a {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
}

/* Parent menu item with submenu */
.traillab-menu-list .has-submenu > a {
    position: relative;
}

.traillab-menu-list .has-submenu:hover > a {
    color: var(--primary-color);
}

.traillab-menu-list .has-submenu.current-menu-item > a {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
}

/* Active submenu item */
.traillab-menu-list .sub-menu .current-menu-item > a {
    background: var(--background-light);
    color: var(--primary-color);
    font-weight: 700;
}

/* Submenu */
.traillab-menu-list .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    border-radius: 0.5rem;
    margin-top: 0.5rem;
}

.traillab-menu-list li:hover > .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.traillab-menu-list .sub-menu li {
    margin: 0;
    padding: 0;
}

.traillab-menu-list .sub-menu a {
    padding: 0.75rem 1.25rem;
    display: block;
    text-transform: none;
    font-size: 0.875rem;
    border-bottom: none;
    font-weight: 600;
    letter-spacing: normal;
}

.traillab-menu-list .sub-menu a:hover {
    background: var(--background-light);
    color: var(--primary-color);
}

/* Actions Section - Right side */
.traillab-nav-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 1.5rem; /* gap-6 */
}

/* Cart Icon */
.traillab-nav-cart {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    color: var(--text-dark);
    text-decoration: none;
    transition: color 0.3s ease;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}

.traillab-nav-cart:hover {
    color: var(--primary-color);
}

.traillab-cart-icon {
    width: 24px;
    height: 24px;
}

.traillab-cart-count {
    position: absolute;
    top: -0.5rem; /* -top-2 */
    right: -0.5rem; /* -right-2 */
    background: var(--primary-color);
    color: #FFFFFF;
    font-size: 0.625rem; /* text-[10px] */
    font-weight: 700;
    padding: 0.125rem 0.375rem; /* px-1.5 py-0.5 */
    border-radius: 9999px; /* rounded-full */
    min-width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* User Avatar */
.traillab-user-dropdown-wrapper {
    position: relative;
}

.traillab-user-trigger {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
    height: 40px;
    width: 40px;
    flex-shrink: 0;
}

.traillab-user-trigger:hover {
    opacity: 0.8;
}

.traillab-user-trigger[aria-expanded="true"] {
    opacity: 0.8;
}

.traillab-user-avatar {
    width: 40px !important; /* Match button height */
    height: 40px !important; /* Match button height */
    border-radius: 50% !important;
    border: 2px solid var(--primary-color) !important;
    display: block !important;
    object-fit: cover !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden;
}

/* User Dropdown */
.traillab-user-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 280px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1001;
    border-radius: 0.5rem;
}

.traillab-user-dropdown-wrapper.active .traillab-user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.traillab-dropdown-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 0.9375rem;
    background: var(--background-light);
}

.traillab-dropdown-avatar img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--primary-color);
}

.traillab-dropdown-user-info {
    flex: 1;
}

.traillab-dropdown-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}

.traillab-dropdown-email {
    font-size: 0.75rem;
    color: #6B7280;
}

.traillab-dropdown-menu {
    list-style: none;
    margin: 0;
    padding: 0.625rem 0;
}

.traillab-dropdown-menu li {
    margin: 0;
    padding: 0;
}

.traillab-dropdown-menu a {
    display: block;
    padding: 0.75rem 1.25rem;
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.traillab-dropdown-menu a:hover {
    background: var(--background-light);
    color: var(--primary-color);
}

.traillab-dropdown-divider {
    height: 1px;
    background: var(--border-light);
    margin: 0.625rem 0;
}

/* Login/Register Buttons */
.traillab-nav-btn {
    padding: 0.5rem 1.25rem;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: all 0.3s ease;
    border-radius: 0.5rem;
    display: inline-block;
    border: 2px solid;
}

.traillab-nav-login {
    color: var(--text-dark);
    border-color: var(--text-dark);
    background: transparent;
}

.traillab-nav-login:hover {
    background: var(--text-dark);
    color: #FFFFFF;
}

.traillab-nav-register {
    color: #FFFFFF;
    border-color: var(--primary-color);
    background: var(--primary-color);
}

.traillab-nav-register:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* Mobile menu toggle (hamburger) - hidden on desktop */
.traillab-mobile-menu-toggle {
    display: none;
}

/* Responsive Design */
@media (max-width: 767px) {
    .traillab-navigation {
        min-height: 60px; /* match the 60px container + body offset on mobile */
    }

    .traillab-mobile-menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 5px;
        width: 44px;
        height: 44px;
        margin-right: -10px;
        padding: 0;
        background: none;
        border: none;
        border-radius: 0.5rem;
        cursor: pointer;
        color: var(--text-dark);
    }

    .traillab-mobile-menu-toggle:focus-visible {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }

    .traillab-navigation.menu-open .traillab-mobile-menu-toggle {
        background: rgba(0, 0, 0, 0.04);
    }

    .traillab-mobile-menu-bar {
        display: block;
        width: 22px;
        height: 2px;
        border-radius: 2px;
        background: currentColor;
        transition: transform 0.25s ease, opacity 0.2s ease;
    }

    .traillab-navigation.menu-open .traillab-mobile-menu-bar:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .traillab-navigation.menu-open .traillab-mobile-menu-bar:nth-child(2) {
        opacity: 0;
    }

    .traillab-navigation.menu-open .traillab-mobile-menu-bar:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    /* Dropdown panel */
    .traillab-navigation.menu-open .traillab-nav-menu {
        display: block;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        max-height: calc(100vh - 60px);
        max-height: calc(100dvh - 60px);
        overflow-y: auto;
        background: #FFFFFF;
        border-bottom: 1px solid var(--border-light);
        box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
        padding: 0.25rem 1rem 1rem;
    }

    .traillab-navigation.menu-open .traillab-menu-list {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }

    .traillab-navigation.menu-open .traillab-menu-list > li {
        border-bottom: 1px solid var(--border-light);
    }

    .traillab-navigation.menu-open .traillab-menu-list > li:last-child {
        border-bottom: none;
    }

    .traillab-navigation.menu-open .traillab-menu-list > li > a {
        padding: 0.9rem 0;
    }

    .traillab-navigation.menu-open .traillab-menu-list .current-menu-item > a,
    .traillab-navigation.menu-open .traillab-menu-list .has-submenu.current-menu-item > a {
        border-bottom: none;
    }

    /* Submenus are shown inline (no hover on touch devices) */
    .traillab-navigation.menu-open .traillab-menu-list .sub-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        min-width: 0;
        margin: 0 0 0.5rem;
        padding: 0 0 0 0.75rem;
        background: transparent;
        backdrop-filter: none;
        border: none;
        border-left: 2px solid var(--border-light);
        border-radius: 0;
        box-shadow: none;
    }

    .traillab-navigation.menu-open .traillab-menu-list .sub-menu a {
        padding: 0.55rem 0.5rem;
        border-radius: 0.375rem;
    }

    .traillab-nav-container {
        min-height: 60px;
        height: 60px;
        padding: 0 1rem;
    }
    
    .traillab-nav-menu {
        display: none; /* Hide menu on mobile */
    }
    
    .traillab-nav-actions {
        gap: 1rem;
    }
    
    .traillab-nav-btn {
        padding: 0.4375rem 0.875rem;
        font-size: 0.6875rem;
    }
    
    .traillab-user-dropdown {
        right: -1rem;
    }
}

/* Add padding to body to account for fixed header */
body:has(.traillab-navigation) {
    padding-top: 80px;
}

@media (max-width: 767px) {
    body:has(.traillab-navigation) {
        padding-top: 60px;
    }
}

