:root {
    --primary-color: #007bff;
    --border-color: #dee2e6;
    --background-light: #f8f9fa;
    --text-color: #212529;
    --button-disabled-bg: #adb5bd;
    --button-disabled-color: #f8f9fa;
    --page-gutter: 5px; /* 定义全局边距 */
}

/* --- 1. 基础页面和字体布局 --- */
html, body {
    height: 100%;
    margin: 0;
    overflow: hidden; /* 保持页面主体不滚动 */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    padding: var(--page-gutter);
    background-color: #f0f2f5;
    color: var(--text-color);
    font-size: 14px;
    box-sizing: border-box;
}

ul {
    list-style-type: none;
    padding-left: 20px;
}

li {
    padding: 4px 0;
}

/* --- 2. 主容器和头部 --- */
.toolbox-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: none;
}

.toolbox-header {
    padding: 0 0 15px 0;
    flex-shrink: 0;
}

.toolbox-header .title-version {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.toolbox-header h1 {
    font-size: 22px;
    margin: 0;
    color: #333;
}

#version-info {
    font-size: 12px;
    color: #6c757d;
    background-color: #e9ecef;
    padding: 3px 8px;
    border-radius: 5px;
}

.toolbox-header .description {
    font-size: 14px;
    color: #555;
    margin: 0;
    margin-left: 20px;
}

/* --- 3. 标签页导航与内容区 --- */
.tab-navigation {
    display: flex;
    gap: 5px;
    margin-bottom: -1px;
    flex-shrink: 0;
}

.tab-button {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid var(--border-color);
    border-bottom: none;
    background-color: #f8f9fa;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: all 0.2s ease-in-out;
    white-space: nowrap;
}

.tab-button.active {
    background-color: white;
    color: var(--primary-color);
    border-top: 3px solid var(--primary-color);
    padding-top: 6px; /* 微调以匹配边框高度 */
}

.tab-content {
    background-color: white;
    padding: var(--page-gutter);
    border-radius: 0 8px 8px 8px;
    border: 1px solid var(--border-color);
    flex-grow: 1; /* 关键：填满剩余垂直空间 */
    overflow: hidden; /* 隐藏内部超出的部分，让子元素自己处理滚动 */
    display: flex;
    margin-bottom: var(--page-gutter); /* 确保下方有5px边距 */
}

.tab-panel {
    display: none;
    width: 100%;
}

.tab-panel.active {
    display: flex;
}

/* --- 4. 高校库/专业目录/招生计划页 内部布局 --- */
.app-container {
    display: flex;
    flex-direction: row;
    gap: var(--page-gutter);
    height: 100%;
    width: 100%;
}

.left-panel, .right-panel {
    display: flex;
    flex-direction: column;
    gap: var(--page-gutter);
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* 招生计划页面 - 保持原有40%:60%比例 */
#app-container-plans .left-panel {
    width: 40%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: var(--page-gutter);
    height: 100%;
}

#app-container-plans .right-panel {
    width: 60%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: var(--page-gutter);
    height: 100%;
}

/* 高校库和专业目录页面 - 使用新的35%:65%比例 */
#app-container-universities .left-panel,
#app-container-majors .left-panel {
    width: 35%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: var(--page-gutter);
    height: 100%;
}

#app-container-universities .right-panel,
#app-container-majors .right-panel {
    width: 65%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: var(--page-gutter);
    height: 100%;
}

/* 确保未登录状态下也使用相同的布局 */
/* 覆盖index.html中的内联样式，确保未登录状态下也使用flex布局 */
body.logged-out .tab-content {
    display: flex !important;
    flex-grow: 1 !important;
    overflow: hidden !important;
}

body.logged-out .left-panel {
    width: 40% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    flex-shrink: 0 !important;
    overflow: hidden !important;
}

body.logged-out .right-panel {
    width: 60% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    flex-shrink: 0 !important;
    overflow: hidden !important;
}

/* 左侧筛选结果滚动框 */
.major-tree-container {
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 8px;
    overflow-y: auto;
    flex-grow: 1; /* 关键：让它填满 .left-panel 的所有剩余空间 */
    min-height: 0; /* 关键：确保滚动条能出现 */
    height: 100%;
    box-sizing: border-box;
}

/* 确保未登录状态下左侧面板也有滚动条 */
body.logged-out .major-tree-container {
    overflow-y: auto !important;
    height: 100% !important;
    flex-grow: 1 !important;
    min-height: 0 !important;
}

/* 右侧详情框 - 高校库和专业目录标签页共用 */
.details-content {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    overflow-y: auto;
    height: 75%; /* 高度占父容器(.right-panel)的75% */
    box-sizing: border-box;
    flex-shrink: 0;
}

/* 右侧输出框 - 高校库和专业目录标签页共用 */
.output-container {
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 8px;
    height: 25%; /* 高度占父容器(.right-panel)的25% */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

/* 统一调整所有容器标题的边距为5px */
.details-content h3, .output-header h3, #plan-details-content h3, #plan-chart-area h3, #plan-output-container h3 {
    margin-top: 5px !important;
    margin-bottom: 5px !important;
    font-size: 18px;
    color: var(--primary-color);
}

/* 确保未登录状态下右侧面板也使用固定高度比例 */
body.logged-out .details-content {
    height: 75% !important;
    flex-shrink: 0 !important;
    overflow-y: auto !important;
}

body.logged-out .output-container {
    height: 25% !important;
    flex-shrink: 0 !important;
}

/* --- 5. 招生计划页 专属独立布局 --- */
/* 恢复原始布局 */
#app-container-plans {
    display: flex;
    flex-direction: row;
    gap: var(--page-gutter);
    height: 100%;
    width: 100%;
}

#app-container-plans .right-panel {
    display: flex;
    flex-direction: column;
    gap: var(--page-gutter);
    height: 100%;
}

/* 右侧上中下三部分按40%:35%:25%高度比例 */
#plan-details-content {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding-top: 5px;
    padding-right: 10px;
    padding-bottom: 10px;
    padding-left: 10px;
    overflow-y: auto;
    height: 40%;
    min-height: 0;
    box-sizing: border-box;
}

#plan-chart-area {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding-top: 5px;
    padding-right: 15px;
    padding-bottom: 15px;
    padding-left: 15px;
    height: 35%;
    min-height: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

#plan-output-container {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding-top: 5px;
    padding-right: 10px;
    padding-bottom: 10px;
    padding-left: 10px;
    height: 25%;
    min-height: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* 确保图表自适应显示比例，不越界 */
#plan-chart-area canvas {
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain;
}

/* --- 6. 通用组件样式 --- */
.controls-toolbar { display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.filter-controls { display: flex; flex-wrap: wrap; gap: 10px; }
.filter-group { border: 1px solid #ddd; border-radius: 5px; padding: 5px 8px; position: relative; background-color: #fff; }
.filter-group summary { font-weight: 500; cursor: pointer; padding: 3px 20px 3px 5px; list-style: none; transition: all 0.2s; border-radius: 4px; }
.filter-group summary.filter-active { background-color: var(--primary-color); color: white; }
.filter-group summary.filter-active::after { color: white; }
.filter-group summary::-webkit-details-marker { display: none; }
.filter-group summary::after { content: ' ▼'; font-size: 0.8em; color: #666; position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.filter-group[open] summary::after { content: ' ▲'; }
.filter-group .filter-options { position: absolute; background-color: white; border: 1px solid #ccc; box-shadow: 0 4px 8px rgba(0,0,0,0.1); border-radius: 5px; padding: 10px; margin-top: 5px; z-index: 10; display: flex; flex-direction: column; gap: 8px; max-height: 250px; overflow-y: auto; }
.filter-options label { display: flex; align-items: center; gap: 5px; white-space: nowrap; font-weight: normal; }
.header-controls { display: flex; align-items: center; flex-wrap: nowrap; gap: 10px; flex-shrink: 0; margin-bottom: 10px; }
.header-controls .search-container { display: flex; gap: 8px; flex-grow: 1; }
.switcher { display: flex; border: 1px solid var(--primary-color); border-radius: 8px; overflow: hidden; }
.switcher input[type="radio"] { display: none; }
.switcher label { padding: 6px 12px; font-size: 14px; cursor: pointer; transition: all 0.2s ease-in-out; color: var(--primary-color); user-select: none; white-space: nowrap; }
.switcher input[type="radio"]:checked + label { background-color: var(--primary-color); color: white; }
.switcher label:not(:last-of-type) { border-right: 1px solid var(--primary-color); }
.query-button { padding: 6px 18px; font-size: 14px; background-color: var(--primary-color); color: white; border: none; border-radius: 8px; cursor: pointer; transition: background-color 0.2s; white-space: nowrap; }
.query-button:hover { background-color: #0056b3; }
.tree-label, .major-label, .uni-label { cursor: pointer; user-select: none; transition: background-color 0.2s; padding: 2px 4px; border-radius: 3px; }
.tree-label:hover, .major-label:hover, .uni-label:hover { color: var(--primary-color); background-color: #e9f5ff; }
.caret::before { content: "+"; color: black; display: inline-block; margin-right: 8px; font-weight: bold; width: 14px; transition: transform 0.2s; }
.caret-down::before { transform: rotate(45deg); }
.nested { display: none; }
.active { display: block; }
.output-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; flex-shrink: 0;}
.output-header h3 { margin: 0; display: flex; align-items: center; }
.output-button { padding: 6px 12px; font-size: 14px; background-color: var(--primary-color); color: white; border: none; border-radius: 8px; cursor: pointer; transition: background-color 0.2s; white-space: nowrap; }
.output-button:hover { background-color: #0056b3; }
.output-button.disabled { background-color: var(--button-disabled-bg); color: var(--button-disabled-color); cursor: not-allowed; pointer-events: none; }
textarea { width: 100%; box-sizing: border-box; flex-grow: 1; font-size: 13px; padding: 10px; border-radius: 5px; border: 1px solid var(--border-color); resize: none; }
.details-content p { margin: 0 0 4px 0; line-height: 1.5; }
.details-content h3 { margin-top: 5px; margin-bottom: 5px; font-size: 18px; color: var(--primary-color);}
/* 确保容器内第一行文本与容器边距保持5px */
.details-content > :first-child, .output-header > :first-child, #plan-details-content > :first-child, #plan-chart-area > :first-child, #plan-output-container > :first-child {
    margin-top: 5px !important;
}
.plan-filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; flex-shrink: 0; }
.plan-interactive-controls { display: flex; gap: 10px; margin-bottom: 10px; align-items: stretch; flex-shrink: 0; }
.input-column { display: flex; flex-direction: column; gap: 5px; flex-grow: 1; }
.input-column input, .input-column textarea { padding: 8px 12px; font-size: 14px; font-family: inherit; border: 1px solid var(--border-color); border-radius: 8px; box-sizing: border-box; width: 100%; }
.input-column textarea { resize: vertical; }
.button-column { display: flex; flex-direction: column; justify-content: space-between; flex-shrink: 0; gap: 5px; }
.button-column .query-button, .button-column .switcher, .button-column .output-button { width: 100%; box-sizing: border-box; display: flex; justify-content: center; }
.content-placeholder { display: flex; align-items: center; justify-content: center; height: 100%; color: #6c757d; }
#query-results-message { color: var(--primary-color); margin-bottom: 10px; font-weight: 500; }
/* --- 基础表格布局 --- */
.plan-list-view { display: table; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.plan-list-view .list-header { display: table-header-group; font-weight: 600; }
.plan-list-view .list-header .list-cell { background-color: #f8f9fa; position: sticky; top: -1px; z-index: 2; }
.plan-list-view .list-body { display: table-row-group; }
.plan-list-view .list-row { display: table-row; }
.plan-list-view .list-cell { display: table-cell; padding: 8px 10px; border-bottom: 1px solid #dee2e6; vertical-align: middle; font-size: 13px; }
.plan-list-view .list-row:hover .list-cell:not(.sticky-col) { background-color: #f1f3f5; }
.plan-list-view .list-cell input[type="checkbox"] { vertical-align: middle; }

/* --- 固定定位核心代码 --- */
.plan-list-view .list-cell:first-child, .plan-list-view .list-cell:nth-child(2) { position: sticky; left: 0; background-color: white; border-right: 1px solid #dee2e6; z-index: 1; }
.plan-list-view .list-row:hover .list-cell:first-child, .plan-list-view .list-row:hover .list-cell:nth-child(2) { background-color: #f1f3f5; }
.plan-list-view .list-header .list-cell:first-child, .plan-list-view .list-header .list-cell:nth-child(2) { z-index: 3; }
.plan-list-view .list-header .list-cell:first-child { z-index: 4; }
.plan-list-view .list-cell:nth-child(2) { left: 8px; }

/* --- 自定义列宽 (最关键的部分) --- */
.plan-list-view .list-cell.col-select { width: 8px; } /* 选择 */
.plan-list-view .list-cell.col-uni-major { width: 280px; white-space: normal; word-break: break-all; } /* 院校专业 */
.plan-list-view .list-cell:nth-child(3) { width: 20px; } /* 省份 */
.plan-list-view .list-cell:nth-child(4) { width: 20px; } /* 城市 */
.plan-list-view .list-cell:nth-child(5) { width: 50px; white-space: normal; word-break: break-all; } /* 学费 */
.plan-list-view .list-cell:nth-child(6) { width: 55px; white-space: normal; word-break: break-all; } /* 选科要求 */
.plan-list-view .list-cell:nth-child(7) { width: 30px; } /* 分数线 */
.plan-list-view .list-cell:nth-child(8) { width: 45px; } /* 位次号 */
.plan-list-view .list-cell.col-notes { width: 350px; white-space: normal; word-break: break-all; } /* 专业简注 */

#plan-details-content .detail-group { margin-bottom: 8px; }
#plan-details-content .detail-group h4 { margin: 0 0 6px 0; font-size: 15px; border-bottom: 1px solid var(--border-color); padding-bottom: 4px; }
#plan-details-content .detail-row, #plan-details-content .detail-item { display: flex; margin-bottom: 1px; line-height: 1.4; font-size: 13px; }
#plan-details-content .detail-multi-row { display: flex; flex-wrap: wrap; }
#plan-details-content .detail-item { margin-right: 20px; }
#plan-details-content .detail-label { flex-shrink: 0; width: 95px; font-weight: 600; color: #333; }
#plan-details-content .detail-value { word-break: break-all; }
#plan-details-content a { color: var(--primary-color); text-decoration: none; }
#plan-details-content a:hover { text-decoration: underline; }
#filter-range .filter-options { width: auto; align-items: center; }
/* 只修改“招生计划”标签页内、位于“输入区域”(.input-column)的 textarea 高度。
  这可以精确地指向“院校名称关键字”和“专业名称关键字”下方的输入框，
  而不会影响到右侧的“意向计划”输出框。*/
#app-container-plans .input-column textarea { min-height: 80px; /* 设置一个较小的最小高度 */ flex-grow: 0; /* 取消其在垂直方向上的弹性增长 */ }

/* 平板设备优化 */
@media (max-width: 1024px) { 
    body { overflow-y: auto; padding: 10px; } 
    .toolbox-container { height: auto; } 
    .app-container { flex-direction: column; } 
    .left-panel, .right-panel { width: 100%; height: auto; max-height: 80vh; } 
    .right-panel { margin-top: 10px; } 
    .tab-navigation { overflow-x: auto; padding-bottom: 5px; } 
}

/* 手机设备优化 */
@media (max-width: 768px) {
    body { padding: 5px; font-size: 13px; }
    .description { display: none; } /* 在手机端隐藏描述文本 */
    .toolbox-header h1 { font-size: 18px; }
    .tab-button { padding: 6px 12px; font-size: 13px; }
    
    /* 确保招生计划标签页的所有容器在手机端都能正确显示 */
    #app-container-plans { flex-direction: column; }
    #app-container-plans .right-panel {
        display: flex !important;
        flex-direction: column;
        width: 100% !important;
        margin-top: 10px;
        flex-grow: 1;
    }
    
    /* 为右侧面板的三个主要容器设置明确的显示属性和高度 */
    #plan-details-content,
    #plan-chart-area,
    #plan-output-container {
        display: flex !important;
        flex-direction: column;
        height: auto !important;
        min-height: 150px !important;
        max-height: 300px;
    }
    
    /* 为图表区域设置合适的最小高度 */
    #plan-chart-area {
        min-height: 200px !important;
    }
    .filter-controls { flex-wrap: wrap; gap: 8px; } /* 允许筛选控件自动换行 */
    .controls-toolbar { flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; } /* 允许工具栏内容自动换行并保持对齐 */
    .header-controls { flex-wrap: wrap; align-items: center; gap: 10px; } /* 允许头部控件自动换行 */
    .header-controls .search-container { flex-wrap: wrap; gap: 8px; } /* 允许搜索容器内的元素自动换行 */
    .plan-interactive-controls { flex-wrap: wrap; gap: 8px; align-items: center; } /* 允许交互式控件自动换行 */
    .button-column { flex-direction: row; flex-wrap: wrap; justify-content: center; } /* 改变按钮列布局为水平并允许换行 */
    .button-column .query-button, .button-column .switcher, .button-column .output-button { width: auto; flex-shrink: 0; } /* 让按钮宽度自适应内容 */
    .switcher { margin: 0 5px; } /* 调整switcher间距 */
    .switcher label { padding: 6px 12px; font-size: 13px; } /* 确保在小屏幕上与查询按钮高度一致 */
    .input-column input, .input-column textarea { padding: 6px 10px; font-size: 13px; }
    .query-button, .output-button { padding: 6px 14px; font-size: 13px; }
    .details-content h3, .output-header h3, #plan-details-content h3, #plan-chart-area h3, #plan-output-container h3 { font-size: 16px; }
    /* 确保所有内容在小屏幕上正确显示 */
     body.logged-out .left-panel, body.logged-out .right-panel,
     body:not(.logged-out) .left-panel, body:not(.logged-out) .right-panel {
         display: flex !important;
         flex-direction: column;
         width: 100% !important; /* 覆盖之前的固定百分比 */
         height: auto !important;
     }
}

/* 选考科目要求表格样式 */
.table-container {
    overflow-x: auto;
    margin-top: 10px;
    border-radius: 5px;
    border: 1px solid #ddd;
}

.subject-requirements-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.subject-requirements-table th {
    background-color: #f2f2f2;
    padding: 10px;
    text-align: left;
    border-bottom: 2px solid #ddd;
    font-weight: bold;
}

.subject-requirements-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

.subject-requirements-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.subject-requirements-table tr:hover {
    background-color: #f5f5f5;
}

