/* =========================================
   1. 全局变量与基础设置
   ========================================= */
:root {
    --primary: #1E88E5;
    --primary-dark: #1565C0;
    --success: #4CAF50;
    --warning: #FF9800;
    --danger: #F44336;
    --dark: #212121;
    --gray-bg: #F5F7FA;
    --border-color: #E0E0E0;
    --text-main: #2C3E50;
    --text-light: #7F8C8D;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--gray-bg);
    color: var(--text-main);
    line-height: 1.6;
    padding-bottom: 50px;
}

/* =========================================
   2. 导航栏
   ========================================= */
.navbar {
    background-color: var(--primary);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 4px 12px rgba(30,136,229,0.2);
}
.container { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
.nav-brand { display: flex; align-items: center; gap: 12px; }
.nav-brand h1 { font-size: 1.5rem; font-weight: 600; }
.version { font-size: 0.75rem; background: rgba(255,255,255,0.2); padding: 3px 10px; border-radius: 12px; }
.nav-desc { font-size: 0.9rem; opacity: 0.9; margin-top: 5px; }

/* =========================================
   3. 控制面板 (Flex Wrap 防止溢出)
   ========================================= */
.control-panel {
    display: flex;
    flex-wrap: wrap; /* 关键：允许换行 */
    gap: 20px;
    margin-top: 25px;
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.03);
    align-items: stretch;
}

.panel-section {
    flex: 1;
    min-width: 260px; /* 最小宽度 */
    display: flex;
    flex-direction: column;
}

.panel-section.upload-area {
    flex: 1.2;
    min-width: 300px;
    border-left: 1px solid #f0f0f0;
    border-right: 1px solid #f0f0f0;
    padding: 0 20px;
}

/* 移动端去边框 */
@media (max-width: 900px) {
    .panel-section.upload-area { border: none; padding: 0; }
}

.panel-section h3 {
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
    font-weight: 700;
}

/* 控件 */
.form-group { margin-bottom: 15px; }
.radio-group { display: flex; gap: 15px; }
.radio-group label { cursor: pointer; display: flex; align-items: center; gap: 5px; }

/* 拖拽区 */
.drop-zone {
    flex-grow: 1;
    border: 2px dashed #BBDEFB;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    background: #FAFDFF;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 150px;
}
.drop-zone:hover { background: #E3F2FD; border-color: var(--primary); }
.drop-zone .icon { font-size: 2.5rem; margin-bottom: 10px; opacity: 0.8; }
.file-info { margin-top: 10px; font-size: 0.9rem; color: var(--success); font-weight: 600; word-break: break-all; }
.validation-msg { font-size: 0.85rem; margin-top: 8px; color: var(--danger); }

/* 按钮 */
.btn-group { display: flex; flex-direction: column; gap: 12px; }
.btn { border: none; padding: 12px 20px; border-radius: 6px; cursor: pointer; font-size: 0.95rem; font-weight: 600; transition: all 0.2s; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: #CFD8DC; cursor: not-allowed; }
.btn-secondary { background: white; border: 1px solid var(--primary); color: var(--primary); padding: 6px 16px; font-size: 0.85rem; margin-top: 10px; border-radius: 20px;}
.btn-warning { background: var(--warning); color: white; }
.btn-outline { background: white; border: 1px solid #B0BEC5; color: #546E7A; }
.btn-small { padding: 6px 16px; font-size: 0.85rem; background: var(--success); color: white; border-radius: 4px; }

/* =========================================
   4. 结果区域 (横向滚动支持)
   ========================================= */
.result-section {
    margin-top: 30px;
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.03);
    display: block; /* 确保显示 */
}

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; border-bottom: 2px solid #f0f0f0; padding-bottom: 15px; }

/* 表格容器：允许横向滚动 */
.table-container {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.result-table {
    width: 100%;
    min-width: 900px; /* 最小宽度防止挤压 */
    border-collapse: collapse;
    font-size: 0.95rem;
}
.result-table th { background: #F4F6F8; padding: 16px 12px; text-align: left; font-weight: 700; border-bottom: 2px solid #ddd; white-space: nowrap; }
.result-table td { padding: 14px 12px; border-bottom: 1px solid #eee; vertical-align: middle; }
.result-table tr:hover { background-color: #FAFBFD; }

/* 类别标签 */
.grade-badge { display: inline-block; padding: 5px 12px; border-radius: 20px; color: white; font-weight: 700; font-size: 0.85rem; min-width: 70px; text-align: center; }
.grade-I, .grade-II { background-color: var(--primary); }
.grade-III { background-color: var(--success); }
.grade-IV { background-color: var(--warning); }
.grade-V { background-color: var(--danger); }
.grade-VI { background-color: var(--dark); }

/* 超标标签 */
.exceeded-tag { display: inline-block; background: #FFEBEE; color: #D32F2F; border: 1px solid #FFCDD2; padding: 3px 8px; border-radius: 4px; font-size: 0.8rem; margin-right: 6px; white-space: nowrap; }
.exceeded-tag.priority { font-weight: 800; border-color: #B71C1C; background: #FFCDD2; color: #B71C1C; }
.text-normal { color: #aaa; font-style: italic; font-size: 0.9rem; }

/* =========================================
   5. Tooltip
   ========================================= */
.tooltip-wrapper { position: relative; display: inline-block; cursor: help; }
.data-icon { font-size: 1.3rem; color: #B0BEC5; transition: all 0.2s; padding: 5px; }
.tooltip-wrapper:hover .data-icon { color: var(--primary); transform: scale(1.2); }

.tooltip-content {
    visibility: hidden; opacity: 0;
    position: absolute; bottom: 80%; right: 100%;
    width: 320px; background-color: white; color: var(--text-main);
    text-align: left; padding: 15px; border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15); z-index: 1000;
    border: 1px solid #eee; transition: opacity 0.2s, transform 0.2s;
    transform: translateY(10px); pointer-events: none;
}
.tooltip-wrapper:hover .tooltip-content { visibility: visible; opacity: 1; transform: translateY(0); }

.raw-data-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-top: 10px; }
.raw-item { display: flex; justify-content: space-between; border-bottom: 1px dashed #eee; padding-bottom: 3px; font-size: 0.85rem; }
.raw-label { color: #90A4AE; }
.raw-val { font-weight: 600; font-family: monospace; color: #37474F; }

/* =========================================
   6. 辅助与响应式
   ========================================= */
.info-section { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-top: 30px; }
.info-card { background: white; padding: 25px; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.03); }
.std-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.std-table th, .std-table td { padding: 8px; border: 1px solid #EEE; text-align: center; }
.std-table th { background: #FAFAFA; }
.rules-list li { margin-bottom: 8px; font-size: 0.9rem; color: #666; margin-left: 20px; }

.hidden { display: none !important; }
.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: rgba(33,33,33,0.9); color: white; padding: 12px 30px; border-radius: 50px; z-index: 2000; }
.toast.error { background: #D32F2F; }

@media (max-width: 900px) { .info-section { grid-template-columns: 1fr; } }
@media (max-width: 768px) {
    .control-panel { flex-direction: column; }
    .panel-section { width: 100%; border: none; padding: 0; }
    .tooltip-content { position: fixed; bottom: 50%; right: 50%; transform: translate(50%, 50%) !important; width: 80vw; }
}