/* ============================================
   Header & Navigation Styles
   ============================================ */

/* 1. Site Header Base Styles */
.site-header {
    background: #ae0007;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    height: 70px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.site-header .site {
    max-width: 1480px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
    height: 100%;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
    position: relative;
    z-index: 1000;
}

/* 2. Logo Styles */
.site-logo {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.site-logo img {
    height: 90px;
    width: auto;
}

/* 3. Main Navigation */
.main-navigation {
    flex: 1;
    margin: 0 40px;
}

.nav-menu {
    display: flex;
    justify-content: center;
    gap: 15px;
    list-style: none;
}

.nav-menu > li {
    position: relative;
}

.nav-menu > li > a {
    color: #fff;
    padding: 25px 15px;
    display: block;
    font-size: 15px;
    transition: all 0.3s ease;
    text-decoration: none;
}

.nav-menu > li > a:hover {
    color: rgba(255,255,255,0.9);
    background: rgba(255,255,255,0.1);
}

/* 4. Mega Menu Styles */
.menu-dropdown {
    position: fixed;
    left: 0;
    right: 0;
    top: 70px;
    width: 100%;
    background: #fff;
    box-shadow: 0 3px 20px rgba(0,0,0,0.1);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 99;
}

.menu-item-has-children:hover .menu-dropdown {
    opacity: 1;
    visibility: visible;
}

.mega-menu-content {
    max-width: 1480px;
    margin: 0 auto;
    padding: 40px 24px;
}

/* 4.1. Simple Dropdown Menu (for About submenu) */
.menu-dropdown .submenu {
    list-style: none;
    padding: 8px 0;
    margin: 0;
    min-width: 200px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.menu-dropdown .submenu li {
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.2s ease;
}

.menu-dropdown .submenu li:last-child {
    border-bottom: none;
}

.menu-dropdown .submenu li:hover {
    background: linear-gradient(90deg, rgba(174, 0, 7, 0.05) 0%, rgba(174, 0, 7, 0.02) 100%);
}

.menu-dropdown .submenu li a {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    color: #333;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
    position: relative;
}

.menu-dropdown .submenu li a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #ae0007;
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.menu-dropdown .submenu li a:hover {
    color: #ae0007;
    padding-left: 24px;
    background: transparent;
}

.menu-dropdown .submenu li a:hover::before {
    transform: scaleY(1);
}

.menu-dropdown .submenu li a i {
    margin-right: 10px;
    font-size: 14px;
    opacity: 0.6;
    transition: all 0.3s ease;
}

.menu-dropdown .submenu li a:hover i {
    opacity: 1;
    transform: translateX(3px);
}

/* 4.2. Simple dropdown positioning (not mega menu) */
/* When menu-dropdown contains submenu but no mega-menu-content, use absolute positioning */
/* Modern browsers with :has() support */
.menu-item-has-children .menu-dropdown:not(:has(.mega-menu-content)) {
    position: absolute !important;
    left: 0 !important;
    right: auto !important;
    top: 100% !important;
    width: auto !important;
    min-width: 180px !important;
    padding: 8px 0 !important;
    margin-top: 0 !important;
}

/* Fallback: Target menu items that have submenu directly (About menu) */
.nav-menu > .menu-item-has-children:not(:has(.mega-menu-content)) .menu-dropdown {
    position: absolute !important;
    left: 0 !important;
    right: auto !important;
    top: 100% !important;
    width: auto !important;
    min-width: 180px !important;
    padding: 8px 0 !important;
    margin-top: 0 !important;
}

/* Ensure mega menu (with mega-menu-content) stays full width and fixed */
/* Products menu with mega-menu-content should remain fixed and full width */
.menu-dropdown:has(.mega-menu-content) {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
}

/* 5. Header Right Section */
.header-right {
    display: flex;
    align-items: center;
    gap: 25px;
    flex-shrink: 0;
    position: relative;
    z-index: 1000;
    visibility: visible;
}

/* 6. Language Switcher */
.wpml-ls ul {
    display: flex;
    gap: 15px;
    list-style: none;
}

.wpml-ls a {
    color: #fff;
    font-size: 14px;
    padding: 5px 8px;
    opacity: 0.8;
    transition: all 0.3s ease;
    text-decoration: none;
}

.wpml-ls a:hover {
    opacity: 1;
}

.wpml-ls-current-language a {
    opacity: 1;
    font-weight: 500;
}

/* 7. Phone Number */
#masthead-phone {
    color: #fff;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    visibility: visible;
    opacity: 1;
    z-index: 1000;
}

/* 8. Header Placeholder - Prevent layout shift */
#header-placeholder {
    min-height: 70px;
    position: relative;
    z-index: 1000;
}

/* 9. Hide main content until header is loaded */
body:not(.header-loaded) .site-main {
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;
}

body.header-loaded .site-main {
    visibility: visible;
    opacity: 1;
}

/* 10. Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    z-index: 1001;
    transition: all 0.3s ease;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    visibility: visible;
    opacity: 1;
}

.mobile-menu-toggle:hover {
    opacity: 0.8;
}

.mobile-menu-toggle .icon-bar {
    display: block;
    width: 25px;
    height: 3px;
    background: #fff;
    margin: 5px 0;
    transition: all 0.3s ease;
}

.mobile-menu-toggle.active .icon-bar:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.mobile-menu-toggle.active .icon-bar:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active .icon-bar:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* 11. Mobile Menu Overlay */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-menu-overlay.active {
    display: block;
    opacity: 1;
}

/* 12. Mobile Menu Panel */
.mobile-menu-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 400px;
    height: 100%;
    background: #fff;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.mobile-menu-panel.active {
    right: 0;
}

.mobile-menu-panel::-webkit-scrollbar {
    width: 6px;
}

.mobile-menu-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.mobile-menu-panel::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.mobile-menu-panel::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.mobile-menu-panel .mobile-menu-header {
    background: #ae0007;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.mobile-menu-panel .mobile-menu-header .mobile-logo {
    height: 50px;
    width: auto;
    filter: brightness(0) invert(1);
}

.mobile-menu-panel .mobile-menu-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    padding: 0;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: transform 0.3s ease;
    border-radius: 50%;
}

.mobile-menu-panel .mobile-menu-close:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

.mobile-menu-panel .mobile-menu-content {
    padding: 0;
    flex: 1;
    overflow-y: auto;
}

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

.mobile-menu-panel .mobile-nav-menu > li {
    border-bottom: 1px solid #f0f0f0;
}

.mobile-menu-panel .mobile-nav-menu > li > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    color: #333;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.mobile-menu-panel .mobile-nav-menu > li > a:active {
    background: #f8f9fa;
}

.mobile-menu-panel .mobile-nav-menu > li > a .menu-arrow {
    transition: transform 0.3s ease;
    color: #999;
    font-size: 12px;
}

.mobile-menu-panel .mobile-nav-menu > li.active > a {
    color: #ae0007;
    background: #f8f9fa;
}

.mobile-menu-panel .mobile-nav-menu > li.active > a .menu-arrow {
    transform: rotate(180deg);
    color: #ae0007;
}

.mobile-menu-panel .mobile-submenu {
    display: none;
    background: #f8f9fa;
    list-style: none;
    padding: 0;
    margin: 0;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 1000px;
    }
}

.mobile-menu-panel .mobile-nav-menu > li.active > .mobile-submenu {
    display: block;
}

.mobile-menu-panel .mobile-submenu li {
    border-bottom: 1px solid #e9ecef;
}

.mobile-menu-panel .mobile-submenu li:last-child {
    border-bottom: none;
}

.mobile-menu-panel .mobile-submenu li a {
    display: block;
    padding: 12px 20px 12px 40px;
    color: #666;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.3s ease;
}

.mobile-menu-panel .mobile-submenu li a:active {
    background: #e9ecef;
    color: #ae0007;
}

.mobile-menu-panel .mobile-menu-footer {
    padding: 20px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
    background: #fff;
}

.mobile-menu-panel .mobile-language-switcher {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.mobile-menu-panel .mobile-language-switcher a {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    text-align: center;
    transition: all 0.3s ease;
}

.mobile-menu-panel .mobile-language-switcher a:active {
    transform: scale(0.95);
}

.mobile-menu-panel .mobile-language-switcher a.active {
    background: #ae0007;
    color: #fff;
    border-color: #ae0007;
}

.mobile-menu-panel .mobile-phone {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #333;
    font-size: 14px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
}

.mobile-menu-panel .mobile-phone i {
    color: #ae0007;
    font-size: 16px;
}

/* ============================================
   Responsive Styles
   ============================================ */

/* Tablet and below */
@media (max-width: 1024px) {
    /* 防止页面横向滚动，消除右侧白色区块 */
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        width: 100% !important;
        box-sizing: border-box !important;
        position: relative !important;
    }
    
    /* 确保主要内容容器不超出视口 */
    .site-main,
    .site-content,
    main,
    article,
    section {
        max-width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    
    .site-header {
        height: 60px;
    }
    
    #header-placeholder {
        min-height: 60px;
    }
    
    .site-header .site {
        padding: 0 3px !important;
        flex-direction: row !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        position: relative !important;
        z-index: 1000 !important;
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }
    
    .site-logo {
        flex: 0 1 auto !important;
        flex-shrink: 1 !important;
        min-width: 0 !important;
        margin-right: 0 !important;
        max-width: 40% !important;
        overflow: hidden !important;
    }
    
    .site-logo img {
        height: 40px !important;
        width: auto;
        max-width: 100% !important;
        object-fit: contain !important;
    }
    
    .main-navigation {
        display: none !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 0 !important;
        min-width: 0 !important;
        max-width: 0 !important;
    }
    
    /* 使用更高优先级的选择器强制显示 */
    .site-header .mobile-menu-toggle,
    .header-right .mobile-menu-toggle,
    button.mobile-menu-toggle,
    #mobileMenuToggle,
    .mobile-menu-toggle {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        z-index: 1001 !important;
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        width: 30px !important;
        height: 30px !important;
        min-width: 30px !important;
        min-height: 30px !important;
        max-width: 30px !important;
        max-height: 30px !important;
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }
    
    .header-right {
        gap: 3px !important;
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        visibility: visible !important;
        position: relative !important;
        z-index: 1000 !important;
        /* 确保不溢出 - 进一步缩小 */
        max-width: 85px !important;
        min-width: 75px !important;
        overflow: visible !important;
        padding: 0 !important;
        margin: 0 !important;
        margin-left: auto !important;
        min-height: 40px !important;
    }
    
    #masthead-phone {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        z-index: 1000 !important;
        align-items: center;
        justify-content: center;
        gap: 0 !important;
        font-size: 0 !important;
        flex-shrink: 0 !important;
        width: 30px !important;
        max-width: 30px !important;
        min-width: 30px !important;
        padding: 0 !important;
        margin: 0 !important;
        height: 30px !important;
        min-height: 30px !important;
        max-height: 30px !important;
    }
    
    #masthead-phone span {
        display: none;
    }
    
    #masthead-phone i {
        font-size: 16px !important;
        color: #fff;
        flex-shrink: 0 !important;
    }
    
    .wpml-ls {
        display: none;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .site-header .site {
        flex-direction: row !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .site-header .site {
        padding: 0 10px !important;
        flex-direction: row !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
    }
    
    .site-logo img {
        height: 45px;
    }
    
    .header-right {
        gap: 10px;
        display: flex !important;
        flex-direction: row !important;
    }
    
    #masthead-phone {
        font-size: 11px;
        display: flex !important;
    }
    
    #masthead-phone i {
        font-size: 22px;
    }
    
    .mobile-menu-toggle {
        padding: 6px;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    #masthead-phone {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .mobile-menu-toggle .icon-bar {
        width: 22px;
        height: 2px;
        margin: 4px 0;
    }
}

/* Desktop - Hide mobile menu */
@media (min-width: 1025px) {
    .mobile-menu-toggle,
    .mobile-menu-overlay,
    .mobile-menu-panel {
        display: none !important;
    }
}

