/* static/css/style.css */
:root {
    --primary-color: #0969da;
    --primary-dim: rgba(9, 105, 218, 0.06);
    --secondary-color: #8250df;
    --bg-color: #f6f8fa;
    --card-bg-color: #ffffff;
    --border-color: #d0d7de;
    --text-color: #1f2328;
    --text-muted-color: #656d76;
    --font-family-tech: 'Orbitron', sans-serif;
    --font-family-main: -apple-system, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", system-ui, sans-serif;
    --sidebar-width: 240px;
    --navbar-height: 52px;
    --green: #1a7f37;
    --red: #cf222e;
}

/* --- 1. 全局滚动条美化 (核心优化) --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: #c1c8cd;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

body {
    font-family: var(--font-family-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow-x: hidden;
    height: 100vh;
    font-size: 14px;
    line-height: 1.5;
}

/* 通用文字颜色 */
.text-green { color: var(--green) !important; }
.text-red   { color: var(--red) !important; }
.text-primary-glow { color: var(--primary-color); font-weight: 600; }

#wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
}

/* --- 2. Sidebar 优化 --- */
.sidebar-wrapper {
    background-color: var(--card-bg-color);
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    /* 防止压缩 */
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: margin .25s ease-out;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* 让列表区域独立滚动，不影响 Logo 区域 */
.sidebar-content {
    overflow-y: auto;
    flex-grow: 1;
    /* 隐藏 Sidebar 内部滚动条但保留功能 */
    scrollbar-width: thin;
}

.sidebar-heading {
    padding: 0 1rem;
    height: var(--navbar-height);
    font-family: var(--font-family-tech);
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar-heading .logo {
    width: 28px;
    height: 28px;
    margin-right: 12px;
}

/* 列表项交互增强 */
.list-group-item {
    background-color: transparent;
    border: none;
    color: var(--text-muted-color);
    font-weight: 500;
    padding: 0.55rem 1rem;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
    font-size: 0.875rem;
}

.list-group-item:hover {
    color: var(--text-color);
    background-color: var(--primary-dim);
    border-left-color: var(--primary-color);
}

/* Active 状态增强 */
.list-group-item.active {
    color: var(--primary-color);
    font-weight: 600;
    background-color: var(--primary-dim);
    border-left-color: var(--primary-color);
}

/* 特殊的主按钮样式 */
.list-group-item-primary {
    background-color: rgba(9, 105, 218, 0.06);
    margin: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(9, 105, 218, 0.2);
    text-align: center;
    border-left: 1px solid rgba(9, 105, 218, 0.2);
}

.list-group-item-primary:hover {
    background-color: rgba(9, 105, 218, 0.12);
    color: var(--primary-color) !important;
    border-color: var(--primary-color);
}

/* 菜单项统一样式：所有项字体颜色、字重一致 */
.list-group-item .nav-main-label {
    color: var(--text-color);
    font-weight: 500;
}

.menu-category {
    padding: 1.25rem 1rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: #656d76;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.menu-group {
    border-bottom: 1px solid rgba(208, 215, 222, 0.35);
}

.menu-tools {
    display: flex;
    justify-content: flex-end;
    padding: 0 0.9rem 0.35rem;
}

.menu-tools-inline {
    padding-top: 0.2rem;
}

.menu-tool-btn {
    border: 1px solid var(--border-color);
    background: #fff;
    color: var(--text-muted-color);
    font-size: 0.7rem;
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
    line-height: 1.2;
}

.menu-tool-btn:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.menu-group-items {
    transition: max-height 0.2s ease;
}

.menu-group.collapsed .menu-group-items {
    display: none;
}

/* compact-aux 已废弃 — 所有菜单全部铺开展示 */

.menu-toggle {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.menu-toggle .menu-chevron {
    transition: transform 0.2s ease;
    font-size: 0.65rem;
    color: var(--text-muted-color);
}

.menu-group.collapsed .menu-chevron {
    transform: rotate(-90deg);
}

.list-group-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-main-label {
    display: inline-flex;
    align-items: center;
    min-width: 0;
}

/* --- 3. Page Content 优化 --- */
#page-content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* 修复 DataTables 在 Flex 容器中溢出的 Bug */
}

/* Navbar */
.top-navbar {
    height: var(--navbar-height);
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 999;
}

.page-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    margin-left: 0.75rem;
}

/* 移动端适配逻辑 */
@media (max-width: 768px) {
    .sidebar-wrapper {
        margin-left: calc(-1 * var(--sidebar-width));
        position: fixed;
        /* 移动端改为浮动 */
        height: 100%;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
    }

    #wrapper.toggled .sidebar-wrapper {
        margin-left: 0;
    }

    /* 遮罩层 (配合 JS) */
    #wrapper.toggled::after {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: 900;
        backdrop-filter: blur(3px);
    }
}

/* --- 4. 组件优化 --- */
.card {
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
}

/* 表单控件优化 */
.form-control,
.form-select {
    background-color: #ffffff;
    border: 1px solid #d0d7de;
    color: #1f2328;
    font-size: 0.875rem;
    border-radius: 6px;
}

.form-control:focus,
.form-select:focus {
    background-color: #ffffff;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(9, 105, 218, 0.15);
    color: #1f2328;
}

.form-label {
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}

/* 按钮 */
.btn-primary {
    background-color: var(--primary-color);
    border: none;
    color: #fff;
    font-weight: 600;
    font-size: 0.875rem;
}

.btn-primary:hover {
    background-color: #4c9aed;
    color: #fff;
}

/* 统计卡片 */
.stat-card .card-body { padding: 1rem 1.25rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; margin: 0.25rem 0; }

/* --- 布局核心样式 --- */
/* 减去顶部导航栏高度 (假设约 56px)，实现全屏无滚动布局 */
.layout-wrapper {
    height: calc(100vh - 58px);
    overflow: hidden;
}

/* 左侧列表栏 */
.sidebar-panel {
    background-color: var(--card-bg-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.strategy-list-container {
    overflow-y: auto;
    flex: 1;
}

/* 列表项悬停效果 */
.strategy-list-item {
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.strategy-list-item:hover,
.strategy-list-item.active {
    background-color: rgba(9, 105, 218, 0.06);
    border-left-color: var(--primary-color);
}

/* 中间编辑器区域 */
.editor-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
}

#monaco-container {
    flex: 1;
    /* 自动占满剩余高度 */
    width: 100%;
}

/* 运行时 HUD 仪表盘 (Glassmorphism) */
.dashboard-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    color: #1f2328;
}

.hud-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* 右侧配置栏 */
.config-panel {
    background-color: var(--card-bg-color);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.config-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* 模拟终端日志 */
.console-box {
    height: 200px;
    background-color: #f6f8fa;
    border-top: 1px solid var(--border-color);
    font-family: 'Consolas', monospace;
    font-size: 0.85rem;
    padding: 10px;
    overflow-y: auto;
    color: #1f2328;
}

.console-line {
    margin-bottom: 2px;
}

.console-timestamp {
    color: #6c757d;
    margin-right: 8px;
}

/* 解决编辑器高度坍塌问题 */
.layout-wrapper {
    height: calc(100vh - 60px);
    overflow: hidden;
}

.editor-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

#monaco-container {
    flex-grow: 1;
    min-height: 500px;
    border-bottom: 1px solid var(--border-color);
}


/* 侧边栏滚动 */
.strategy-list-container {
    height: calc(100vh - 120px);
    overflow-y: auto;
}

.config-scroll-area {
    height: calc(100vh - 350px);
    overflow-y: auto;
    padding: 15px;
}

/* 运行状态遮罩层优化 */
.dashboard-overlay {
    position: absolute;
    top: 50px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: none;
    /* 初始隐藏 */
}

.hud-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    min-width: 140px;
}

.font-tech {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    letter-spacing: 1px;
}

.x-small {
    font-size: 0.7rem;
}

#monaco-container {
    width: 100%;
    height: calc(100vh - 160px);
    /* 动态计算高度 */
}