/**
 * 火桥主题 - Mega Menu 大菜单样式
 *
 * @package huoqiao
 * @description 顶部导航栏二级下拉菜单 - 大型菜单布局
 * 左侧：2列网格菜单项（图标+标题+描述）
 * 右侧：推广卡片区域
 */

/* ============================================
 * Mega Menu 容器
 * ============================================ */

/* 触发器 - 父级菜单项 */
.hq-nav-menu > .nav-item.mega-menu-parent {
    position: relative;
    overflow: hidden;
}

.hq-nav-menu > .nav-item.mega-menu-parent:hover,
.hq-nav-menu > .nav-item.mega-menu-parent.mega-open {
    overflow: visible;
}

/* Mega Menu 下拉容器 */
.hq-mega-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    opacity: 0;
    visibility: hidden;
    z-index: 1000;
    padding-top: 8px;
    transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

/* 悬停显示 */
.hq-nav-menu > .nav-item.mega-menu-parent:hover > .hq-mega-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

/* 触屏/移动端点击展开（等同于 hover 效果） */
.hq-nav-menu > .nav-item.mega-menu-parent.mega-open > .hq-mega-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
    animation: megaMenuFadeIn 0.25s ease-out forwards;
}

/* Mega Menu 内容区 */
.hq-mega-menu-inner {
    display: flex;
    background: #ffffff;
    border-radius: 16px;
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.04),
        0 12px 24px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    width: fit-content;
    min-width: 400px;
    max-width: 900px;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.hq-mega-menu:not(.has-promo) .hq-mega-menu-grid {
    border-right: none;
}

/* ============================================
 * 左侧网格区域
 * ============================================ */

.hq-mega-menu-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 16px 24px;
    border-right: 1px solid rgba(0, 0, 0, 0.06);
}

/* 菜单项 */
.hq-mega-menu-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 12px 18px;
    border-radius: 12px;
    text-decoration: none;
    transition: background-color 0.2s ease, transform 0.15s ease;
    cursor: pointer;
}

.hq-mega-menu-item:hover {
    background-color: rgba(0, 0, 0, 0.03);
    transform: translateX(2px);
}

/* 当前页标记 */
.hq-mega-menu-item.is-current {
    background-color: rgba(74, 144, 217, 0.08);
    border-left: 3px solid var(--primary-color, #4a90d9);
    padding-left: 13px;
}

.hq-mega-menu-item.is-current .hq-mega-menu-title {
    color: var(--primary-color, #4a90d9);
    font-weight: 700;
}

.hq-mega-menu-item.is-current .hq-mega-menu-icon {
    border-color: rgba(74, 144, 217, 0.4);
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

/* 图标容器 */
.hq-mega-menu-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    border: 1px solid rgba(74, 144, 217, 0.15);
    box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.05);
    transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.hq-mega-menu-item:hover .hq-mega-menu-icon {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    transform: scale(1.05);
    border-color: rgba(74, 144, 217, 0.3);
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.1);
}

.hq-mega-menu-icon i {
    font-size: 20px;
    color: var(--primary-color, #4a90d9);
    transition: color 0.2s ease;
}

.hq-mega-menu-item:hover .hq-mega-menu-icon i {
    color: var(--primary-color-hover, #3a7bc8);
}

/* 文字区域 */
.hq-mega-menu-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-top: 2px;
}

.hq-mega-menu-title {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a2e;
    line-height: 1.4;
    transition: color 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hq-mega-menu-item:hover .hq-mega-menu-title {
    color: var(--primary-color, #4a90d9);
}

.hq-mega-menu-desc {
    font-size: 12px;
    color: #6c757d;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* 查看全部入口 */
.hq-mega-menu-view-all {
    border: 1px dashed rgba(74, 144, 217, 0.3) !important;
    background: rgba(74, 144, 217, 0.02);
}

.hq-mega-menu-view-all:hover {
    background: rgba(74, 144, 217, 0.06) !important;
    border-color: rgba(74, 144, 217, 0.5) !important;
}

.hq-mega-menu-view-all .hq-mega-menu-icon {
    background: linear-gradient(135deg, rgba(74, 144, 217, 0.1) 0%, rgba(74, 144, 217, 0.2) 100%) !important;
    border: 1px solid rgba(74, 144, 217, 0.2);
}

.hq-mega-menu-view-all:hover .hq-mega-menu-icon {
    background: linear-gradient(135deg, rgba(74, 144, 217, 0.2) 0%, rgba(74, 144, 217, 0.3) 100%) !important;
}

.hq-mega-menu-view-all .hq-mega-menu-icon i {
    color: var(--primary-color, #4a90d9) !important;
}

.hq-mega-menu-view-all .hq-mega-menu-title {
    color: var(--primary-color, #4a90d9) !important;
}

.hq-mega-menu-view-all:hover .hq-mega-menu-title {
    color: var(--primary-color-hover, #3a7bc8) !important;
}

/* ============================================
 * 右侧推广卡片区域
 * ============================================ */

.hq-mega-menu-promo {
    width: 260px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 12px 12px 0;
    background: transparent;
}

/* 主推广卡片 */
.hq-mega-promo-main {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 140px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
}

.hq-mega-promo-main:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* 背景层：图片容器（z-index: 0） */
.hq-mega-promo-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

.hq-mega-promo-bg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.hq-mega-promo-main:hover .hq-mega-promo-bg img {
    transform: scale(1.05);
}

/* 暗色叠加层（z-index: 1） */
.hq-mega-promo-main::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 40%, rgba(0, 0, 0, 0.5) 100%);
    z-index: 1;
    pointer-events: none;
}

/* 内容浮层（z-index: 2） */
.hq-mega-promo-content {
    position: relative;
    z-index: 2;
    padding: 16px;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hq-mega-promo-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 3;
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #a3e635 0%, #84cc16 100%);
    padding: 4px 10px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(163, 230, 53, 0.4);
    pointer-events: none;
}

.hq-mega-promo-title-main {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.3;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.hq-mega-promo-desc-main {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.4;
}

.hq-mega-promo-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #a3e635;
    color: #1a1a2e;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.15s ease;
    width: fit-content;
    margin-top: 4px;
}

.hq-mega-promo-btn:hover {
    background: #bef264;
    transform: scale(1.02);
}

.hq-mega-promo-btn::after {
    content: '→';
    font-size: 14px;
    transition: transform 0.2s ease;
    display: inline-block;
}

.hq-mega-promo-btn:hover::after {
    transform: translateX(3px);
}

/* 次级推广入口 */
.hq-mega-promo-sub {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 12px;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.15s ease;
}

.hq-mega-promo-sub:hover {
    background: #e9ecef;
    transform: translateX(2px);
}

.hq-mega-promo-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-primary, #5E6AD2), var(--color-primary-light, #7A84E8));
    border-radius: 10px;
}

.hq-mega-promo-icon i,
.hq-mega-promo-icon svg {
    width: 20px;
    height: 20px;
    color: #ffffff;
    font-size: 18px;
}

.hq-mega-promo-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hq-mega-promo-title-sub {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a2e;
    line-height: 1.4;
}

.hq-mega-promo-desc-sub {
    font-size: 11px;
    color: #6c757d;
    line-height: 1.3;
}

.hq-mega-promo-arrow {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
    transition: color 0.2s ease, transform 0.2s ease;
    transform: translateX(0);
}

.hq-mega-promo-arrow i {
    font-size: 12px;
    transition: transform 0.2s ease;
}

.hq-mega-promo-sub:hover .hq-mega-promo-arrow {
    color: var(--primary-color, #4a90d9);
    transform: translateX(3px);
}

.hq-mega-promo-sub:hover .hq-mega-promo-arrow i {
    transform: translateX(2px);
}

/* ============================================
 * 响应式适配
 * ============================================ */

/* ≤1200px：自适应宽度 */
@media (max-width: 1200px) {
    .hq-mega-menu-inner {
        max-width: 600px;
    }
}

/* ≤992px：纵向堆叠布局（平板横屏） */
@media (max-width: 991.98px) {
    .hq-nav-menu > .nav-item.mega-menu-parent {
        overflow: visible;
    }

    .hq-mega-menu {
        position: static;
        transform: none;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        padding-top: 0;
        width: 100%;
    }

    .hq-mega-menu-inner {
        flex-direction: column;
        min-width: auto;
        max-width: 100%;
        border-radius: 12px;
    }

    .hq-mega-menu-grid {
        padding: 10px;
        gap: 6px;
    }

    .hq-mega-menu-promo {
        width: 100%;
        padding: 0 10px 10px 10px;
        gap: 8px;
    }

    .hq-mega-promo-main {
        min-height: 100px;
    }
}

/* ≤768px：移动端标准展开 */
@media (max-width: 767.98px) {
    .hq-mega-menu {
        display: none;
    }

    .hq-nav-item.mega-menu-parent.mega-open > .hq-mega-menu {
        display: block;
    }

    /* 手机端隐藏描述 */
    .hq-mega-menu-desc {
        display: none;
    }

    /* 手机端隐藏推广模块 */
    .hq-mega-menu-promo {
        display: none;
    }
}

/* ============================================
 * 动画效果
 * ============================================ */

@keyframes megaMenuFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.hq-nav-menu > .nav-item.mega-menu-parent:hover > .hq-mega-menu,
.hq-nav-menu > .nav-item.mega-menu-parent.mega-open > .hq-mega-menu {
    animation: megaMenuFadeIn 0.25s ease-out forwards;
}

/* ============================================
 * 无障碍支持
 * ============================================ */

.hq-mega-menu:focus-within {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.hq-mega-menu-item:focus {
    outline: 2px solid var(--primary-color, #4a90d9);
    outline-offset: -2px;
    background-color: rgba(0, 0, 0, 0.03);
}

.hq-mega-promo-main:focus,
.hq-mega-promo-sub:focus {
    outline: 2px solid var(--primary-color, #4a90d9);
    outline-offset: 2px;
}

/* ============================================
 * 交错入场动画
 * ============================================ */

@keyframes megaMenuItemFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hq-nav-menu > .nav-item.mega-menu-parent:hover > .hq-mega-menu .hq-mega-menu-item,
.hq-nav-menu > .nav-item.mega-menu-parent.mega-open > .hq-mega-menu .hq-mega-menu-item {
    animation: megaMenuItemFadeIn 0.3s ease-out forwards;
}

/* 交错延迟 */
.hq-mega-menu-item:nth-child(1) { animation-delay: 0.03s; }
.hq-mega-menu-item:nth-child(2) { animation-delay: 0.06s; }
.hq-mega-menu-item:nth-child(3) { animation-delay: 0.09s; }
.hq-mega-menu-item:nth-child(4) { animation-delay: 0.12s; }
.hq-mega-menu-item:nth-child(5) { animation-delay: 0.15s; }
.hq-mega-menu-item:nth-child(6) { animation-delay: 0.18s; }
.hq-mega-menu-item:nth-child(7) { animation-delay: 0.21s; }
.hq-mega-menu-item:nth-child(8) { animation-delay: 0.24s; }

/* 推广卡片入场动画 */
@keyframes megaMenuPromoFadeIn {
    from {
        opacity: 0;
        transform: translateX(12px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.hq-nav-menu > .nav-item.mega-menu-parent:hover > .hq-mega-menu .hq-mega-menu-promo,
.hq-nav-menu > .nav-item.mega-menu-parent.mega-open > .hq-mega-menu .hq-mega-menu-promo {
    animation: megaMenuPromoFadeIn 0.35s ease-out 0.1s forwards;
    opacity: 0;
}

/* ============================================
 * 3D 倾斜效果 (hover)
 * ============================================ */

.hq-mega-promo-main {
    transform-style: preserve-3d;
    perspective: 500px;
}

.hq-mega-promo-main:hover {
    transform: translateY(-4px) rotateX(1deg) rotateY(-1deg);
}

.hq-mega-promo-main:hover .hq-mega-promo-bg img {
    transform: scale(1.08);
}

/* ============================================
 * 箭头指示器动画
 * ============================================ */

.hq-mega-promo-btn::after {
    content: '→';
    font-size: 14px;
    transition: transform 0.2s ease;
    display: inline-block;
}

.hq-mega-promo-btn:hover::after {
    transform: translateX(4px);
}

/* 箭头脉冲动画（触发器上的小箭头） */
.hq-nav-menu .nav-item.mega-menu-parent > .nav-link::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid currentColor;
    vertical-align: middle;
    margin-left: 4px;
    opacity: 0.5;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.hq-nav-menu .nav-item.mega-menu-parent:hover > .nav-link::after,
.hq-nav-menu .nav-item.mega-menu-parent.mega-open > .nav-link::after {
    transform: rotate(180deg);
    opacity: 1;
}

/* 隐藏更多按钮旁边的下拉箭头 */
.hq-nav-menu .nav-item.hq-nav-more.mega-menu-parent > .nav-link::after {
    display: none;
    content: none;
}

/* ============================================
 * 移动端底部滑出式设计
 * ============================================ */

@media (max-width: 767.98px) {
    .hq-mega-menu {
        display: none;
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        transform: none;
        padding-top: 0;
        z-index: 10000;
        opacity: 1;
        visibility: visible;
    }

    .hq-nav-menu > .nav-item.mega-menu-parent.mega-open > .hq-mega-menu {
        display: block;
        animation: megaMenuSlideUp 0.3s ease-out forwards;
    }

    @keyframes megaMenuSlideUp {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .hq-mega-menu-inner {
        min-width: auto;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 70vh;
        overflow-y: auto;
    }

    /* 手机端隐藏描述 */
    .hq-mega-menu-desc {
        display: none;
    }

    /* 手机端隐藏推广模块 */
    .hq-mega-menu-promo {
        display: none;
    }

    /* 网格全宽显示 */
    .hq-mega-menu-grid {
        grid-template-columns: repeat(2, 1fr);
        border-right: none;
    }

    /* 菜单项触摸反馈 */
    .hq-mega-menu-item:active {
        background-color: rgba(74, 144, 217, 0.1);
        transform: scale(0.98);
    }
}

/* 平板横屏优化 */
@media (min-width: 768px) and (max-width: 991.98px) {
    .hq-mega-menu-inner {
        max-height: 60vh;
        overflow-y: auto;
    }

    /* 平板也隐藏推广区以节省空间 */
    .hq-mega-menu-promo {
        display: none;
    }

    .hq-mega-menu-grid {
        border-right: none;
    }
}

/* ============================================
 * 高对比度模式支持
 * ============================================ */

@media (prefers-contrast: high) {
    .hq-mega-menu-item {
        border: 1px solid currentColor;
    }

    .hq-mega-menu-item:hover {
        border-color: var(--primary-color, #4a90d9);
    }

    .hq-mega-promo-main {
        border: 2px solid #fff;
    }
}

/* ============================================
 * 减少动画模式
 * ============================================ */

@media (prefers-reduced-motion: reduce) {
    .hq-mega-menu,
    .hq-mega-menu-item,
    .hq-mega-promo-main,
    .hq-mega-promo-btn,
    .hq-mega-promo-sub,
    .hq-mega-promo-arrow {
        animation: none !important;
        transition: none !important;
    }
}
