﻿/*
 * WooCommerce Mega Menu Styles
 */

/* 1. Overlay and Main Container */
.wc-mega-menu-overlay {
    position: fixed;
    /* 修复 2: 将 top 设为 0，让它从浏览器顶部开始，依赖于用户主题的菜单结构来定位 */
    top: 48px; 
    left: 0;
    width: 100%;
    height: 100vh; /* 全屏高度 */
    /* 修复 4: 确保半透明效果 */
    background-color: rgba(0, 0, 0, 0.8); /* 半透明黑色背景 */
    z-index: 9999; /* Ensure it's above other content */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    box-sizing: border-box;
}

.wc-mega-menu-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

.wc-mega-menu-content {
    display: flex;
    width: 100%;
    /* 修复 2: 增加顶部内边距，为菜单留出空间。请根据您的菜单高度调整此值，例如 60px */
    padding-top: 0px; 
    margin: 0 auto;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.5); /* 内部内容区域使用白色半透明背景 */
    overflow: hidden;
}

/* 2. Left Panel (Level 1 Categories) */
.wc-mega-menu-left-panel {
    width: 20%;
    background-color: rgba(248, 248, 248, 0.5); /* 内部内容区域使用白色半透明背景 */
    padding: 20px 0;
    border-right: 1px solid #fff;
    overflow-y: auto;
    /* 修复 2: 调整高度以适应新的 padding-top */
    height: calc(100% - 58px); 
}

.wc-mega-menu-left-panel ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.wc-mega-menu-left-panel li a {
    display: block;
    padding: 15px 20px;
    text-decoration: none;
    color: #222;
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Hover/Active effect for Level 1 Category */
.wc-mega-menu-left-panel li:hover,
.wc-mega-menu-left-panel li.is-active {
    background-color: #fff; /* Highlight background */
    border-left: 4px solid #FF0030; /*   Accent color */
    margin-left: -4px;
}

.wc-mega-menu-left-panel li:hover a,
.wc-mega-menu-left-panel li.is-active a {
    color: #FF0030;
}

/* 3. Right Panel (Dynamic Content) */
.wc-mega-menu-right-panel {
    width: 80%;
    padding: 20px;
    background-color: #fff; /* 内部内容区域使用白色半透明背景 */
    overflow-y: auto;
    /* 修复 2: 调整高度以适应新的 padding-top */
    height: calc(100% - 60px); 
}

/* 4. Level 2 Tabs */
.wc-mega-menu-tabs {
    display: flex;
    border-bottom: 1px solid #FF0030;
    margin-bottom: 20px;
    overflow-x: auto;
    white-space: nowrap;
}

.wc-mega-menu-tab-button {
    background: none;
    border: none;
    padding: 5px 10px 15px 10px;
    cursor: pointer;
    font-size: 16px;
    color: #222;
    border-bottom: 2px solid transparent;
    transition: color 0.2s ease, border-bottom-color 0.2s ease;
    margin-right: 10px;
}

/* Hover/Active effect for Level 2 Tab */
.wc-mega-menu-tab-button:hover {
    color: #222;
}

.wc-mega-menu-tab-button.active {
    color: #FF0030;
    border-bottom-color: #FF0030;
    font-weight: bold;
}

/* 5. Tab Content (Product Grid) */
.wc-mega-menu-tab-content-wrapper {
    position: relative;
}

.wc-mega-menu-tab-content {
    display: none;
    padding: 10px 0;
}

.wc-mega-menu-tab-content.active {
    display: block;
}

.wc-mega-menu-product-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 columns for products */
    gap: 20px;
}

.wc-mega-menu-product-item {
    display: block;
    text-align: center;
    text-decoration: none;
    color: #222;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-radius: 4px;
    padding: 10px;
}

/* Hover effect for Product Item */
.wc-mega-menu-product-item:hover,
.wc-mega-menu-product-item.is-hovered {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
    color:#FF0030;
}

.product-image-wrapper {
    margin-bottom: 10px;
    overflow: hidden;
    border-radius: 4px;
    /* 修复 3: 调整图片尺寸为 160x160 */
    width: 160px;
    height: 160px;
    margin-left: auto;
    margin-right: auto;
}

.wc-mega-menu-product-item img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 确保图片覆盖整个 160x160 区域 */
    display: block;
    transition: transform 0.3s ease;
}

.wc-mega-menu-product-item:hover img {
    transform: scale(1.05);
}

.product-name {
    font-size: 14px;
    margin: 0;
    white-space: normal;
    word-break: break-word;
}

/* Loading and Error Messages */
.loading-placeholder, .error-message {
    text-align: center;
    padding: 50px;
    color: #999;
}
