/* ===== 全局布局 wrapper ===== */
/* 默认禁止 body 滚动，由内部内容区自行滚动 */
html, body {
    height: 100%;
    overflow: hidden;
}

/* =========================================================
   Bootstrap Modal 兼容：
   只阻止 Bootstrap 自动加的滚动条补偿 padding，
   其余全交给 Bootstrap 默认行为即可
   ========================================================= */
body.modal-open {
    padding-right: 0 !important;
}

.layout-wrapper {
    display: flex;
    position: fixed;
    top: 50px;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    z-index: 100;
}
.modal {
    z-index: 2050 !important;
}
.modal-backdrop {
    z-index: 2049 !important;
}
/* 有些模态框带 fade 过渡，确保不被截断 */
.modal-content {
    overflow: visible;
}
.layout-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 面包屑：自然占位在顶部，不需要 sticky */
.layout-main .breadcrumb-wrapper {
    flex-shrink: 0;
}

/* 让 body-content 成为唯一的滚动容器 */
.layout-main .body-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ===== 两列侧边栏 ===== */
/* layout-wrapper 已是 fixed，侧边栏不需要 sticky */
.global-sidebar {
    display: flex;
    flex-shrink: 0;
    align-self: flex-start;
    height: 100%;
    z-index: 100;
}

/* 第一列：主分类（固定 64px） */
.sidebar-primary {
    width: 64px;
    background-color: #2c3e50;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    overflow-y: auto;
}
.sidebar-primary .primary-item {
    width: 100%;
    padding: 12px 4px;
    color: #bdc3c7;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    border-left: 3px solid transparent;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
}
.sidebar-primary .primary-item:hover {
    background-color: #34495e;
    color: #fff;
}
.sidebar-primary .primary-item.active {
    background-color: #34495e;
    color: #3498db;
    border-left-color: #3498db;
}
.sidebar-primary .primary-icon {
    font-size: 20px;
}

/* 侧边栏底部版权信息 */
.sidebar-footer {
    margin-top: auto;
    padding: 10px 4px 14px;
    text-align: center;
    font-size: 10px;
    color: #7f8c8d;
    line-height: 1.5;
}
.sidebar-footer a {
    display: block;
    color: #3498db;
    text-decoration: none;
    font-size: 10px;
    margin-top: 2px;
}
.sidebar-footer a:hover {
    color: #5dade2;
    text-decoration: underline;
}

/* 第二列：副导航（默认收起，hover展开；加 .sidebar-pinned 时常驻展开） */
.sidebar-secondary {
    width: 0;
    overflow: hidden;
    background-color: #fff;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    transition: width 0.25s ease;
    display: flex;
    flex-direction: column;
}
.global-sidebar:hover .sidebar-secondary {
    width: 220px;
    overflow-y: auto;
}
.global-sidebar.sidebar-pinned .sidebar-secondary {
    width: 220px;
    overflow-y: auto;
    transition: none;  /* pinned 常驻展开：直接到位，无动画 */
}

/* 切换按钮：主分类列底部 */
.sidebar-toggle-btn {
    margin-top: auto;
    padding: 10px 0;
    color: #7f8c8d;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    transition: color 0.15s;
    user-select: none;
    border-top: 1px solid rgba(255,255,255,0.08);
    width: 100%;
}
.sidebar-toggle-btn:hover {
    color: #3498db;
}
.sidebar-toggle-btn .toggle-hint {
    font-size: 9px;
}
.global-sidebar.sidebar-pinned .sidebar-toggle-btn {
    color: #3498db;
}

/* 副面板 */
.secondary-panel {
    display: none;
    padding: 16px 0;
    min-height: 100%;
}
.secondary-panel.active {
    display: block;
}
.panel-title {
    font-size: 15px;
    font-weight: bold;
    color: #2c3e50;
    padding: 0 18px 10px;
    border-bottom: 1px solid #ecf0f1;
    margin-bottom: 8px;
}

/* 分组 */
.nav-group {
    margin-bottom: 2px;
}
.nav-group-title {
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    color: #34495e;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    transition: background 0.15s;
}
.nav-group-title:hover {
    background-color: #f4f6f9;
}
.nav-group-title .expand-arrow {
    font-size: 12px;
    transition: transform 0.2s;
}
.nav-group.collapsed .nav-group-title .expand-arrow {
    transform: rotate(-90deg);
}
.nav-group-body {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.25s ease;
}
.nav-group.collapsed .nav-group-body {
    max-height: 0;
}
.nav-group-body a {
    display: block;
    padding: 7px 18px 7px 32px;
    font-size: 13px;
    color: #555;
    text-decoration: none;
    transition: all 0.15s;
}
.nav-group-body a:hover {
    background-color: #f4f6f9;
    color: #3498db;
    padding-left: 36px;
}



/* ===== 整体布局（导航首页专用） ===== */
.nav-page-wrapper {
    display: flex;
    gap: 0;
    min-height: calc(100vh - 120px);
    background-color: #f4f6f9;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

/* ===== 左侧分类栏 ===== */
.nav-sidebar {
    width: 200px;
    background-color: #2c3e50;
    color: #ecf0f1;
    padding: 20px 0;
    flex-shrink: 0;
}
.nav-sidebar .sidebar-title {
    font-size: 18px;
    font-weight: bold;
    padding: 0 20px 16px;
    border-bottom: 1px solid #34495e;
    margin-bottom: 8px;
    letter-spacing: 1px;
}
.nav-sidebar .category-item {
    padding: 12px 20px;
    cursor: pointer;
    font-size: 15px;
    color: #bdc3c7;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-sidebar .category-item:hover {
    background-color: #34495e;
    color: #fff;
}
.nav-sidebar .category-item.active {
    background-color: #3498db;
    color: #fff;
    border-left-color: #e74c3c;
}
.nav-sidebar .category-item .cat-icon {
    margin-right: 8px;
}
.nav-sidebar .category-item .arrow {
    font-size: 12px;
}

/* ===== 右侧内容区 ===== */
.nav-content {
    flex: 1;
    padding: 24px 28px;
    overflow-y: auto;
}
.section-block {
    scroll-margin-top: 100px;
    display: none;
}
.section-block.active {
    display: block;
}
.section-block h3 {
    margin: 0 0 4px;
    font-size: 22px;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 8px;
    display: inline-block;
}
.section-block .section-desc {
    color: #7f8c8d;
    margin-bottom: 20px;
    font-size: 14px;
}

/* ===== 大按钮网格 ===== */
.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.button-grid .btn-group-title {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0 0;
    margin: 14px 0 2px;
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
    letter-spacing: 0.5px;
    border-left: 3px solid #3498db;
}
.button-grid .btn-group-title::before {
    content: '';
    width: 20px;
    height: 1px;
    background: #dfe4ea;
}
.button-grid .btn-group-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #ecf0f1;
}
.button-grid hr {
    grid-column: 1 / -1;
    border: none;
    height: 0;
    margin: 8px 0;
}
.big-btn {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    padding: 18px 22px;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    color: #2c3e50;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.25s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    min-height: 70px;
}
.big-btn:hover {
    background-color: #3498db;
    color: #fff;
    border-color: #3498db;
    text-decoration: none;
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(52,152,219,0.35);
}
.big-btn .btn-icon {
    font-size: 26px;
    color: #3498db;
    transition: color 0.25s;
}
.big-btn:hover .btn-icon {
    color: #fff;
}
.big-btn .btn-label {
    flex: 1;
}
.big-btn .btn-arrow {
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.25s;
}
.big-btn:hover .btn-arrow {
    opacity: 1;
}
.big-btn.external::after {
    content: "↗";
    font-size: 11px;
    margin-left: 4px;
    opacity: 0.7;
}

/* ===== 顶部面包屑区域不要太挤 ===== */
.page-header-row {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}
.page-header-row h2 {
    margin: 0;
    color: #2c3e50;
}

/* ===== 滚动条美化 ===== */
.nav-content::-webkit-scrollbar {
    width: 8px;
}
.nav-content::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 4px;
}
.nav-content::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}

/* ===== 响应式：移动端覆盖桌面端 fixed 布局 ===== */
@media (max-width: 768px) {
    /* 禁止横向溢出，body 正常滚动 */
    html, body {
        height: auto !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        max-width: 100vw !important;
    }
    /* 所有元素统一 box-sizing */
    * {
        box-sizing: border-box;
    }
    /* ===== 主布局：彻底脱离 flex，恢复块级流式 ===== */
    .layout-wrapper {
        display: block !important;
        position: static !important;
        width: 100% !important;
        max-width: 100vw !important;
        min-height: auto !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        overflow: hidden !important;
        gap: 0 !important;
    }
    .layout-main {
        display: block !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow: visible !important;
        flex: none !important;
        flex-grow: 0 !important;
        min-width: unset !important;
    }
    .layout-main .breadcrumb-wrapper {
        width: 100% !important;
        max-width: 100vw !important;
    }
    .layout-main .body-content {
        width: 100% !important;
        max-width: 100vw !important;
        overflow: visible !important;
    }

    /* ===== 侧边栏：改为顶部横向分类条 ===== */
    .global-sidebar {
        display: block !important;
        width: 100% !important;
        max-width: 100vw !important;
        height: auto !important;
        padding: 0 !important;
        flex: none !important;
        flex-shrink: 0 !important;
        align-self: auto !important;
        position: static !important;
    }
    /* 移动端隐藏副导航列 */
    .sidebar-secondary {
        display: none !important;
        width: 0 !important;
    }
    .global-sidebar:hover .sidebar-secondary {
        display: none !important;
        width: 0 !important;
    }
    /* 主分类列改为横向滚动 */
    .sidebar-primary {
        width: 100% !important;
        max-width: 100vw !important;
        flex-direction: row;
        overflow-x: auto !important;
        overflow-y: hidden;
        padding: 8px 6px !important;
        height: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    .sidebar-primary .primary-item {
        flex-direction: row;
        gap: 6px;
        padding: 8px 14px !important;
        border-left: none !important;
        border-bottom: 3px solid transparent;
        white-space: nowrap;
        font-size: 13px;
        flex-shrink: 0;
        width: auto;
        height: auto !important;
        max-height: none !important;
    }
    .sidebar-primary .primary-item.active {
        border-left-color: transparent !important;
        border-bottom-color: #3498db;
    }
    /* 隐藏移动端侧边栏底部版权 */
    .sidebar-footer {
        display: none;
    }

    /* ===== 导航首页也适配 ===== */
    .nav-page-wrapper {
        flex-direction: column;
        min-height: auto;
        width: 100%;
        max-width: 100vw;
    }
    .nav-sidebar {
        width: 100%;
        padding: 10px 0;
    }
    .nav-sidebar .sidebar-title {
        display: none;
    }
    .nav-sidebar .category-list {
        display: flex;
        overflow-x: auto;
        padding: 0 10px;
        -webkit-overflow-scrolling: touch;
    }
    .nav-sidebar .category-item {
        border-left: none;
        border-bottom: 3px solid transparent;
        white-space: nowrap;
        padding: 8px 14px;
        flex-shrink: 0;
    }
    .nav-sidebar .category-item.active {
        border-left: none;
        border-bottom-color: #e74c3c;
    }
    .button-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }
}