/* Site Header */
.site-header {
    position: fixed;
    top: 0;
    left: 250px; /* Corresponds to left menu width */
    width: calc(100% - 250px); /* Subtract left menu width */
    height: 66px; /* Define height */
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
    z-index: 99;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

/* WordPress admin toolbar correction */
body.admin-bar .site-header {
    top: 32px; /* Add top spacing when admin toolbar is displayed */
}

@media screen and (max-width: 782px) {
    body.admin-bar .site-header {
        top: 46px; /* Higher admin toolbar on mobile */
    }
}

.site-header {
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 2px 15px rgba(0,0,0,0.1);
    position: fixed; /* Use fixed positioning to ensure it stays at top */
    top: 0;
    left: 250px; /* Corresponds to left menu width, ensure alignment with content area */
    z-index: 1000;
    width: calc(100% - 250px); /* Subtract left menu width, consistent with .main-wrapper */
    max-width: calc(100% - 250px);
    height: 66px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

div.header-content {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0.5rem 0 !important;
    max-width: 1410px !important;
    margin: 0 auto !important;
    position: relative !important;
    padding-left: 15px !important;
    padding-right: 15px !important;
    height: 66px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    background: transparent !important;
}

@media (max-width: 768px) {
    div.header-content {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        padding: 0 !important;
        height: auto !important;
        gap: 0 !important;
    }
}

.site-logo a {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 8px;
    padding: 5px 10px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.site-logo a:hover {
    text-decoration: none;
    color: inherit;
}

.site-logo-img {
    max-height: 50px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
    display: block;
}

.site-logo img {
    max-height: 50px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
    display: block;
}

.site-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
    margin: 0;
    text-decoration: none;
    display: inline-block;
    line-height: 1.2;
}

.search-form {
    position: absolute;
    left: 15px; /* Fix search box to align with left content area */
    top: 50%;
    transform: translateY(-50%); /* Only center vertically */
    width: 400px;
    z-index: 5;
}

.search-form-custom {
    position: relative;
    width: 100%;
    height: 50px;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 8px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid #f2f2f2;
}

.search-field {
    border: 1px solid #f2f2f2;
    padding: 0.5rem 1.5rem 0.5rem 1rem;
    border-radius: 8px;
    width: 400px; /* Adjust width */
    height: 50px;
    outline: none;
    transition: all 0.3s ease;
    font-size: 16px;
    box-sizing: border-box;
    background: transparent;
}

.search-field:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
    background: rgba(255, 255, 255, 0.9);
}

.search-submit {
    position: absolute;
    right: 0.5rem;
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.3s ease;
    height: 40px;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-submit:hover {
    color: #007bff;
}

.search-submit svg {
    width: 24px;
    height: 24px;
}

/* Navigation */
.main-nav {
    background: rgba(255, 255, 255, 0.85);
    padding: 0;
    margin: 0;
    position: relative;
    width: 300px; /* Keep consistent with right sidebar width */
    margin-left: auto;
    margin-right: 0; /* Ensure right alignment */
    text-align: right; /* Ensure content right aligned */
    display: flex;
    justify-content: flex-end;
    align-items: center;
    height: 100%;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
}

.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    align-items: center;
    justify-content: flex-end; /* Right align menu items */
    width: 100%; /* Ensure full width */
}

.nav-menu li {
    position: relative;
    margin: 0;
    display: inline-block; /* Ensure list items display correctly */
    flex-shrink: 0; /* Prevent menu items from being compressed */
}

.nav-menu a {
    display: block;
    padding: 15px 20px;
    color: #333;
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 17px;
    border-radius: 8px;
    margin: 2px;
    white-space: nowrap; /* Prevent text wrapping */
}

.nav-menu a:hover {
    background-color: #f8f9fa;
    color: #007bff;
}

/* Active state styles - Show blue text and light gray background with rounded corners when clicked */
.nav-menu .current-menu-item > a,
.nav-menu .current-menu-ancestor > a,
.nav-menu .current_page_item > a,
.nav-menu .current_page_parent > a,
.nav-menu .current_page_ancestor > a {
    background-color: #F8F9FA !important;
    color: #007bff !important;
    border-radius: 8px;
}

/* Remove .active class persistent styles, only keep current page active state */
.nav-menu .current-menu-item > a,
.nav-menu .current_page_item > a {
    background-color: #F8F9FA !important;
    color: #007bff !important;
    border-radius: 8px;
}

/* Click state (temporary click effect) */
.nav-menu a:active {
    background-color: #F8F9FA;
    color: #007bff;
    transform: translateY(1px);
}

.nav-menu li:hover > a {
    color: #007bff;
}

.nav-menu .sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0; /* Submenu right edge aligns with parent menu right edge */
    background: rgba(255, 255, 255, 0.85);
    min-width: 200px;
    width: auto; /* Cancel max-content, let content naturally determine width */
    z-index: 1000;
    box-shadow: 0 2px 15px rgba(0,0,0,0.15);
    flex-direction: column;
    padding: 0;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    text-align: left; /* Submenu items text left aligned */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Submenu upward triangle */
.nav-menu .sub-menu::before {
    content: "";
    position: absolute;
    top: -10px;
    right: 20px;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid rgba(255, 255, 255, 0.85);
    z-index: 1001;
    filter: drop-shadow(0 -2px 2px rgba(0,0,0,0.1));
}

/* Dynamically adjust triangle position to center align with parent menu item */
.nav-menu li:hover .sub-menu::before {
    right: calc(50% - 10px); /* 10px is half the triangle width */
    transform: translateX(50%);
}

.nav-menu li:hover .sub-menu {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Submenu display animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nav-menu .sub-menu li {
    display: block;
    width: 100%;
    text-align: left;
    margin: 0;
}

.nav-menu .sub-menu a {
    padding: 12px 20px;
    display: block;
    border-radius: 4px; /* Submenu also add rounded corners, but slightly smaller */
    color: #333;
    transition: all 0.3s ease;
    border-bottom: 1px solid #f8f9fa;
    margin: 2px 8px; /* Add left and right margins */
    text-align: left; /* Ensure text left aligned */
    white-space: nowrap; /* Prevent text wrapping */
}

.nav-menu .sub-menu a:last-child {
    border-bottom: none;
}

.nav-menu .sub-menu a:hover {
    background: #f2f2f2;
    color: #007bff;
}

/* Submenu active state */
.nav-menu .sub-menu .current-menu-item > a,
.nav-menu .sub-menu .current_page_item > a,
.nav-menu .sub-menu .active > a {
    background-color: #f2f2f2 !important;
    color: #007bff !important;
    border-radius: 4px;
}

.nav-menu .menu-item-has-children {
    position: relative;
}

.nav-menu .menu-item-has-children > a::after {
    content: '∨';
    font-size: 16px;
    margin-left: 5px;
    opacity: 0.7;
}

.nav-menu .menu-item-has-children:hover > a::after {
    content: '∧';
    font-size: 16px;
    opacity: 1;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
}

.mobile-left-toggle,
.mobile-top-toggle {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: #333;
    font-size: 1.2rem;
}

.mobile-left-toggle:hover,
.mobile-top-toggle:hover {
    color: #007bff;
}

/* Mobile Menu Styles */
.mobile-left-menu,
.mobile-top-menu {
    position: fixed;
    top: 0;
    width: 280px;
    height: 100vh;
    background: #3F4257;
    z-index: 1001;
    overflow-y: auto;
    transition: transform 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.3);
}

.mobile-left-menu {
    left: 0;
    transform: translateX(-100%);
}

.mobile-top-menu {
    right: 0;
    transform: translateX(100%);
}

.mobile-left-menu.active {
    transform: translateX(0);
    display: block;
}

.mobile-top-menu.active {
    transform: translateX(0);
    display: block;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: none; /* Remove bottom border */
    background: none; /* Remove background color */
    color: #ffffff;
}

/* Blue vertical line style */
.blue-line {
    display: inline-block;
    width: 4px;
    height: 18px;
    background-color: #1E90FF;
    margin-right: 8px;
    border-radius: 2px;
    vertical-align: middle;
}

.menu-title {
    font-size: 17px;
    font-weight: 500;
    color: #ffffff;
    padding-left: 0; /* Remove default left padding */
    display: flex;
    align-items: center;
}

/* Left menu title indent one character */
.mobile-left-menu .menu-title {
    padding-left: 0.5rem;
}

/* Top menu title indent (move right one character) */
.mobile-top-menu .menu-title {
    padding-left: 1rem;
}

.close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #ffffff;
    padding: 0.5rem;
}

.mobile-menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mobile-menu-list li {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

/* Ensure menu items with submenus have fixed positioning */
.mobile-menu-list li.menu-item-has-children {
    position: relative;
}

.mobile-menu-list a {
    display: block;
    padding: 15px 20px 15px 2rem;
    color: #ffffff;
    text-decoration: none;
    transition: background-color 0.3s ease;
    font-size: 17px;
    position: relative; /* Add positioning context */
    min-height: 24px; /* Ensure sufficient height even with little content to accommodate expand button */
}

.mobile-menu-list a:hover {
    background: #5A5E7D;
    color: #ffffff;
}

/* Mobile menu active state */
.mobile-menu-list .current-menu-item > a,
.mobile-menu-list .current-menu-ancestor > a,
.mobile-menu-list .current_page_item > a,
.mobile-menu-list .current_page_parent > a,
.mobile-menu-list .current_page_ancestor > a {
    background: #5A5E7D !important;
    color: white !important;
}

.mobile-menu-list .sub-menu {
    display: none;
    background: rgba(0, 0, 0, 0.2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.mobile-menu-list .sub-menu.show {
    display: block;
}

.mobile-menu-list .sub-menu li {
    border-bottom: none;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.mobile-menu-list .sub-menu a {
    padding-left: 3rem;
    font-size: 17px;
    color: rgba(255, 255, 255, 0.9);
}

.mobile-menu-list .sub-menu a:hover {
    background: #5A5E7D;
}

.mobile-expand-btn {
    position: absolute;
    right: 10px;
    top: 15px; /* Fixed top position aligned with primary category */
    transform: none; /* Remove vertical centering effect */
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    z-index: 2; /* Increase layer level */
    transition: background-color 0.3s ease;
    font-family: Arial, sans-serif;
    font-weight: bold;
    margin-right: 10px;
}

.mobile-expand-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.mobile-expand-btn.active {
    transform: none;
}

.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.mobile-overlay.active {
    display: block;
}

/* Mobile Responsive */
/* Mobile site logo style */
.mobile-site-logo {
    display: none;
}

/* Mobile responsive design */
@media (max-width: 768px) {
    /* Mobile top navigation position adjustment */
    .site-header {
        left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important; /* Allow height to adapt to two-row design */
        padding: 0 !important; /* Ensure no padding */
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important; /* Add shadow */
        position: fixed !important; /* Ensure fixed positioning */
        top: 0 !important; /* Fix at top */
        background: rgba(255, 255, 255, 0.85) !important; /* Set white background */
        z-index: 1000 !important; /* Ensure sufficiently high layer level */
        margin-bottom: 30px !important; /* Add bottom spacing */
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.3) !important;
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 20px) !important; /* 增加安全区域底部内边距 */
    }
    
    /* Adjust top row layout */
    .header-content {
        display: flex !important;
        flex-direction: column !important;
        padding: 0 !important; /* Remove all padding */
        height: auto !important;
        margin: 0 !important; /* Remove margins */
        width: 100% !important; /* Width 100% */
        background: transparent !important; /* Transparent background */
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) !important; /* Add shadow effect */
        gap: 0 !important; /* Remove gaps */
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 20px) !important; /* 增加安全区域底部内边距 */
    }
    
    .header-top-row {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        padding: 10px 0 !important; /* Remove left and right padding */
        background: transparent !important; /* Transparent background */
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 20px) !important; /* 增加安全区域底部内边距 */
    }
    
    /* Mobile logo style adjustment */
    .mobile-site-logo {
        display: block !important;
        margin-left: 10px !important; /* Only add slight left margin to logo */
    }
    
    /* Menu button right align */
    .mobile-menu-toggle {
        display: flex !important;
        gap: 10px !important;
    }
    
    /* Mobile display logo */
    .mobile-site-logo {
        display: block;
    }
    
    .mobile-site-logo a {
        display: flex;
        align-items: center;
        text-decoration: none;
        color: #333;
        background: rgba(255, 255, 255, 0.85);
        border-radius: 8px;
        padding: 5px 10px;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.3);
    }
    
    .mobile-site-logo img {
        max-height: 40px;
        width: auto;
    }
    
    .mobile-site-logo .site-title {
        font-size: 1.3rem;
        margin: 0;
        color: #333;
    }
    
    /* Search box placed in second row */
    .search-form {
        position: relative !important;
        left: auto !important;
        top: auto !important;
        transform: none !important;
        width: 100% !important;
        margin: 0 auto !important; /* Center horizontally */
        z-index: 5 !important;
        padding: 0 15px !important; /* Add left and right padding */
        background-color: #fff !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        order: 2 !important; /* Ensure search box in second row */
        flex: 1 !important; /* Occupy remaining space */
        height: auto !important;
        min-height: 45px !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        margin-bottom: calc(env(safe-area-inset-bottom, 0px) + 30px) !important; /* 增加安全区域底部内边距 */
    }
    
    .search-form-custom {
        width: 100% !important;
        height: 45px !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        position: relative !important;
        background: rgba(255, 255, 255, 0.85) !important;
        border-radius: 8px !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
    }
    
    .search-field {
        width: 100% !important;
        max-width: 100% !important;
        height: 45px !important;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
        border-left: none !important;
        border-right: none !important;
        border-radius: 0 !important;
        background: transparent !important;
        padding: 0 40px 0 15px !important;
        box-sizing: border-box !important;
        display: block !important;
        font-size: 16px !important;
    }
    
    .search-submit {
        right: 10px;
        height: 45px; /* Match search box height */
    }
    
    /* Hide standard navigation bar */
    .main-nav {
        display: none !important;
    }
    
    .mobile-left-menu,
    .mobile-top-menu {
        display: block;
        padding-bottom: calc(env(safe-area-inset-bottom, 30px) + 60px); /* 为移动端菜单添加更多底部内边距以适配Microsoft Edge */
    }
}

/* Mobile special handling of search box */
@media (max-width: 768px) {
    /* Search box special styles */
    .search-field {
        font-size: 16px;
    }
    
    /* Ensure search box container visible */
    .search-form {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        width: calc(100% - 30px) !important; /* Adjust width, subtract 15px left and right margins */
        z-index: 5 !important;
        margin: 0 15px !important; /* Add 15px left and right margins */
        padding: 0 !important;
        box-sizing: border-box !important;
        background-color: #fff !important;
        height: auto !important;
        min-height: 45px !important;
    }
    
    .search-form-custom {
        position: relative !important;
        width: 100% !important;
        height: 45px !important;
        margin: 10px 0 !important; /* Add top and bottom margins */
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        max-width: 500px !important; /* Limit maximum width */
        margin-left: auto !important; /* Center horizontally */
        margin-right: auto !important; /* Center horizontally */
        border: 2px solid #007bff !important; /* Add obvious blue outline */
        border-radius: 8px !important; /* Rounded corners */
        background: rgba(255, 255, 255, 0.85) !important; /* Background */
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
    }
    
    .search-field {
        width: 100% !important;
        max-width: 100% !important;
        height: 45px !important;
        border: none !important; /* Remove internal borders */
        border-radius: 8px !important; /* Rounded corners */
        background: transparent !important;
        padding: 0 40px 0 15px !important;
        box-sizing: border-box !important;
        display: block !important;
        font-size: 16px !important;
        visibility: visible !important;
        opacity: 1 !important;
        outline: none !important;
    }
    
    .search-submit {
        position: absolute !important;
        right: 5px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        height: 30px !important;
        width: 30px !important;
        background: none !important;
        border: none !important;
        display: flex !important; /* Change to flex layout */
        align-items: center !important; /* Vertical center */
        justify-content: center !important; /* Horizontal center */
        visibility: visible !important; /* Ensure visible */
        opacity: 1 !important; /* Ensure opaque */
        z-index: 10 !important; /* Increase layer level */
        padding: 0 !important; /* Remove padding */
        color: #6c757d !important; /* Add color consistent with desktop */
        cursor: pointer !important; /* Add hand cursor */
    }
    
    .search-submit svg {
        width: 20px !important;
        height: 20px !important;
        display: block !important; /* Force display */
    }
}