/* * ==========================================
 * 1. 设计令牌 (Design Tokens) - PC视觉核心
 * ==========================================
 */
/* CSS变量定义：色彩、尺寸、圆角、动画曲线 */
:root {
    /* 主色调梯度 */
    --primary-50: #eff6ff; --primary-100: #dbeafe; --primary-200: #bfdbfe;
    --primary-300: #93c5fd; --primary-400: #60a5fa; --primary-500: #3b82f6;
    --primary-600: #2563eb; --primary-700: #1d4ed8;
    /* 功能色 */
    --success: #10b981; --warning: #f59e0b; --danger: #ef4444; --info: #06b6d4;
    /* 布局尺寸 */
    --side-w: 230px;                     /* 侧边栏宽度 */
    --side-collapsed-w: 72px;           /* 折叠后侧边栏宽度 */
    --head-h: 68px;                     /* 顶部栏高度 */
    --tab-h: 46px;                      /* 标签栏高度 */
    /* 圆角 */
    --radius-sm: 8px; var(--radius-md): 12px; var(--radius-lg): 20px;
    /* 动画曲线 */
    --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-elastic: cubic-bezier(0.34, 1.56, 0.64, 1);
    --trans: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 明亮主题变量定义 */
:root {
    --bg: #f8fafc;
    --bg-sub: #ffffff; 
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-hover: #f1f5f9; 
    --bg-active: #eff6ff;
    --border: #e2e8f0; 
    --text: #0f172a; 
    --text-sub: #64748b;
    --text-muted: #94a3b8;
    --glass: rgba(255, 255, 255, 0.85);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05);
    --glow: 0 0 20px rgba(59, 130, 246, 0.1);
}

/* * ==========================================
 * 2. 全局基础与背景
 * ==========================================
 */
/* 重置盒模型并移除点击高亮 */
*, *::before, *::after { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; 
}

/* 全局基础样式 */
body, html {
    margin: 0; 
    padding: 0; 
    height: 100%; 
    width: 100%;
    background-color: var(--bg);                  /* 动态背景色 */
    color: var(--text);                          /* 动态文本色 */
    font-size: 14px; 
    line-height: 1.5; 
    overflow: hidden;                           /* 隐藏全局滚动条 */
}

body {
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "PingFang SC",
        "Hiragino Sans GB",
        "Microsoft YaHei",
        "Helvetica Neue",
        Arial,
        sans-serif;
}

/* 背景装饰：网点图案 */
.bg-decor {
    position: fixed; 
    inset: 0;                                    /* 覆盖整个视口 */
    z-index: -1;                                 /* 置于最底层 */
    pointer-events: none;                        /* 不响应鼠标事件 */
    background-image: radial-gradient(var(--border) 1px, transparent 1px);
    background-size: 24px 24px;                  /* 网点间距 */
    opacity: 0.3;                                /* 半透明 */
    mask-image: radial-gradient(circle at 50% 50%, black, transparent 90%); /* 中心渐变遮罩 */
}

/* 背景光晕效果 */
.bg-glow {
    position: fixed; 
    top: -20%; 
    right: -10%; 
    width: 600px; 
    height: 600px;
    background: radial-gradient(circle, var(--primary-500) 0%, transparent 70%);
    opacity: 0.08; 
    filter: blur(80px);                         /* 高斯模糊 */
    z-index: -1; 
    pointer-events: none;
}

/* 自定义滚动条样式 */
::-webkit-scrollbar { 
    width: 4px; 
    height: 4px; 
}
::-webkit-scrollbar-thumb { 
    background: var(--border); 
    border-radius: 2px; 
}
/* 隐藏侧边栏和标签栏的滚动条 */
.sidebar-nav::-webkit-scrollbar, 
.tabs-bar::-webkit-scrollbar { 
    display: none; 
}

/* * ==========================================
 * 3. 响应式布局引擎 (Layout Engine)
 * ==========================================
 */
/* 主容器：网格布局 */
.app-container {
    display: grid; 
    height: 100vh;
    height: 100dvh;                              /* 全屏高度 */
    grid-template-columns: var(--side-w) 1fr;   /* 侧边栏 + 主内容 */
    grid-template-rows: var(--head-h) 1fr;      /* 内容 */
    grid-template-areas: "sidebar header" "sidebar main"; /* 区域定义 */
    transition: grid-template-columns 0.4s var(--ease-out); /* 折叠动画 */
}
/* 折叠状态：缩小侧边栏 */
.app-container.collapsed { 
    grid-template-columns: var(--side-collapsed-w) 1fr; 
}

/* 移动端适配（最大宽度992px） */
@media (max-width: 992px) {
    /* 单列布局：隐藏侧边栏 */
    .app-container {
        grid-template-columns: 100% !important;
        grid-template-rows: var(--head-h) 1fr;
        grid-template-areas: "header" "main";
    }
    
    /* 侧边栏改为固定定位的抽屉 */
    .sidebar {
        position: fixed !important; 
        inset: 0 auto 0 0;                     /* 左侧固定 */
        width: 220px !important; 
        z-index: 2000;                         /* 最高层级 */
        transform: translateX(-100%);          /* 默认隐藏 */
        box-shadow: none;
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important; /* 滑动动画 */
    }
    
    /* 移动端展开状态 */
    .app-container.mobile-open .sidebar { 
        transform: translateX(0);              /* 滑入显示 */
    }
    
    /* 遮罩层：点击关闭侧边栏 */
    .sidebar-mask {
        position: fixed; 
        inset: 0; 
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);            /* 背景模糊 */
        z-index: 1999; 
        display: none;
        opacity: 0; 
        transition: opacity 0.3s;
    }
    
    .app-container.mobile-open .sidebar-mask { 
        display: block; 
        opacity: 1; 
    }
    
    /* 响应式显示/隐藏控制 */
    .pc-only { display: none !important; }    /* PC端元素隐藏 */
    .mobile-only { display: flex !important; } /* 移动端元素显示 */
    
    /* 移动端间距调整 */
    .header { padding: 0 16px !important; }
    .viewport { 
        margin: 0 !important; 
        border-radius: 0 !important; 
        border: none !important; 
    }
    .tabs-bar { padding: 0 16px !important; }
    
    /* 边缘触发区域：用于手势呼出侧边栏 */
    .edge-trigger { 
        position: fixed; 
        left: 0; 
        top: 0; 
        bottom: 0; 
        width: 25px; 
        z-index: 1500; 
    }
}

/* PC端适配（最小宽度993px） */
@media (min-width: 993px) {
    .mobile-only { display: none !important; }
    .edge-trigger { display: none; }
}

/* * ==========================================
 * 4. 侧边栏 (Sidebar)
 * ==========================================
 */
.sidebar {
    grid-area: sidebar;                         /* 网格区域 */
    background: var(--bg-sub);                  /* 次级背景色 */
    border-right: 1px solid var(--border);      /* 右侧分割线 */
    display: flex; 
    flex-direction: column;                     /* 垂直排列 */
    overflow: hidden;                           /* 隐藏溢出内容 */
    transition: width 0.4s var(--ease-out);     /* 宽度过渡动画 */
}

/* 品牌区域 */
.sidebar-brand {
    height: var(--head-h);                      /* 与顶部栏同高 */
    padding: 0 24px;
    display: flex; 
    align-items: center; 
    flex-shrink: 0;                            /* 防止被压缩 */
    overflow: hidden;                          /* 隐藏溢出文本 */
}

/* 品牌LOGO */
.brand-logo {
    width: 40px; 
    height: 40px;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    border-radius: 12px;
    display: flex; 
    align-items: center; 
    justify-content: center;
    color: #fff; 
    font-size: 20px;
    box-shadow: 0 8px 16px -4px rgba(59, 130, 246, 0.4); /* 发光阴影 */
    flex-shrink: 0;                            /* 保持固定尺寸 */
    margin-right: 12px;
}

/* 品牌信息区域 */
.brand-info { 
    transition: opacity 0.2s;                  /* 折叠时的淡出动画 */
    white-space: nowrap;                       /* 禁止文字换行 */
}

/* 折叠状态下隐藏品牌信息 */
.app-container.collapsed .brand-info { 
    opacity: 0; 
    pointer-events: none;                      /* 禁用鼠标事件 */
}

.brand-name { 
    font-size: 16px; 
    font-weight: 800; 
}
.brand-tag { 
    font-size: 10px; 
    font-weight: 600; 
    color: var(--primary-400); 
    letter-spacing: 0.05em;                    /* 字间距 */
}

/* 导航菜单容器 */
.sidebar-nav { 
    flex: 1;                                   /* 占据剩余空间 */
    overflow-y: auto;                          /* 垂直滚动 */
    padding: 16px; 
}

/* 分组标签 */
.nav-label { 
    padding: 0 12px 8px; 
    font-size: 11px; 
    font-weight: 700; 
    color: var(--text-muted); 
    opacity: 0.8; 
    margin-top: 10px; 
}
/* 折叠状态下隐藏分组标签 */
.app-container.collapsed .nav-label { 
    display: none; 
}

/* 导航项 */
.nav-item {
    display: flex; 
    align-items: center; 
    padding: 8px 10px;
    border-radius: var(--radius-md); 
    margin-bottom: 4px;
    color: var(--text-sub); 
    transition: all 0.2s var(--ease-out);      /* 平滑过渡 */
    cursor: pointer; 
    position: relative; 
    font-weight: 500;
}

/* 悬停状态 */
.nav-item:hover { 
    background: var(--bg-hover); 
    color: var(--text); 
}

/* 激活状态 */
.nav-item.active { 
    background: var(--bg-active); 
    color: var(--primary-400); 
    font-weight: 600; 
}

/* 激活状态指示条 */
.nav-item.active::before {
    content: ''; 
    position: absolute; 
    left: 0; 
    top: 10px; 
    bottom: 10px;
    width: 3px; 
    background: var(--primary-500); 
    border-radius: 0 3px 3px 0;
    box-shadow: 0 0 8px var(--primary-500);    /* 发光效果 */
}

/* 导航图标 */
.nav-item i.main-icon { 
    width: 24px; 
    font-size: 18px; 
    text-align: center; 
    margin-right: 12px; 
    transition: 0.2s; 
}

/* 折叠状态下的导航项 */
.app-container.collapsed .nav-item { 
    justify-content: center;                   /* 居中显示 */
    padding: 12px 0; 
}
.app-container.collapsed .nav-item i.main-icon { 
    margin-right: 0; 
    font-size: 20px; 
}
/* 折叠状态下隐藏文字和外部链接图标 */
.app-container.collapsed .nav-item span, 
.app-container.collapsed .nav-item .external-icon { 
    display: none; 
}

/* 移动端融合菜单（显示顶部菜单项） */
.mobile-fusion-menu { 
    display: none;                             /* PC端默认隐藏 */
    padding-bottom: 20px; 
    margin-bottom: 20px; 
    border-bottom: 1px solid var(--border);    /* 分割线 */
}

/* 移动端显示融合菜单 */
@media (max-width: 992px) { 
    .mobile-fusion-menu { 
        display: block; 
    } 
}

/* ==========================================
 * 导航分组折叠功能样式
 * ========================================== */

/* 分组容器 */
.nav-group {
    margin-bottom: 8px;
}

/* 分组标题容器（可点击） */
.nav-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px 8px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.nav-group-title:hover {
    opacity: 0.8;
}

/* 折叠切换箭头 */
.nav-group-toggle {
    font-size: 12px;
    color: var(--text-muted);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: 8px;
    flex-shrink: 0;
}

/* 收起状态：箭头向上 */
.nav-group.collapsed .nav-group-toggle {
    transform: rotate(-90deg);
}

/* 分组内容容器 */
.nav-group-content {
    max-height: 1000px;
    overflow: hidden;
    opacity: 1;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease;
}

/* 收起状态：内容隐藏 */
.nav-group.collapsed .nav-group-content {
    max-height: 0;
    opacity: 0;
}

/* 折叠状态下隐藏分组下的所有菜单项 */
.nav-group.collapsed .nav-item {
    display: none;
}

/* 关键修复：全局侧边栏收缩时隐藏标签文本和箭头 */
.app-container.collapsed .nav-group-toggle {
    display: none !important;
}

/* 侧边栏全局收缩状态下：隐藏分组内容 */
.app-container.collapsed .nav-group-content {
    display: none;
}

/* * ==========================================
 * 5. 顶部栏 (Header)
 * ==========================================
 */
.header {
    grid-area: header;                         /* 网格区域 */
    background: var(--glass);                  /* 毛玻璃背景 */
    backdrop-filter: blur(16px);               /* 背景模糊 */
    -webkit-backdrop-filter: blur(16px);       /* Safari兼容 */
    border-bottom: 1px solid var(--border);    /* 底部边框 */
    display: flex; 
    align-items: center; 
    justify-content: space-between;            /* 两端对齐 */
    padding: 0 24px; 
    z-index: 100;                              /* 层级 */
}

/* 图标按钮通用样式 */
.icon-btn {
    background: var(--glass);                  /* 毛玻璃背景 */
    width: 48px; 
    height: 48px; 
    border-radius: var(--radius-sm);
    color: var(--text-sub); 
    display: flex; 
    align-items: center; 
    justify-content: center;
    transition: 0.2s; 
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.icon-btn:hover { 
    background: var(--bg-hover); 
    color: var(--text); 
}

/* 顶部菜单容器 */
.top-menu { 
    display: flex; 
    gap: 4px; 
    background: var(--bg-hover); 
    padding: 4px; 
    border-radius: var(--radius-sm); 
    border: 1px solid rgba(0, 0, 0, 0.05);     /* 半透明边框 */
}

/* 顶部菜单项 */
.top-menu-link { 
    padding: 6px 16px; 
    border-radius: 6px; 
    font-size: 14px; 
    font-weight: 500; 
    color: var(--text-sub); 
    transition: 0.2s; 
    cursor: pointer; 
    position: relative;
    display: flex; 
    align-items: center; 
    gap: 8px;
}
.top-menu-link:hover { 
    color: var(--text); 
    background: var(--bg); 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);     /* 悬停阴影 */
}
.top-menu-link i { 
    font-size: 12px; 
    width: 16px; 
    text-align: center; 
}

/* 外部链接指示器（右上角小图标） */
.top-menu-link .external-indicator { 
    font-size: 8px; 
    opacity: 0.5; 
    position: absolute; 
    top: 2px; 
    right: 2px; 
    width: 10px; 
    height: 10px; 
    display: flex; 
    align-items: center; 
    justify-content: center;
}

/* 用户信息区域 */
.user-pill { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    padding: 4px 12px 4px 4px; 
    border-radius: 30px;                       /* 胶囊形状 */
    background: var(--bg-sub); 
    border: 1px solid var(--border); 
}

/* 用户头像 */
.avatar { 
    width: 32px; 
    height: 32px; 
    border-radius: 50%;                        /* 圆形 */
    background: linear-gradient(135deg, var(--primary-600), var(--primary-400));
    color: #fff; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-weight: 700; 
    font-size: 12px; 
}

/* * ==========================================
 * 6. 主内容区 (Main)
 * ==========================================
 */
.main { 
    grid-area: main;                           /* 网格区域 */
    display: flex; 
    flex-direction: column;                    /* 垂直排列 */
    overflow: hidden;                          /* 隐藏溢出 */
}

/* 标签栏 */
.tabs-bar { 
    height: var(--tab-h);                      /* 固定高度 */
    display: flex; 
    align-items: center; 
    gap: 6px; 
    padding: 0 24px; 
    overflow-x: auto;                          /* 水平滚动 */
    scrollbar-width: none;                     /* Firefox隐藏滚动条 */
    background: var(--bg); 
    border-bottom: 1px solid var(--border); 
}

/* 单个标签 */
.tab-item { 
    height: 32px; 
    padding: 0 12px; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    border-radius: var(--radius-sm); 
    font-size: 12px; 
    font-weight: 500; 
    color: var(--text-sub); 
    cursor: pointer; 
    transition: 0.2s; 
    border: 1px solid transparent; 
    background: transparent; 
    max-width: 160px;                          /* 最大宽度限制 */
    flex-shrink: 0;                            /* 防止压缩 */
}
.tab-item span { 
    overflow: hidden; 
    text-overflow: ellipsis;                   /* 文字溢出显示省略号 */
    white-space: nowrap;                       /* 禁止换行 */
}

/* 激活状态的标签 */
.tab-item.active { 
    background: var(--bg-sub); 
    color: var(--primary-400); 
    border-color: var(--border); 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); 
    font-weight: 600; 
}

/* 标签关闭按钮 */
.tab-close { 
    font-size: 10px; 
    opacity: 0;                               /* 默认隐藏 */
    width: 16px; 
    height: 16px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    border-radius: 50%;                       /* 圆形 */
    transition: 0.2s; 
}
/* 悬停和激活时显示关闭按钮 */
.tab-item:hover .tab-close, 
.tab-item.active .tab-close { 
    opacity: 0.6; 
}
.tab-close:hover { 
    opacity: 1 !important; 
    background: var(--danger);                /* 危险色背景 */
    color: white; 
}

/* 页面工具栏 */
.page-toolbar { 
    padding: 10px 24px; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    min-height: 48px; 
}

/* 面包屑导航 */
.breadcrumb { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    font-size: 12px; 
    color: var(--text-muted); 
}

/* 视图容器 */
.viewport { 
    flex: 1;                                   /* 占据剩余空间 */
    margin: 0 24px 24px; 
    background: var(--bg-card);                /* 卡片背景 */
    border-radius: var(--radius-lg); 
    border: 1px solid var(--border); 
    box-shadow: var(--shadow-lg);              /* 阴影效果 */
    position: relative; 
    overflow: hidden; 
    backdrop-filter: blur(5px);                /* 背景模糊 */
}

/* iframe页面容器 */
.iframe-page { 
    position: absolute; 
    inset: 0;                                 /* 填充父容器 */
    width: 100%; 
    height: 100%; 
    border: none; 
    display: none;                            /* 默认隐藏 */
    background: var(--bg-sub); 
}

/* 激活状态的iframe */
.iframe-page.active { 
    display: block; 
    animation: fadeIn 0.4s ease;              /* 淡入动画 */
}

/* iframe淡入动画 */
@keyframes fadeIn { 
    from { 
        opacity: 0; 
        transform: translateY(5px);            /* 轻微上移动画 */
    } 
    to { 
        opacity: 1; 
        transform: translateY(0); 
    } 
}

/* 加载遮罩层 */
.loader-mask { 
    position: absolute; 
    inset: 0;                                 /* 覆盖整个容器 */
    background: var(--bg-card); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    z-index: 50;                              /* 高于iframe */
    transition: opacity 0.3s;                 /* 淡出过渡 */
}
.loader-mask.hide { 
    opacity: 0; 
    pointer-events: none;                     /* 隐藏时禁用交互 */
}

/* 加载动画 */
.spinner { 
    width: 40px; 
    height: 40px; 
    border: 3px solid transparent; 
    border-top-color: var(--primary-500);      /* 顶部颜色 */
    border-radius: 50%; 
    animation: spin 1s infinite cubic-bezier(0.5, 0, 0.5, 1);
}
.spinner::after { 
    content:''; 
    position: absolute; 
    inset: 4px;                              /* 内缩4px */
    border-radius: 50%; 
    border: 3px solid transparent; 
    border-top-color: var(--primary-300);     /* 第二层颜色 */
    opacity: 0.5; 
    animation: spin 2s linear infinite;       /* 不同速度的双层动画 */
}
@keyframes spin { 
    to { 
        transform: rotate(360deg);            /* 旋转动画 */
    } 
}

/* 消息通知容器 */
.toast-container { 
    position: fixed; 
    top: 24px; 
    right: 24px; 
    z-index: 9999;                            /* 最高层级 */
    display: flex; 
    flex-direction: column;                   /* 垂直堆叠 */
    gap: 12px;                                /* 间距 */
}

/* 单个通知 */
.toast { 
    background: var(--bg-sub); 
    border: 1px solid var(--border); 
    padding: 14px 20px; 
    border-radius: var(--radius-md); 
    box-shadow: var(--shadow-lg); 
    display: flex; 
    align-items: center; 
    gap: 14px; 
    color: var(--text); 
    animation: slideIn 0.4s var(--ease-elastic); /* 弹性滑入动画 */
    position: relative; 
    overflow: hidden; 
}

/* 通知左侧指示条 */
.toast::before { 
    content: ''; 
    position: absolute; 
    left: 0; 
    top: 0; 
    bottom: 0; 
    width: 4px; 
    background: var(--primary-500); 
}

/* 滑入动画 */
@keyframes slideIn { 
    from { 
        transform: translateX(100%) scale(0.9); /* 从右侧缩小滑入 */
        opacity: 0; 
    } 
    to { 
        transform: translateX(0) scale(1); 
        opacity: 1; 
    } 
}