/* ============================================================
   内审不符合项AI智能分析工具 - 页面样式
   简约企业风格：蓝灰主色调，从上往下布局
   二期：选项卡 / 批量表格 / 统计看板 / 知识库
   ============================================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background-color: #f4f6f9;
  color: #333;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- 页面标题 ---------- */
.page-header {
  background: linear-gradient(135deg, #1f4e8c 0%, #2f6fb2 100%);
  color: #fff;
  text-align: center;
  padding: 28px 16px 22px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 1px;
}

.page-header .sub-title {
  margin-top: 8px;
  font-size: 13px;
  opacity: 0.85;
}

/* ---------- 主体容器 ---------- */
.container {
  width: 100%;
  max-width: 980px;
  margin: 24px auto 40px;
  padding: 0 16px;
  flex: 1;
}

/* ---------- 选项卡 ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid #e3e8ef;
  margin-bottom: 18px;
}

.tab {
  padding: 10px 26px;
  font-size: 15px;
  border: none;
  background: transparent;
  color: #6c757d;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
}

.tab:hover { color: #1f4e8c; }

.tab.active {
  color: #1f4e8c;
  font-weight: 600;
  border-bottom-color: #1f4e8c;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- 面板/卡片通用 ---------- */
.panel,
.card {
  background: #fff;
  border: 1px solid #e3e8ef;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(31, 78, 140, 0.06);
}

.input-panel {
  padding: 20px;
  margin-bottom: 20px;
}

/* ---------- 输入区 ---------- */
.field {
  margin-bottom: 16px;
  flex: 1;
}

.field-row {
  display: flex;
  gap: 16px;
}

.field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #1f4e8c;
}

.field .required {
  color: #d93025;
  font-size: 12px;
  font-weight: normal;
}

.field .optional {
  color: #8a94a6;
  font-size: 12px;
  font-weight: normal;
}

.field textarea,
.field input[type="text"],
#kbSearch {
  width: 100%;
  resize: vertical;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.6;
  border: 1px solid #cfd6e0;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.field textarea:focus,
.field input:focus,
#kbSearch:focus {
  border-color: #2f6fb2;
  box-shadow: 0 0 0 3px rgba(47, 111, 178, 0.15);
}

/* 校验不通过时的红框提示 */
.field textarea.invalid {
  border-color: #d93025;
  box-shadow: 0 0 0 3px rgba(217, 48, 37, 0.12);
}

/* ---------- 按钮 ---------- */
.btn-group {
  display: flex;
  gap: 12px;
}

.btn {
  padding: 10px 28px;
  font-size: 15px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity 0.2s, background-color 0.2s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background-color: #1f4e8c;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background-color: #2f6fb2;
}

.btn-default {
  background-color: #fff;
  color: #555;
  border-color: #cfd6e0;
}

.btn-default:hover:not(:disabled) {
  background-color: #f0f3f7;
}

.btn-sm {
  padding: 4px 12px;
  font-size: 13px;
}

/* ---------- 错误提示条 ---------- */
.error-bar {
  background: #fdecea;
  color: #c0392b;
  border: 1px solid #f5c6cb;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---------- 结果卡片（纵向排列） ---------- */
.result-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  overflow: hidden;
  margin-bottom: 14px;
}

.result-section .card { margin-bottom: 0; }

.card-title {
  background-color: #f0f4fa;
  color: #1f4e8c;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 16px;
  border-bottom: 1px solid #e3e8ef;
}

.card-body {
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.8;
  min-height: 48px;
}

.card-body .placeholder {
  color: #aab2bf;
}

/* 列表样式（深层原因 / 纠正预防措施） */
.card-body ul {
  padding-left: 20px;
}

.card-body ul li {
  margin-bottom: 4px;
}

/* 小标签（立即纠正 / 纠正预防措施分组） */
.sub-label {
  display: inline-block;
  font-size: 12px;
  color: #1f4e8c;
  background: #e8f0fa;
  border-radius: 4px;
  padding: 1px 8px;
  margin: 6px 0 4px;
  font-weight: 600;
}

/* 结果徽章（严重程度 / 问题类型 / 闭环判定） */
.badge {
  display: inline-block;
  padding: 4px 16px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-sm { padding: 2px 10px; font-size: 12px; }

.badge-red    { background: #fdecea; color: #c0392b; border: 1px solid #f5b7b1; }
.badge-orange { background: #fef5e7; color: #ca6f1e; border: 1px solid #fad7a0; }
.badge-blue   { background: #e8f0fa; color: #1f4e8c; border: 1px solid #aed0f0; }
.badge-green  { background: #e9f7ef; color: #1e8449; border: 1px solid #a9dfbf; }
.badge-gray   { background: #f2f4f7; color: #6c757d; border: 1px solid #d5dbe3; }

/* 加载中动画 */
.loading {
  color: #2f6fb2;
}

.loading::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border: 2px solid #2f6fb2;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -1px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- 批量分析 ---------- */
.batch-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.file-name {
  font-size: 13px;
  color: #6c757d;
}

.tip-text {
  margin-top: 12px;
  font-size: 12px;
  color: #8a94a6;
  line-height: 1.6;
}

.progress-text {
  margin-top: 10px;
  font-size: 13px;
  color: #2f6fb2;
  font-weight: 600;
}

.table-panel {
  padding: 12px;
  overflow-x: auto;
}

.batch-empty {
  text-align: center;
  padding: 30px 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  border: 1px solid #e3e8ef;
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  word-break: break-all;
}

.data-table th {
  background: #f0f4fa;
  color: #1f4e8c;
  font-weight: 600;
  white-space: nowrap;
}

.data-table tr:nth-child(even) td { background: #fafbfd; }

.status-done { color: #1e8449; font-weight: 600; }
.status-fail { color: #c0392b; font-weight: 600; }
.status-wait { color: #8a94a6; }
.status-run  { color: #2f6fb2; }

/* ---------- 统计看板 ---------- */
.stat-cards {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1;
  min-width: 140px;
  background: #fff;
  border: 1px solid #e3e8ef;
  border-radius: 8px;
  text-align: center;
  padding: 18px 10px;
  box-shadow: 0 1px 3px rgba(31, 78, 140, 0.06);
}

.stat-num {
  font-size: 30px;
  font-weight: 700;
  color: #1f4e8c;
}

.stat-red    { color: #c0392b; }
.stat-orange { color: #ca6f1e; }
.stat-blue   { color: #2f6fb2; }
.stat-green  { color: #1e8449; }

.stat-label {
  margin-top: 6px;
  font-size: 13px;
  color: #6c757d;
}

/* 纯CSS横向条形图 */
.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.bar-name {
  width: 180px;
  font-size: 13px;
  text-align: right;
  color: #444;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  flex: 1;
  background: #eef1f6;
  border-radius: 4px;
  height: 20px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2f6fb2, #4a90d9);
  border-radius: 4px;
  min-width: 4px;
}

.bar-fill.bar-red    { background: linear-gradient(90deg, #c0392b, #e07065); }
.bar-fill.bar-orange { background: linear-gradient(90deg, #ca6f1e, #e8a765); }
.bar-fill.bar-green  { background: linear-gradient(90deg, #1e8449, #52b788); }

.bar-count {
  width: 60px;
  font-size: 13px;
  color: #6c757d;
}

/* ---------- 知识库 ---------- */
.kb-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
}

.kb-toolbar #kbSearch { flex: 1; }

.kb-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kb-item {
  background: #fff;
  border: 1px solid #e3e8ef;
  border-radius: 8px;
  overflow: hidden;
}

.kb-item-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  flex-wrap: wrap;
}

.kb-item-head:hover { background: #f7f9fc; }

.kb-time {
  font-size: 12px;
  color: #8a94a6;
  white-space: nowrap;
}

.kb-desc {
  flex: 1;
  font-size: 14px;
  color: #333;
  min-width: 200px;
}

.kb-del {
  border: none;
  background: transparent;
  color: #c0392b;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
}

.kb-del:hover { text-decoration: underline; }

.kb-item-detail {
  border-top: 1px dashed #e3e8ef;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.9;
  background: #fafbfd;
}

.kb-item-detail .kb-field-label {
  color: #1f4e8c;
  font-weight: 600;
}

/* ---------- 页面底部提示 ---------- */
.page-footer {
  text-align: center;
  color: #9aa3b0;
  font-size: 12px;
  padding: 18px 16px 26px;
}

/* ---------- 判定依据参考资料卡片 ---------- */
.ref-card .card-title { color: #2f6f4f; }
.ref-item { padding: 8px 0; border-bottom: 1px dashed #e3e8ef; }
.ref-item:last-child { border-bottom: none; }
.ref-name { font-size: 13px; font-weight: 600; color: #333; margin-bottom: 4px; }
.ref-excerpt { font-size: 12px; color: #667; line-height: 1.6; }

/* ---------- 企业知识库状态区 ---------- */
.kb-status-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.kb-status-text { font-size: 13px; color: #445; }

/* ---------- 看板交互：可点击筛选 + 柱状图 + 明细 ---------- */
.stat-card.clickable { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.stat-card.clickable:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(43,108,212,.18); }
.stat-card.clickable.active { outline: 2px solid #2b6cd4; outline-offset: 2px; }
.bar-row.clickable { cursor: pointer; border-radius: 6px; padding: 2px 6px; }
.bar-row.clickable:hover { background: #f0f4fb; }
.bar-row.clickable.active { background: #e3ecfb; box-shadow: inset 0 0 0 1px #2b6cd4; }
.bar-row.clickable .bar-count { width: auto; min-width: 60px; white-space: nowrap; }
.col-chart { display: flex; align-items: stretch; gap: 14px; height: 220px; padding: 12px 4px 0; }
.col-item { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; cursor: pointer; }
.col-count { font-size: 12px; color: #555; margin-bottom: 4px; }
.col-bar { width: 60%; max-width: 46px; background: #7ea6ee; border-radius: 4px 4px 0 0; transition: height .3s; }
.col-item:hover .col-bar { background: #5b8def; }
.col-item.active .col-bar { background: #2b6cd4; }
.col-name { font-size: 12px; color: #666; margin-top: 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-item.active .col-name { color: #2b6cd4; font-weight: bold; }
.dash-detail-clause { padding: 8px 14px; color: #666; font-size: 12px; border-top: 1px dashed #e5e9f2; }

/* ---------- 窄屏适配 ---------- */
@media (max-width: 600px) {
  .page-header h1 { font-size: 20px; }
  .btn-group { flex-direction: column; }
  .btn { width: 100%; }
  .field-row { flex-direction: column; gap: 0; }
  .tab { padding: 10px 14px; }
  .bar-name { width: 100px; }
}
