/*
Theme Name: Tondy
Description: Full width + Multi-level menu with Top Bar, integrated CSS with dynamic defaults
Version: 2.0
Author: Your Name
Text Domain: tondy
*/

/* =========================
   Reset & Base Styles
========================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family, Arial, Helvetica, sans-serif);
    font-size: var(--body-font-size, 16px);
    line-height: 1.6;
    color: #333;
    background-color: #fff;
}

a {
    text-decoration: none;
    color: var(--primary-color, #28a745);
    transition: all 0.3s ease;
}

a:hover {
    color: var(--accent-color, #ffc107);
}

img {
    max-width: 100%;
    height: auto;
}

/* =========================
   Top Bar Styles
========================= */
.top-bar * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.top-bar {
    background-color: var(--topbar-bg-color, #2c3e50);
    color: var(--topbar-text-color, #ecf0f1);
    font-size: 14px;
    width: 100%;
    z-index: 100001;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    height: var(--topbar-height, 40px);
    line-height: var(--topbar-height, 40px);
    position: relative;
}

.top-bar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 40px;
    height: 100%;
}

.top-bar-left,
.top-bar-right {
    display: flex;
    align-items: center;
    height: 100%;
}

.top-bar-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    align-items: center;
    height: 100%;
}

.top-bar-menu li {
    position: relative;
    margin: 0;
    height: 100%;
    display: flex;
    align-items: center;
}

.top-bar-menu li a {
    display: flex;
    align-items: center;
    padding: 0 15px;
    color: inherit;
    text-decoration: none;
    font-weight: 500;
    height: 100%;
    transition: all 0.3s ease;
    white-space: nowrap;
    line-height: normal;
}

.top-bar-menu li a:hover {
    color: var(--topbar-hover-color, #3498db);
    background: rgba(255,255,255,0.1);
}

.top-bar-right .top-bar-menu {
    justify-content: flex-end;
}

/* =========================
   Header Styles
========================= */
.site-header {
    width: 100%;
    background-color: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative;
    z-index: 99999;
}

.site-branding-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px 40px;
    position: relative;
}

.header-left {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.header-right {
    flex: 0 0 auto;
}

.site-branding {
    display: flex;
    align-items: center;
}

.site-logo-link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
}

.site-title {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin: 0;
}

.site-description {
    font-size: 14px;
    color: #666;
    margin: 0;
}

/* 移动端汉堡按钮（桌面隐藏） */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #333;
    padding: 5px 10px;
    line-height: 1;
}

/* =========================
   搜索框样式增强 - 确保层级最高
========================= */
.header-search {
    position: relative;
    z-index: 100000 !important;
    overflow: visible !important;
    /* 添加平移 */
    transform: translateX(<?php echo intval(get_theme_mod('tondy_search_translate_x', 0)); ?>px);
    transition: transform 0.3s ease;
}

.search-form {
    display: flex;
    background: #fff;
    border-radius: 25px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    position: relative;
}

.search-form:focus-within {
    box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.2), 0 5px 20px rgba(0, 0, 0, 0.1) !important;
    border-color: var(--primary-color, #28a745) !important;
    position: relative !important;
    z-index: 100003 !important;
}

.search-field {
    flex: 1;
    border: none;
    outline: none;
    padding: 0 20px;
    font-size: 14px;
    background: transparent;
    width: 100%;
}

.search-field::placeholder {
    color: #999;
    font-style: italic;
}

.search-submit {
    background: var(--primary-color, #28a745);
    border: none;
    padding: 0 20px;
    cursor: pointer;
    color: white;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
}

.search-submit:hover {
    background: var(--accent-color, #ffc107);
}

.search-icon {
    font-size: 16px;
}

/* =========================
   搜索建议下拉框样式 - 简化版
========================= */
/* 搜索建议下拉框样式 - 跟随父级平移 */
.search-suggestions-container {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    background: white !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    border-top: none !important;
    border-radius: 0 0 <?php echo esc_attr(get_theme_mod('tondy_search_radius', 25)); ?>px <?php echo esc_attr(get_theme_mod('tondy_search_radius', 25)); ?>px !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25) !important;
    z-index: 100001 !important;
    max-height: 450px !important;
    overflow-y: auto !important;
    display: none !important;
    background: rgba(255, 255, 255, 0.99) !important;
    /* 关键：不重置变换，让子元素跟随父级变换 */
    transform: none !important;
}

.search-suggestions-container.show {
    display: block !important;
    animation: slideDownFadeIn 0.2s ease-out !important;
}

@keyframes slideDownFadeIn {
    from { 
        opacity: 0 !important; 
        transform: translateY(-10px) !important;
    }
    to { 
        opacity: 1 !important; 
        transform: translateY(0) !important;
    }
}

.search-suggestions-list {
    list-style: none !important;
    margin: 0 !important;
    padding: 8px 0 !important;
}

.search-suggestion-item {
    padding: 0 !important;
    margin: 0 !important;
    transition: background-color 0.2s ease !important;
}

.search-suggestion-item:hover {
    background-color: rgba(39, 174, 96, 0.08) !important;
}

.search-suggestion-item a {
    display: flex !important;
    align-items: center !important;
    padding: 12px 20px !important;
    text-decoration: none !important;
    color: #333 !important;
    transition: all 0.2s ease !important;
    width: 100% !important;
    position: relative !important;
    z-index: 1 !important;
}

.search-suggestion-item a:hover {
    background-color: rgba(39, 174, 96, 0.05) !important;
    padding-left: 25px !important;
}

.search-suggestion-thumbnail {
    width: 45px !important;
    height: 45px !important;
    object-fit: cover !important;
    border-radius: 6px !important;
    margin-right: 15px !important;
    flex-shrink: 0 !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    transition: transform 0.2s ease !important;
}

.search-suggestion-item:hover .search-suggestion-thumbnail {
    transform: scale(1.05) !important;
}

.search-suggestion-content {
    flex: 1 !important;
    min-width: 0 !important;
}

.search-suggestion-title {
    font-weight: 600 !important;
    font-size: 14px !important;
    margin-bottom: 4px !important;
    color: #222 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.search-suggestion-sku {
    font-size: 12px !important;
    color: #666 !important;
    margin-top: 2px !important;
}

.search-suggestion-no-results {
    padding: 30px 15px !important;
    text-align: center !important;
    color: #666 !important;
    font-size: 14px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 10px !important;
}

.search-suggestion-loading {
    padding: 30px 15px !important;
    text-align: center !important;
    color: #666 !important;
    font-size: 14px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 15px !important;
}

.search-suggestion-loading:after {
    content: '...' !important;
    animation: dots 1.5s steps(4, end) infinite !important;
    font-size: 24px !important;
    color: var(--primary-color, #28a745) !important;
}

@keyframes dots {
    0%, 20% { content: '.' !important; }
    40% { content: '..' !important; }
    60%, 100% { content: '...' !important; }
}

.search-suggestion-loading:before {
    content: '' !important;
    width: 40px !important;
    height: 40px !important;
    border: 3px solid rgba(0, 0, 0, 0.1) !important;
    border-top-color: var(--primary-color, #28a745) !important;
    border-radius: 50% !important;
    animation: spin 1s linear infinite !important;
}

@keyframes spin {
    to { transform: rotate(360deg) !important; }
}

.search-real-time-indicator {
    position: absolute !important;
    right: 15px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 8px !important;
    height: 8px !important;
    border-radius: 50% !important;
    background: var(--primary-color, #28a745) !important;
    animation: pulse 1.5s infinite !important;
    box-shadow: 0 0 0 2px rgba(39, 174, 96, 0.2) !important;
    pointer-events: none !important;
}

@keyframes pulse {
    0% { opacity: 1; transform: translateY(-50%) scale(1); }
    50% { opacity: 0.5; transform: translateY(-50%) scale(1.2); }
    100% { opacity: 1; transform: translateY(-50%) scale(1); }
}

.search-suggestions-container::-webkit-scrollbar {
    width: 6px !important;
}

.search-suggestions-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05) !important;
    border-radius: 3px !important;
}

.search-suggestions-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2) !important;
    border-radius: 3px !important;
}

.search-suggestions-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3) !important;
}

/* 确保搜索区域在所有其他元素之上 */
@media (min-width: 769px) {
    .main-navigation {
        z-index: 99999 !important;
    }
    
    .header-search {
        z-index: 100000 !important;
    }
    
    .search-suggestions-container {
        z-index: 100001 !important;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25) !important;
    }
}

@media (max-width: 768px) {
    .search-suggestions-container {
        position: fixed !important;
        top: 120px !important;
        left: 10px !important;
        right: 10px !important;
        z-index: 100001 !important;
        max-height: calc(100vh - 140px) !important;
        border-radius: 12px !important;
        box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25) !important;
    }
    
    .search-suggestion-item a {
        padding: 15px 20px !important;
    }
    
    .search-suggestion-thumbnail {
        width: 50px !important;
        height: 50px !important;
    }
}

/* =========================
   Header Icons Styles
========================= */
.header-icons {
    display: flex;
    gap: 20px;
    align-items: center;
}

.icon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    color: #333;
    text-decoration: none;
    transition: all 0.3s ease;
    padding: 5px;
    border-radius: 8px;
    min-width: 60px;
}

.icon-item:hover {
    color: var(--primary-color, #28a745);
    background-color: #f8f9fa;
    transform: translateY(-2px);
}

.icon-item img {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    object-fit: contain;
}

.icon-text {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
}

/* =========================
   Main Navigation Styles
========================= */
.main-navigation {
    width: 100%;
    background: #fff;
    position: relative;
    z-index: 99999 !important;
}

.main-navigation .nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.main-navigation .menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    align-items: center;
    height: 100%;
}

.main-navigation .menu > li {
    position: relative;
    margin: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
}

.main-navigation .menu > li > a {
    display: block;
    padding: 0 15px;
    color: #333;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
    white-space: nowrap;
    height: 100%;
    display: flex;
    align-items: center;
    position: relative;
}

.main-navigation .menu > li > a:hover {
    color: var(--primary-color, #28a745);
}

/* ========== Mega Menu 新布局（95/5 + 70/30） ========== */
.mega-panel-wrapper {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    width: 100%;
    pointer-events: none;
    z-index: 9998 !important;
    display: block;
}

.mega-panel {
    width: 100%;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 0 0 14px 14px;
    overflow: hidden;
    backdrop-filter: blur(20px) saturate(120%);
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(0,0,0,0.08);
    border-top: none;
    box-shadow: 0 15px 50px rgba(0,0,0,0.15);
    pointer-events: auto;
    
    transform: translateY(0) scaleY(0);
    transform-origin: top center;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 400px;
    max-height: 600px;
}

.mega-panel.open {
    transform: translateY(0) scaleY(1);
    opacity: 1;
}

/* 顶部区域（95%） */
.mega-top-section {
    flex: 0 0 95%;
    display: flex;
    padding: 25px;
    gap: 30px;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    height: calc(95% - 1px);
}

/* 左侧列（70%） - 子项目列 */
.mega-left-column {
    flex: 0 0 70%;
    display: flex;
    gap: 0;
    overflow: hidden;
}

/* 列样式 */
.mega-column {
    flex: 1;
    min-width: 0;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 列之间的分隔线 */
.mega-column-with-border {
    border-left: 1px solid rgba(0,0,0,0.1);
    padding-left: 30px;
}

/* 子项目标题 */
.mega-subitem {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mega-subitem-title {
    font-size: 16px;
    font-weight: 700;
    color: #222;
    text-decoration: none;
    transition: color 0.2s ease;
    padding: 4px 0;
    display: inline-block;
    width: fit-content;
    position: relative;
}

.mega-subitem-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color, #27ae60);
    transition: width 0.3s ease;
}

.mega-subitem-title:hover::after {
    width: 100%;
}

.mega-subitem-title:hover {
    color: var(--primary-color, #27ae60);
}

/* 产品列表 */
.mega-product-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 5px;
    max-height: 160px;
    overflow-y: auto;
    padding-right: 5px;
}

.mega-product-list::-webkit-scrollbar {
    width: 4px;
}

.mega-product-list::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.05);
    border-radius: 2px;
}

.mega-product-list::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 2px;
}

.mega-product-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.2);
}

.mega-product-item {
    padding: 2px 0;
}

.mega-product-item a {
    font-size: 13px;
    color: #666;
    text-decoration: none;
    transition: all 0.2s ease;
    display: block;
    padding: 6px 0 6px 12px;
    border-left: 2px solid transparent;
    line-height: 1.3;
}

.mega-product-item a:hover {
    color: var(--primary-color, #27ae60);
    border-left-color: var(--primary-color, #27ae60);
    padding-left: 15px;
}

/* 查看更多链接 */
.mega-view-more {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed rgba(0,0,0,0.1);
}

.mega-view-more a {
    font-size: 12px;
    color: #fff;
    text-decoration: none;
    transition: color 0.2s ease;
}

.mega-view-more a:hover {
    color: var(--primary-color, #27ae60);
}

/* 右侧列（30%） - 侧边栏 */
.mega-right-column {
    flex: 0 0 30%;
    display: flex;
    flex-direction: column;
    padding-left: 20px;
    border-left: 1px solid rgba(0,0,0,0.1);
}

.sidebar-featured {
    text-decoration: none;
    display: block;
    transition: transform 0.2s ease;
    height: 100%;
}

.sidebar-featured:hover {
    transform: translateY(-3px);
}

.sidebar-featured-image {
    width: 500px;
    height: 380px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 15px;
    background: #f5f5f7;
}

.sidebar-featured-title {
    font-size: 16px;
    font-weight: 600;
    color: #222;
    margin-bottom: 8px;
    line-height: 1.3;
}

.sidebar-featured-text {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

/* 底部区域（5%） */
.mega-bottom-section {
    flex: 0 0 5%;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0 25px 15px;
    height: 5%;
}

.mega-view-all-container {
    width: 100%;
    text-align: right;
}

.mega-view-all-link {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color, #27ae60);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: inline-block;
    background: rgba(39, 174, 96, 0.1);
}

.mega-view-all-link:hover {
    background: rgba(39, 174, 96, 0.2);
    transform: translateX(3px);
}

.main-navigation .menu > li.open > a {
    color: var(--primary-color, #27ae60);
}

.main-navigation .menu li ul {
    display: none !important;
}

.main-navigation .menu li:hover > ul {
    display: none !important;
}

.mega-placeholder {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 14px;
    width: 100%;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .mega-panel {
        border-radius: 0 0 10px 10px;
        max-height: 500px;
    }
    
    .mega-top-section {
        flex-direction: column;
        padding: 20px;
        gap: 20px;
    }
    
    .mega-left-column {
        flex: 0 0 auto;
        width: 100%;
        flex-wrap: wrap;
    }
    
    .mega-column {
        flex: 0 0 50%;
        min-width: 200px;
        padding: 10px 15px;
    }
    
    .mega-column-with-border {
        border-left: none;
        border-top: 1px solid rgba(0,0,0,0.1);
        padding-left: 15px;
        padding-top: 20px;
    }
    
    .mega-right-column {
        flex: 0 0 auto;
        width: 100%;
        border-left: none;
        border-top: 1px solid rgba(0,0,0,0.1);
        padding-left: 0;
        padding-top: 20px;
    }
    
    .sidebar-featured-image {
        height: 150px;
    }
    
    .mega-bottom-section {
        padding: 0 20px 15px;
    }
}

@media (max-width: 768px) {
    .mega-panel-wrapper {
        display: none !important;
    }
}

/* =========================
   移动端菜单切换
========================= */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #333;
    padding: 10px;
}

/* =========================
   Content Area
========================= */
.site-content {
    width: 100%;
    min-height: 60vh;
    padding: 40px;
}

/* =========================
   Responsive Design
========================= */
@media (max-width: 1024px) {
    .site-branding-nav {
        padding: 15px 20px;
    }
    
    .header-center {
        position: static;
        transform: none;
        flex: 1;
        margin: 0 20px;
    }
    
    .search-form {
        width: 100% !important;
    }
    
    .header-icons {
        gap: 15px;
    }
    
    .main-navigation .menu > li {
        margin: 0 15px;
    }
    
    .search-suggestions-container {
        max-height: 300px;
    }
}

/* 移动端布局重写 (max-width: 768px) */
@media (max-width: 768px) {
    /* 隐藏桌面元素 */
    .top-bar,
    .main-navigation {
        display: none !important;
    }

    /* 显示汉堡按钮 */
    .mobile-menu-toggle {
        display: block;
    }

    /* 头部flex换行，重新定义order */
    .site-branding-nav {
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        padding: 10px 20px;
    }

    .header-left {
        flex: 1 1 auto;
        width: auto;
        order: 1;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .header-search-global-container {
        flex: 0 0 100%;
        width: 100%;
        order: 2;
        margin: 10px 0 0 0;
        padding: 0;
    }

    .header-search .search-form {
        width: 100% !important;
        max-width: 100%;
    }

    .header-right {
        flex: 0 0 100%;
        width: 100%;
        order: 3;
        display: flex;
        justify-content: center;
        margin-top: 10px;
    }

    .header-icons {
        justify-content: center;
        gap: 15px;
        flex-wrap: wrap;
    }

    .icon-item {
        min-width: 50px;
    }

    .icon-text {
        font-size: 11px;
    }

    /* 确保搜索框不溢出 */
    .search-field {
        font-size: 14px;
    }

    /* =========================
       移动端抽屉菜单统一样式（顶栏与主导航完全一致）
    ========================= */
    .mobile-drawer ul,
    .mobile-drawer li {
        list-style: none !important;   /* 移除所有小圆圈 */
        margin: 0;
        padding: 0;
    }

    /* 强制每个菜单项占满宽度，自动换行 */
    .mobile-drawer li {
        width: 100%;
    }

    .mobile-drawer li a {
        width: 100%;
        white-space: normal;
        word-break: break-word;
    }

    /* 确保抽屉内容容器不溢出 */
    .mobile-drawer-inner,
    .mobile-drawer-content {
        width: 100%;
        overflow-x: hidden;
    }

    /* 顶级菜单项边框（仅一级菜单有底边线） */
    .mobile-drawer .top-bar-menu > li,
    .mobile-drawer .menu > li {
        border-bottom: 1px solid #f0f0f0;
    }

    .mobile-drawer .top-bar-menu > li:last-child,
    .mobile-drawer .menu > li:last-child {
        border-bottom: none;
    }

    /* 顶级菜单链接 */
    .mobile-drawer .top-bar-menu > li > a,
    .mobile-drawer .menu > li > a {
        padding: 15px 20px;
        color: #000000;                /* 悬停前统一黑色 */
        display: flex;
        align-items: center;
        justify-content: space-between;
        background: transparent;
        text-decoration: none;
        font-weight: normal;
    }

    /* 子菜单容器（统一背景和缩进） */
    .mobile-drawer .sub-menu {
        background: #f9f9f9;
        padding: 5px 0 5px 20px;
        border-top: 1px solid rgba(0,0,0,0.05);
        border-bottom: 1px solid rgba(0,0,0,0.05);
        display: none;                  /* 默认隐藏，由JS控制显示 */
    }

    .mobile-drawer .sub-menu.open {
        display: block;
    }

    /* 子菜单项 */
    .mobile-drawer .sub-menu li {
        border-bottom: 1px solid #eaeaea;
    }

    .mobile-drawer .sub-menu li:last-child {
        border-bottom: none;
    }

    /* 子菜单链接 */
    .mobile-drawer .sub-menu a {
        padding: 12px 20px;
        color: #000000;                 /* 子菜单默认黑色 */
        display: block;
        text-decoration: none;
        font-size: 14px;
        background: transparent;
    }

    /* 悬停样式（统一使用主题主色） */
    .mobile-drawer a:hover {
        color: var(--primary-color, #27ae60) !important;
        background-color: rgba(39, 174, 96, 0.05);
    }

    /* 当前展开的父菜单链接颜色也变为主色 */
    .mobile-drawer .menu-item-has-children.open > a {
        color: #238304 !important;
    }

    /* 下拉箭头（保留原有箭头样式） */
    .mobile-drawer .menu-item-has-children > a::after {
        content: '▾';
        float: right;
        font-size: 18px;
        transition: transform 0.2s;
        color: inherit;
    }

    .mobile-drawer .menu-item-has-children.open > a::after {
        transform: rotate(180deg);
    }

    /* 隐藏桌面端的Mega Panel（移动端不需要） */
    .mobile-drawer .mega-panel-wrapper {
        display: none !important;
    }

    /* 确保多个菜单列表无缝合并（无额外间距） */
    .mobile-drawer .top-bar-menu,
    .mobile-drawer .menu {
        margin: 0;
        padding: 0;
    }

    /* 抽屉菜单结构样式 */
    .mobile-drawer {
        position: fixed;
        top: 0;
        right: -100%;
        width: 100%;
        height: 100%;
        z-index: 1000000;
        transition: right 0.3s ease-in-out;
        visibility: hidden;
    }

    .mobile-drawer.open {
        right: 0;
        visibility: visible;
    }

    .mobile-drawer-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        opacity: 0;
        transition: opacity 0.3s ease;
        z-index: 1;
    }

    .mobile-drawer.open .mobile-drawer-overlay {
        opacity: 1;
    }

    .mobile-drawer-inner {
        position: absolute;
        top: 0;
        right: 0;
        width: 80%;
        max-width: 400px;
        height: 100%;
        background: #fff;
        box-shadow: -5px 0 25px rgba(0,0,0,0.2);
        z-index: 2;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
    }

    .mobile-drawer.open .mobile-drawer-inner {
        transform: translateX(0);
    }

    .mobile-drawer-header {
        padding: 20px;
        border-bottom: 1px solid #eee;
        display: flex;
        justify-content: flex-end;
    }

    .mobile-drawer-close {
        background: none;
        border: none;
        font-size: 32px;
        line-height: 1;
        cursor: pointer;
        color: #333;
    }

    .mobile-drawer-content {
        padding: 20px;
        flex: 1;
        overflow-y: auto;
    }

    /* 防止body滚动 */
    body.drawer-open {
        overflow: hidden;
    }

    /* ---------- 修复顶栏菜单在移动端一行多列的问题 ---------- */
    .mobile-drawer-topbar {
        display: block;
        width: 100%;
    }

    .mobile-drawer-topbar ul {
        display: block;
        width: 100%;
        margin-bottom: 10px;
    }

    .mobile-drawer-topbar ul:last-child {
        margin-bottom: 0;
    }

    .mobile-drawer .top-bar-menu {
        display: block !important;  /* 覆盖桌面端的flex，确保垂直排列 */
        width: 100%;
    }

    /* 确保子菜单面板样式与主导航完全一致 */
    .mobile-drawer .sub-menu {
        background: #f9f9f9;
        padding: 5px 0 5px 20px;
        border-top: 1px solid rgba(0,0,0,0.05);
        border-bottom: 1px solid rgba(0,0,0,0.05);
        display: none;
    }

    .mobile-drawer .sub-menu.open {
        display: block;
    }

    /* 针对GTranslate菜单的微调，使其与其他菜单项视觉统一 */
    .mobile-drawer .menu-item-gtranslate .sub-menu {
        padding-left: 20px;
    }

    .mobile-drawer .menu-item-gtranslate > a img {
        margin-right: 5px;
        vertical-align: middle;
    }
}

@media (max-width: 480px) {
    .top-bar-container {
        flex-direction: column;
        height: auto;
        padding: 10px 20px;
    }
    
    .top-bar-left,
    .top-bar-right {
        justify-content: center;
        text-align: center;
    }
    
    .header-icons {
        gap: 15px;
    }
    
    .icon-item {
        min-width: 50px;
    }
    
    .icon-text {
        font-size: 10px;
    }
    
    .search-form {
        width: 100% !important;
    }
    
    .search-field {
        font-size: 13px;
        padding: 0 12px;
    }
}

/* =========================
   Sticky Header
========================= */
.sticky-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.page .entry-title,
.page .entry-header,
.page .post-title,
.page .page-title {
    display: none !important;
}

.page .entry-content,
.page .post-content {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* =========================
   优化后的 Top Bar 下拉菜单样式
========================= */
.top-bar-menu li.menu-item-has-children {
    position: relative;
}

.top-bar-menu .sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--topbar-bg-color, #2c3e50);
    min-width: 180px;
    z-index: 1001;
    border-radius: 0 0 6px 6px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.top-bar-menu .sub-menu li {
    height: auto;
    display: block;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.top-bar-menu .sub-menu li:last-child {
    border-bottom: none;
}

.top-bar-menu .sub-menu li a {
    height: auto;
    padding: 12px 20px;
    white-space: nowrap;
    color: var(--topbar-text-color, #ecf0f1);
    background-color: transparent;
    display: block;
}

.top-bar-menu .sub-menu li a:hover {
    background-color: rgba(255, 255, 255, 0.15);
    color: var(--topbar-hover-color, #3498db);
}

@media (min-width: 769px) {
    .top-bar-menu li.menu-item-has-children:hover > .sub-menu {
        display: block !important;
    }
    
    .top-bar-menu li.menu-item-has-children > a::after {
        content: '▾';
        margin-left: 5px;
        font-size: 12px;
        opacity: 0.7;
    }
}

@media (max-width: 768px) {
    .top-bar-menu li.menu-item-has-children > a::after {
        content: '▾';
        margin-left: 5px;
        font-size: 12px;
        opacity: 0.7;
    }
    
    .top-bar-menu .sub-menu {
        position: static;
        display: none;
        background-color: rgba(255, 255, 255, 0.05);
        box-shadow: none;
        border: none;
        border-radius: 0;
    }
    
    .top-bar-menu .sub-menu.open {
        display: block;
    }
    
    .top-bar-menu li.top-bar-nav-open .sub-menu {
        display: block;
    }
}

/* =========================
   优化粘性导航位置
========================= */
.customize-previewing .sticky-header {
    top: 32px !important;
}

@media (max-width: 782px) {
    .customize-previewing .sticky-header {
        top: 46px !important;
    }
}

.sticky-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.admin-bar .sticky-header {
    top: 32px;
}

@media (max-width: 782px) {
    .admin-bar .sticky-header {
        top: 46px;
    }
}

.site-header-wrapper.scrolled .top-bar {
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.site-header-wrapper.scrolled .sticky-header {
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.video-placeholder {
    width: 100%;
    height: 100%;
    background: #333;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 24px;
}

.video-placeholder p {
    margin-top: 10px;
    font-size: 14px;
}

.site-content {
    overflow-x: visible !important;
}

/* ===== COOKIE BANNER 核心样式 ===== */
#cookieConsentBanner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    padding: 25px 30px;
    display: none;
    border-top: 3px solid #27ae60;
}

.cookie-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start; /* 改为顶部对齐 */
}

.cookie-text {
    flex: 1;
    min-width: 300px;
    padding-right: 25px;
}

.cookie-text h3 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 19px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.cookie-text h3 i {
    color: #27ae60;
    font-size: 20px;
}

.cookie-text p {
    color: #5d6d7e;
    font-size: 15px;
    margin-bottom: 12px;
    line-height: 1.6;
}

.cookie-warning {
    background-color: #fff8e6;
    border-left: 4px solid #f1c40f;
    padding: 12px 18px;
    margin-top: 12px;
    border-radius: 0 5px 5px 0;
    font-size: 14.5px;
}

.cookie-warning i {
    color: #f39c12;
    margin-right: 8px;
    font-size: 15px;
}

/* ===== 主要修改：按钮改为垂直排列 ===== */
.cookie-buttons {
    display: flex;
    flex-direction: column; /* 改为垂直排列 */
    gap: 16px; /* 垂直按钮之间的间距 */
    margin-top: 0; /* 移除顶部间距，因为我们使用垂直对齐 */
    width: 280px; /* 固定宽度确保按钮宽度一致 */
    flex-shrink: 0; /* 防止按钮区域被压缩 */
}

.cookie-btn {
    padding: 14px 20px;
    border-radius: 7px;
    font-weight: 600;
    font-size: 15.5px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    width: 100%; /* 按钮宽度占满容器 */
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px; /* 确保所有按钮高度一致 */
}

.cookie-btn-accept {
    background-color: #27ae60;
    color: white;
    box-shadow: 0 3px 8px rgba(39, 174, 96, 0.2);
    order: 1; /* 确保"接受所有"按钮在最上面 */
}

.cookie-btn-accept:hover {
    background-color: #219653;
    transform: translateY(-3px);
    box-shadow: 0 5px 12px rgba(39, 174, 96, 0.3);
}

.cookie-btn-settings {
    background-color: transparent;
    color: #5d6d7e;
    border: 2px solid #bdc3c7;
    order: 2; /* "设置"按钮在中间 */
}

.cookie-btn-settings:hover {
    border-color: #27ae60;
    color: #27ae60;
    background-color: rgba(39, 174, 96, 0.05);
    transform: translateY(-2px);
}

.cookie-btn-reject {
    background-color: transparent;
    color: #e74c3c;
    border: 2px solid #e74c3c;
    order: 3; /* "拒绝非必要"按钮在最下面 */
}

.cookie-btn-reject:hover {
    background-color: rgba(231, 76, 60, 0.05);
    transform: translateY(-2px);
}

/* 为EU和非EU按钮组设置相同样式 */
#euButtons, #nonEuButtons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

/* 详细设置面板 */
#cookieSettings {
    display: none;
    margin-top: 25px;
    padding: 25px;
    background-color: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.cookie-setting {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e8e8e8;
}

.cookie-setting:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.cookie-setting-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.cookie-setting-header h4 {
    color: #2c3e50;
    font-size: 17px;
    font-weight: 600;
}

.cookie-setting-toggle {
    position: relative;
    display: inline-block;
    width: 55px;
    height: 28px;
}

.cookie-setting-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.cookie-setting-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.cookie-setting-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .cookie-setting-slider {
    background-color: #27ae60;
}

input:checked + .cookie-setting-slider:before {
    transform: translateX(27px);
}

.cookie-setting-desc {
    font-size: 14.5px;
    color: #5d6d7e;
    line-height: 1.6;
    padding-right: 10px;
}

.setting-required {
    color: #27ae60;
    font-size: 13.5px;
    font-weight: 600;
    background-color: rgba(39, 174, 96, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 8px;
}

.save-settings-btn {
    background-color: #2c3e50;
    color: white;
    padding: 14px 35px;
    font-weight: 600;
    font-size: 16px;
    border-radius: 7px;
    box-shadow: 0 3px 8px rgba(44, 62, 80, 0.2);
    width: 100%;
    margin-top: 10px;
}

.save-settings-btn:hover {
    background-color: #1a252f;
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(44, 62, 80, 0.3);
}

/* 响应式设计 - 针对移动设备优化 */
@media (max-width: 992px) {
    .cookie-content {
        flex-direction: column;
        align-items: stretch;
    }
    
    .cookie-text {
        padding-right: 0;
        margin-bottom: 25px;
        min-width: 100%;
    }
    
    .cookie-buttons {
        width: 100%; /* 移动端按钮区域占满宽度 */
        margin-top: 10px;
    }
    
    .cookie-btn {
        width: 100%;
    }
}

/* 小屏幕手机优化 */
@media (max-width: 768px) {
    #cookieConsentBanner {
        padding: 20px 20px 25px;
    }
    
    .cookie-text h3 {
        font-size: 18px;
    }
    
    .cookie-text p {
        font-size: 14.5px;
    }
    
    .cookie-warning {
        font-size: 14px;
        padding: 10px 15px;
    }
    
    .cookie-btn {
        padding: 15px 18px;
        font-size: 15.5px;
        min-height: 50px; /* 移动端按钮高度稍大，便于点击 */
    }
    
    /* 移动端设置面板调整 */
    #cookieSettings {
        padding: 20px;
        margin-top: 20px;
    }
    
    .cookie-setting-header {
        flex-wrap: wrap;
    }
    
    .cookie-setting-header h4 {
        font-size: 16px;
        margin-bottom: 5px;
    }
}

/* 小屏幕手机优化 */
@media (max-width: 480px) {
    .cookie-buttons {
        gap: 12px; /* 小屏幕上减少垂直间距 */
    }
    
    .cookie-btn {
        padding: 14px 15px;
        font-size: 15px;
        min-height: 46px;
    }
    
    .save-settings-btn {
        padding: 15px 20px;
    }
}

/* 平板设备优化 */
@media (min-width: 769px) and (max-width: 1024px) {
    .cookie-content {
        max-width: 95%;
    }
    
    .cookie-buttons {
        width: 260px; /* 平板设备稍微减小按钮区域宽度 */
    }
}

/* 大屏幕桌面优化 */
@media (min-width: 1200px) {
    .cookie-buttons {
        width: 300px; /* 大屏幕上增加按钮区域宽度 */
    }
}

@media (max-width: 768px) {
    /* ===== 顶栏菜单强制垂直排列 ===== */
    .mobile-drawer .top-bar-menu {
        display: block !important;      /* 覆盖桌面端的flex */
        width: 100% !important;
        margin: 0;
        padding: 0;
    }

    .mobile-drawer .top-bar-menu li {
        display: block !important;      /* 每个li独立占一行 */
        width: 100% !important;
        float: none !important;
        clear: both !important;
        margin: 0;
        padding: 0;
        border-bottom: 1px solid rgba(0,0,0,0.05); /* 可选分隔线 */
    }

    /* 父菜单链接样式 */
    .mobile-drawer .top-bar-menu > li > a {
        display: block !important;
        width: 100% !important;
        padding: 15px 20px !important;
        box-sizing: border-box !important;
        white-space: normal !important;  /* 允许文字换行 */
        word-break: break-word !important;
        color: #000000; /* 默认黑色，可按需修改 */
        text-decoration: none;
        background: transparent;
        border-bottom: none;
    }

    /* 子菜单容器 */
    .mobile-drawer .top-bar-menu .sub-menu {
        display: none;                   /* 默认隐藏，由JS控制展开 */
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        background: #f9f9f9;            /* 浅灰背景，可自定义 */
        border-top: 1px solid rgba(0,0,0,0.05);
        border-bottom: 1px solid rgba(0,0,0,0.05);
        box-sizing: border-box !important;
    }

    .mobile-drawer .top-bar-menu .sub-menu li {
        border-bottom: 1px solid #eaeaea;
        padding: 0 !important;
        margin: 0 !important;
    }

    .mobile-drawer .top-bar-menu .sub-menu li:last-child {
        border-bottom: none;
    }

    .mobile-drawer .top-bar-menu .sub-menu a {
        display: block !important;
        width: 100% !important;
        padding: 12px 20px 12px 35px !important; /* 增加左缩进，区分层级 */
        box-sizing: border-box !important;
        color: #000000; /* 子菜单默认黑色 */
        text-decoration: none;
        font-size: 14px;
        background: transparent;
        white-space: normal !important;
        word-break: break-word !important;
    }

    /* 悬停样式（可选） */
    .mobile-drawer .top-bar-menu a:hover {
        color: var(--primary-color, #27ae60) !important;
        background-color: rgba(39, 174, 96, 0.05);
    }

    /* 当前展开的父菜单项高亮（与子菜单打开同步） */
    .mobile-drawer .top-bar-menu li.menu-item-has-children.open > a {
        color: #238304 !important;
    }

    /* 下拉箭头保留，但确保不影响布局 */
    .mobile-drawer .top-bar-menu li.menu-item-has-children > a::after {
        content: '▾';
        float: right;
        font-size: 18px;
        transition: transform 0.2s;
        color: inherit;
    }

    .mobile-drawer .top-bar-menu li.menu-item-has-children.open > a::after {
        transform: rotate(180deg);
    }
}