/* ==================== 悬停式菜单样式 - v4.3.0 ==================== */
/* 优化：统一z-index、完善响应式、提升性能 */

/* ==================== CSS变量和z-index规范 ==================== */
:root {
    /* z-index层级规范 */
    --z-base: 1;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-fixed: 300;
    --z-modal-backdrop: 997;
    --z-modal: 998;
    --z-sidebar: 1000;
    --z-popover: 1002;
    --z-tooltip: 1003;
    --z-notification: 2000;
    --z-toast: 2001;
    --z-loading: 9999;

    /* 颜色变量 */
    --sidebar-bg: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    --sidebar-item-hover: rgba(96, 165, 250, 0.15);
    --sidebar-item-active: rgba(96, 165, 250, 0.25);
    --primary-color: #667eea;

    /* 尺寸变量 */
    --sidebar-width: 64px;
    --sidebar-width-tablet: 56px;
    --submenu-width: 240px;
    --submenu-width-tablet: 220px;
    --submenu-width-mobile: 80%;
    --header-height: 56px;
}

/* 整体布局 */
.hover-menu-layout {
    display: flex;
    min-height: 100vh;
    background: #f5f7fa;
}

/* ==================== 左侧一级菜单（优化紧凑度和响应式） ==================== */
.sidebar-hover {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    left: 0;
    top: 0;
    z-index: var(--z-sidebar);
    overflow-x: hidden;
    overflow-y: auto;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-hover::-webkit-scrollbar {
    width: 3px;
}

.sidebar-hover::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* Logo区域（紧凑） */
.sidebar-hover-logo {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.sidebar-hover-logo i {
    font-size: 28px;
    color: #60a5fa;
}

/* 一级菜单导航（紧凑间距） */
.sidebar-hover-nav {
    flex: 1;
    padding: 6px 0;
    overflow-y: auto;
}

/* 一级菜单项（紧凑） */
.sidebar-hover-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    margin: 2px 6px;
    cursor: pointer;
    transition: all 0.25s ease;
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    border-radius: 8px;
    border: none;
    background: transparent;
    width: calc(100% - 12px);
}

.sidebar-hover-item:hover {
    background: var(--sidebar-item-hover);
    color: #ffffff;
}

.sidebar-hover-item.active {
    background: var(--sidebar-item-active);
    color: #ffffff;
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.3);
}

/* 一级菜单图标（优化大小） */
.sidebar-hover-item i {
    font-size: 22px;
    margin-bottom: 3px;
}

/* 一级菜单文字（紧凑） */
.sidebar-hover-item span {
    font-size: 10px;
    text-align: center;
    line-height: 1.1;
    max-width: 56px;
    word-break: keep-all;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

/* 底部工具栏 */
.sidebar-hover-footer {
    padding: 8px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.sidebar-hover-footer .sidebar-hover-item {
    margin: 2px 6px;
}

/* ==================== 浮动二级菜单面板（优化z-index和响应式） ==================== */
.submenu-panel {
    position: fixed;
    left: var(--sidebar-width);
    top: 0;
    width: var(--submenu-width);
    height: 100vh;
    background: #ffffff;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.12);
    z-index: var(--z-modal);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

/* 显示状态 */
.submenu-panel.active {
    transform: translateX(0);
}

/* 二级菜单头部 */
.submenu-header {
    padding: 16px 18px;
    background: var(--primary-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.submenu-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}

.submenu-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.submenu-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.submenu-close i {
    font-size: 18px;
}

/* 二级菜单内容区 */
.submenu-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.submenu-content::-webkit-scrollbar {
    width: 4px;
}

.submenu-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

/* 二级菜单分组 */
.submenu-group {
    margin-bottom: 4px;
}

.submenu-group-title {
    padding: 8px 18px;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 二级菜单项 */
.submenu-item {
    display: flex;
    align-items: center;
    padding: 10px 18px;
    color: #334155;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
    border-left: 3px solid transparent;
}

.submenu-item:hover {
    background: #f1f5f9;
    border-left-color: var(--primary-color);
    color: var(--primary-color);
}

.submenu-item.active {
    background: #ede9fe;
    border-left-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 600;
}

.submenu-item i {
    font-size: 16px;
    margin-right: 10px;
    width: 16px;
    text-align: center;
}

.submenu-item-text {
    font-size: 13px;
    flex: 1;
}

.submenu-item-badge {
    background: #ef4444;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

/* 遮罩层（优化z-index） */
.submenu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: var(--z-modal-backdrop);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.submenu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ==================== 主内容区域 ==================== */
.hover-menu-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* 顶部栏 */
.hover-menu-header {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* 面包屑 */
.header-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #64748b;
}

.header-breadcrumb i {
    font-size: 16px;
}

/* 右侧操作区 */
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-action-btn {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: #f8fafc;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.header-action-btn:hover {
    background: #e2e8f0;
    color: #334155;
}

.header-action-btn i {
    font-size: 18px;
}

.header-action-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid white;
}

/* 用户信息 */
.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.header-user:hover {
    background: #f8fafc;
}

.header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.header-avatar i {
    font-size: 20px;
}

.header-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.header-username {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}

.header-role {
    font-size: 11px;
    color: #64748b;
}

/* 内容区域 */
.hover-menu-content {
    flex: 1;
    padding: 20px;
    background: #f5f7fa;
}

/* ==================== 响应式优化 ==================== */

/* 平板端 (1024px以下) */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: var(--sidebar-width-tablet);
        --submenu-width: var(--submenu-width-tablet);
    }

    .sidebar-hover-item {
        padding: 6px 3px;
    }

    .sidebar-hover-item i {
        font-size: 20px;
    }

    .sidebar-hover-item span {
        font-size: 9px;
    }

    .hover-menu-content {
        padding: 16px;
    }
}

/* 移动端 (768px以下) - 重要修复 */
@media (max-width: 768px) {
    :root {
        --submenu-width: var(--submenu-width-mobile);
    }

    /* 侧边栏默认隐藏 */
    .sidebar-hover {
        transform: translateX(-100%);
        z-index: calc(var(--z-sidebar) + 1);
    }

    .sidebar-hover.mobile-open {
        transform: translateX(0);
    }

    /* 主内容区占满屏幕 */
    .hover-menu-main {
        margin-left: 0;
        width: 100%;
    }

    /* 二级菜单调整 */
    .submenu-panel {
        left: 0;
        max-width: 300px;
    }

    .submenu-panel.active {
        left: var(--sidebar-width-tablet);
    }

    /* 头部调整 */
    .hover-menu-header {
        padding: 0 16px;
    }

    .header-user-info {
        display: none;
    }

    /* 内容区域调整 */
    .hover-menu-content {
        padding: 12px;
    }

    /* 添加移动端菜单按钮 */
    .mobile-menu-toggle {
        display: flex !important;
    }
}

/* 小屏手机 (480px以下) */
@media (max-width: 480px) {
    .hover-menu-header {
        padding: 0 12px;
    }

    .header-actions {
        gap: 8px;
    }

    .header-action-btn {
        width: 32px;
        height: 32px;
    }

    .header-avatar {
        width: 32px;
        height: 32px;
    }

    .hover-menu-content {
        padding: 8px;
    }
}

/* 移动端菜单切换按钮 */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    z-index: calc(var(--z-sidebar) + 2);
    transition: all 0.3s;
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

.mobile-menu-toggle i {
    font-size: 24px;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }
}

/* ==================== 性能优化 ==================== */
/* GPU加速 */
.sidebar-hover,
.submenu-panel,
.submenu-overlay {
    will-change: transform;
}

/* 减少重绘 */
.sidebar-hover-item,
.submenu-item {
    contain: layout style paint;
}
