/* 通用下拉菜单样式 - 整合优化版 */

:root {
    --dropdown-bg: #fff;
    --dropdown-shadow: 0 8px 24px rgba(0,0,0,0.12);
    --dropdown-border-radius: 8px;
    --dropdown-primary-color: #ff3333;
    --dropdown-text-color: #1a1a1a;
    --dropdown-desc-color: #666;
    --dropdown-border-color: #eee;
    --dropdown-hover-bg: #f0f2f5;
    --dropdown-transition: all 0.3s ease;
}

/* 基础菜单容器 - 使用自定义类名避免Bootstrap冲突 */
.navbar-nav .nav-item.custom-dropdown-menu,
.navbar-nav .nav-item.products-menu {
    position: relative !important;
}

/* 下拉面板基础样式 - 使用自定义类名避免Bootstrap冲突 */
.dropdown-panel,
.products-panel {
    display: none !important;
    position: absolute !important;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--dropdown-bg);
    border-radius: var(--dropdown-border-radius);
    box-shadow: var(--dropdown-shadow);
    padding: 24px;
    z-index: 1000;
    margin-top: 8px;
    opacity: 0;
    transition: var(--dropdown-transition);
}

/* 面板宽度设置 - 固定宽度 */
.products-panel { 
    width: 800px; 
}
.dropdown-panel { 
    width: 400px; 
}

/* 面板内容处理 */
.dropdown-panel,
.products-panel {
    white-space: normal;
    overflow: visible;
}

.dropdown-category,
.product-category {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* 透明连接区域 - 使用自定义类名避免Bootstrap冲突 */
.custom-dropdown-menu::after,
.products-menu::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: 20px;
    background: transparent;
}

/* Hover效果 - 使用自定义类名避免Bootstrap冲突 */
.custom-dropdown-menu:hover .dropdown-panel,
.dropdown-panel:hover {
    display: block !important;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.products-menu:hover .products-panel,
.products-panel:hover {
    display: flex !important;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 加载进度条 - 使用自定义类名避免Bootstrap冲突 */
.dropdown-panel::before,
.products-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(to right, var(--dropdown-primary-color), var(--dropdown-primary-color));
    transform-origin: center;
    animation: loadingProgress 0.2s ease forwards;
}

@keyframes loadingProgress {
    0% { width: 0; left: 50%; }
    50% { width: 50%; left: 25%; }
    100% { width: 100%; left: 0; }
}

/* 链接hover效果 - 使用自定义类名避免Bootstrap冲突 */
.navbar-nav .nav-item.custom-dropdown-menu:hover .nav-link,
.navbar-nav .nav-item.products-menu:hover .nav-link {
    color: var(--dropdown-primary-color) !important;
}

/* 菜单项动画 */
.dropdown-item,
.product-item {
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInUp 0.3s ease forwards;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 动画延迟设置 */
.dropdown-category:nth-child(1) .dropdown-item:nth-child(1) { animation-delay: 0.1s; }
.dropdown-category:nth-child(1) .dropdown-item:nth-child(2) { animation-delay: 0.2s; }
.dropdown-category:nth-child(1) .dropdown-item:nth-child(3) { animation-delay: 0.3s; }
.dropdown-category:nth-child(1) .dropdown-item:nth-child(4) { animation-delay: 0.4s; }

.product-category:nth-child(1) .product-item:nth-child(1) { animation-delay: 0.1s; }
.product-category:nth-child(1) .product-item:nth-child(2) { animation-delay: 0.2s; }
.product-category:nth-child(1) .product-item:nth-child(3) { animation-delay: 0.3s; }
.product-category:nth-child(2) .product-item:nth-child(1) { animation-delay: 0.2s; }
.product-category:nth-child(2) .product-item:nth-child(2) { animation-delay: 0.3s; }
.product-category:nth-child(3) .product-item:nth-child(1) { animation-delay: 0.3s; }
.product-category:nth-child(3) .product-item:nth-child(2) { animation-delay: 0.4s; }
.product-category:nth-child(3) .product-item:nth-child(3) { animation-delay: 0.5s; }

/* 分类容器 */
.dropdown-category,
.product-category {
    flex: 1;
    padding: 0 16px;
}

.dropdown-category:not(:last-child),
.product-category:not(:last-child) {
    border-right: 1px solid var(--dropdown-border-color);
}

/* 分类标题 */
.category-title {
    color: var(--dropdown-desc-color);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
    text-transform: uppercase;
}

/* 菜单列表 */
.dropdown-list,
.product-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* 菜单项 */
.dropdown-item,
.product-item {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px dashed var(--dropdown-border-color);
}

.dropdown-item:last-child,
.product-item:last-child {
    border-bottom: none;
}

/* 菜单链接 */
.dropdown-link,
.product-link {
    color: var(--dropdown-text-color);
    text-decoration: none;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 4px;
    transition: var(--dropdown-transition);
    display: flex;
    align-items: center;
    position: relative;
}

.dropdown-link:hover,
.product-link:hover {
    background: var(--dropdown-hover-bg);
    color: var(--dropdown-primary-color);
}

/* 菜单项hover效果 - 只保留标题背景，去除整体背景 */
.dropdown-item:hover,
.product-item:hover {
    background: transparent;
}

.dropdown-item:hover .dropdown-link,
.product-item:hover .product-link {
    background: var(--dropdown-hover-bg);
    border-radius: 4px;
}

/* 图标样式 */
.dropdown-link i,
.product-link i {
    margin-right: 8px;
    color: var(--dropdown-primary-color);
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

/* 描述文字 */
.dropdown-desc,
.product-desc {
    margin: 4px 0 0 36px;
    font-size: 12px;
    color: var(--dropdown-desc-color);
    line-height: 1.5;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* 移动端样式 */
@media (max-width: 991.98px) {
    .custom-dropdown-menu,
    .products-menu {
        position: static;
        width: 100%;
    }

    .dropdown-panel,
    .products-panel {
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        width: 100% !important;
        box-shadow: none;
        margin: 0 !important;
        padding: 15px;
        background: #f8f9fa;
        border-radius: var(--dropdown-border-radius);
        transform: none;
        display: none !important;
        opacity: 1;
        transition: var(--dropdown-transition);
        white-space: normal;
        flex-direction: column;
        z-index: 1000;
        max-height: calc(100vh - 120px) !important;
        overflow-y: scroll !important;
        overflow-x: hidden !important;
        /* 强制显示滚动条 - 即使内容较少也显示 */
        scrollbar-width: thin !important;
        scrollbar-color: rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.1) !important;
        /* 确保内容区域正确计算高度 */
        min-height: 200px !important;
    }

    .custom-dropdown-menu:hover .dropdown-panel,
    .products-menu:hover .products-panel {
        display: none;
    }

    .dropdown-panel.show,
    .products-panel.show {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        height: auto !important;
        max-height: calc(100vh - 120px) !important;
        overflow-y: scroll !important;
        overflow-x: hidden !important;
        /* 强制显示滚动条 - 即使内容较少也显示 */
        scrollbar-width: thin !important;
        scrollbar-color: rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.1) !important;
        /* 确保内容区域正确计算高度 */
        min-height: 200px !important;
        animation: slideDown 0.3s ease forwards;
    }
    
    /* 确保收起状态下完全隐藏 */
    .dropdown-panel:not(.show),
    .products-panel:not(.show) {
        display: none !important;
        animation: none;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        height: 0 !important;
        overflow: hidden !important;
        overflow-y: hidden !important;
    }

    .dropdown-category,
    .product-category {
        width: 100%;
        padding: 10px 0;
        border: none !important;
        flex: none;
    }

    .dropdown-category + .dropdown-category,
    .product-category + .product-category {
        margin-top: 10px;
        border-top: 1px solid rgba(0, 0, 0, 0.1) !important;
    }

    .dropdown-link,
    .product-link {
        padding: 10px 15px;
        border-radius: 6px;
        background: var(--dropdown-bg);
        transition: var(--dropdown-transition);
        display: flex;
        align-items: center;
    }

    .dropdown-link:hover,
    .product-link:hover {
        background: #f0f0f0;
    }

    .dropdown-desc,
    .product-desc {
        margin: 5px 15px 0 35px;
        font-size: 12px;
        color: var(--dropdown-desc-color);
    }
}

/* 移动端动画 */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 移动端滚动条样式优化 - 强制显示滚动条 */
@media (max-width: 991.98px) {
    /* Webkit浏览器滚动条样式 */
    .dropdown-panel::-webkit-scrollbar,
    .products-panel::-webkit-scrollbar {
        width: 8px !important;
        height: 8px !important;
    }
    
    .dropdown-panel::-webkit-scrollbar-track,
    .products-panel::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.1) !important;
        border-radius: 4px !important;
        margin: 2px !important;
    }
    
    .dropdown-panel::-webkit-scrollbar-thumb,
    .products-panel::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.4) !important;
        border-radius: 4px !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
    }
    
    .dropdown-panel::-webkit-scrollbar-thumb:hover,
    .products-panel::-webkit-scrollbar-thumb:hover {
        background: rgba(0, 0, 0, 0.6) !important;
    }
    
    .dropdown-panel::-webkit-scrollbar-corner,
    .products-panel::-webkit-scrollbar-corner {
        background: rgba(0, 0, 0, 0.1) !important;
    }
    
    /* Firefox滚动条样式 */
    .dropdown-panel,
    .products-panel {
        scrollbar-width: thin !important;
        scrollbar-color: rgba(0, 0, 0, 0.4) rgba(0, 0, 0, 0.1) !important;
    }
    
    /* 确保内容可以完整滚动 */
    .dropdown-panel .dropdown-category,
    .products-panel .product-category {
        min-height: auto !important;
        height: auto !important;
    }
    
    /* 强制内容区域支持滚动 */
    .dropdown-panel > *,
    .products-panel > * {
        min-height: 0 !important;
        height: auto !important;
    }
}
