/* === Mobile Header Styles (SVG Animation) ===
 * Credits: https://freefrontend.com/css-hamburger-menu-icons/
 * Intent: Keep the hamburger animation self-contained and reliable on mobile.
 */
.hamburger-menu {
    --color: #fff;
    /* Stroke color for the SVG paths. */
    width: 36px;
    height: 36px;
    padding: 0;
    margin: 0;
    outline: none;
    position: relative;
    border: none;
    background: none;
    cursor: pointer;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
    display: none;
    z-index: 1201;
}

/* Position the SVG relative to the clickable button box. */
.hamburger-menu svg {
    width: 64px;
    height: 48px;
    top: -6px;
    left: -14px;
    stroke: var(--color);
    stroke-width: 4px;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    display: block;
    position: absolute;
}

/* Animation logic: dasharray + dashoffset morph the paths into an “X”. */
.hamburger-menu svg path {
    transition: stroke-dasharray var(--duration, .85s) var(--easing, ease) var(--delay, 0s),
        stroke-dashoffset var(--duration, .85s) var(--easing, ease) var(--delay, 0s);
    stroke-dasharray: var(--array-1, 26px) var(--array-2, 100px);
    stroke-dashoffset: var(--offset, 126px);
    transform: translateZ(0);
}

.hamburger-menu svg path:nth-child(2) {
    --duration: .7s;
    --easing: ease-in;
    --offset: 100px;
    --array-2: 74px;
}

.hamburger-menu svg path:nth-child(3) {
    --offset: 133px;
    --array-2: 107px;
}

/* === Active State === */
.hamburger-menu.active svg path {
    --offset: 57px;
}

.hamburger-menu.active svg path:nth-child(1),
.hamburger-menu.active svg path:nth-child(3) {
    --delay: .15s;
    --easing: cubic-bezier(.2, .4, .2, 1.1);
}

.hamburger-menu.active svg path:nth-child(2) {
    --duration: .4s;
    --offset: 2px;
    --array-1: 1px;
}

.hamburger-menu.active svg path:nth-child(3) {
    --offset: 58px;
}

.mobile-menu-container {
    display: contents;
}

body.admin-bar .topbar {
    top: 52px;
}

/* === Mobile Menu Styles === */

@media (max-width: 1000px) {

    /* =========================================
        1. BASE SETUP (keep logo & hamburger on top)
     ========================================= */
    /* Keep logo + hamburger above the expanding menu panel. */
    .topbar {
        padding: 0 15px;
    }

    body.admin-bar .topbar {
        top: 66px;
    }

    .logo-area,
    .hamburger-menu {
        position: relative;
        z-index: 1200;
    }

    .hamburger-menu {
        display: flex;
    }

    /* =========================================
        2. THE CONTAINER (expand/collapse panel)
     ========================================= */
    .mobile-menu-container {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;

        /* Closed state */
        height: auto;
        max-height: 70px;
        overflow: hidden;

        /* Visually “invisible” when closed */
        background: transparent;
        border: none;
        box-shadow: none;
        border-radius: 20px;

        /* Layout: flex column */
        display: flex;
        flex-direction: column;
        align-items: center;

        transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
        box-sizing: border-box;

        /* IMPORTANT: top padding reserves space for the logo row. */
        padding-top: 90px;
    }

    /* Open state */
    .mobile-menu-container.active {
        max-height: 450px;
        /* Large enough to show the full nav + user area. */

        background: rgba(15, 23, 42, 0.98);
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5);

        /* Space between nav and login area */
        gap: 1.5rem;
    }

    /* =========================================
        3. THE LINKS
     ========================================= */
    .nav-links {
        /* Reset desktop styles to avoid inherited transforms/positioning on mobile. */
        position: static !important;
        transform: none !important;
        top: auto !important;
        left: auto !important;

        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        gap: 1rem;
        margin: 0;
        padding: 0;

        opacity: 0;
        transition: opacity 0.3s ease 0.1s;
        pointer-events: none;
    }

    .mobile-menu-container.active .nav-links {
        opacity: 1;
        pointer-events: all;
    }

    .nav-links li {
        list-style: none;
        text-align: center;
        width: 100%;
    }

    .nav-links a {
        display: block;
        font-size: 1.2rem;
        color: var(--text-muted);
        padding: 5px 0;
    }

    .nav-links a::after {
        display: none;
    }

    .nav-links a:hover {
        color: #fff;
    }

    /* =========================================
        4. LOGIN AREA
     ========================================= */
    .user-area {
        position: static;
        width: 100%;
        display: flex;
        justify-content: center;
        padding-bottom: 2rem;

        opacity: 0;
        transition: opacity 0.3s ease 0.2s;
    }

    .mobile-menu-container.active .user-area {
        opacity: 1;
    }

    .user-area .btn-login {
        font-size: 1.1rem;
        padding: 10px 40px;
        border: 1px solid var(--glass-border);
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.05);
        color: var(--text-main);
        display: inline-block;
    }

    /* Hide desktop-only UI in the mobile menu layout. */
    .user-dropdown-toggle,
    .user-menu,
    .user-menu-header {
        display: none !important;
    }
}

/* === Floating Dock Navigation === */
.topbar {
    /* Fixed "floating" header. z-index is managed so it stays above content, while
       the mobile menu layers (.mobile-menu-container) remain predictable. */
    position: fixed;
    top: 20px;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 90%;
    max-width: 1200px;
    height: 70px;
    border-radius: 20px;
    background: rgba(15, 23, 42, 0.85);

    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    padding: 0 20px;
    box-sizing: border-box;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
}

.logo-area {
    display: flex;
    align-items: center;
    height: 100%;
}

.logo-img {
    height: 50px;
    width: auto;
    object-fit: contain;
    transform: translateY(15px)
}

/* === Navigation "links" === */
.nav-links {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 2rem;
    z-index: 10;
}

.nav-links a {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-muted);
    position: relative;
    padding: 0.5rem 0;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-primary);
    transition: width 0.3s ease;
    box-shadow: 0 0 10px var(--accent-primary);
}

.nav-links a:hover {
    color: #fff;
}

.nav-links a:hover::after {
    width: 100%;
}

/* === User Area & Dropdown === */
.user-area {
    position: relative;
}

.user-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 12px;
    transition: background 0.2s ease;
}

.user-dropdown-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-avatar img {
    border-radius: 50%;
    border: 2px solid var(--accent-primary);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

/* User Menu Dropdown */
.user-menu {
    position: absolute;
    top: 120%;
    right: 0;
    width: 240px;
    background: rgba(15, 23, 42, 0.95);
    border-radius: 16px;
    padding: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    z-index: 1100;
}

.user-area:hover .user-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu-header {
    padding: 1.25rem;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.03), transparent);
    border-bottom: 1px solid var(--glass-border);
}

.user-menu-header strong {
    display: block;
    color: #fff;
    font-size: 1rem;
}

.user-menu-header small {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.user-menu-items {
    padding: 0.5rem;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.menu-item:hover {
    background: var(--glass-highlight);
    color: #fff;
}

.menu-item .icon {
    font-size: 1.1rem;
}

.menu-item.logout-link {
    color: var(--accent-danger);
}

.menu-item.logout-link:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* === WordPress Admin Bar === */

/* 1. Base container */
#wpadminbar {
    visibility: visible !important;
    /* Force visibility (some themes/plugins hide the bar). */
    background: rgba(15, 23, 42, 0.85) !important;
    /* Theme dark blue with transparency */
    backdrop-filter: blur(12px) !important;
    /* Glass effect */
    -webkit-backdrop-filter: blur(12px) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    /* Glass border */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    color: #94a3b8 !important;
    /* Muted text */
}

/* 2. Text & font */
#wpadminbar * {
    font-family: 'Inter', sans-serif !important;
    /* Match site typography */
    font-weight: 500 !important;
}

#wpadminbar .ab-item,
#wpadminbar a.ab-item,
#wpadminbar>#wp-toolbar span.ab-label,
#wpadminbar>#wp-toolbar span.noticon {
    color: #cbd5e1 !important;
    /* Brighter text for readability */
}

/* 3. Icons (WP logo, user icon, etc.) */
#wpadminbar .ab-icon:before,
#wpadminbar .ab-item:before {
    color: #6366f1 !important;
    /* Primary indigo */
}

/* 4. Hover effects (accent glow) */
#wpadminbar li:hover>.ab-item,
#wpadminbar .ab-item:focus,
#wpadminbar .ab-item:hover {
    background: rgba(99, 102, 241, 0.15) !important;
    /* Accent glow background */
    color: #fff !important;
    /* White text on hover */
}

/* 5. Dropdown menus (keep submenus in glass style) */
#wpadminbar .menupop .ab-sub-wrapper {
    background: rgba(15, 23, 42, 0.95) !important;
    /* Near-opaque dark */
    backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 0 0 12px 12px !important;
    /* Rounded bottom corners */
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5) !important;
}

/* 6. Admin bar search field (if enabled) */
#wpadminbar input[type="text"] {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
    border-radius: 6px !important;
    padding: 5px 10px !important;
}

#wpadminbar input[type="text"]:focus {
    border-color: #6366f1 !important;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.2) !important;
}

/* === FIX: WordPress Admin Bar Mobile (under 600px) === */
@media screen and (max-width: 600px) {
    #wpadminbar {
        position: fixed !important; /* Keep it pinned to the top */
        top: 0 !important;
        width: 100% !important;
        min-width: 100% !important; /* Prevent horizontal shrinking */
        z-index: 99999 !important; /* Always on top */
        
        /* Layout fixes for the content */
        display: block !important;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    /* Ensure the topbar doesn't sit under the admin bar on mobile. */
    body.admin-bar .topbar {
        top: 46px !important; /* WP bar is ~46px tall on mobile */
    }
    
    /* Optional: prevent horizontal scrolling if WP admin bar forces width */
    html, body {
        overflow-x: hidden;
    }
}