/* ============================================================
   智能排课系统 — 全局样式
   浅色主题 / 主色 #2F5597 / 圆角 6px / 边框 #e2e6ee
   ============================================================ */

:root {
  --primary: #2F5597;
  --primary-hover: #3a63ad;
  --primary-active: #264a85;
  --danger: #c9463d;
  --danger-hover: #b53d35;
  --success: #2f8f4e;
  --warning: #c07f1a;
  --border: #e2e6ee;
  --bg: #f5f6fa;
  --panel: #ffffff;
  --text: #2b3446;
  --muted: #8a93a6;
  --radius: 6px;
  --sidebar-bg: #1c2740;
  --sidebar-text: #aeb9d2;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  display: flex;
}

/* ---------------- 侧栏 ---------------- */

.sidebar {
  width: 200px;
  flex: 0 0 200px;
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 20px 16px;
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-icon { color: #7fa3e0; }

/* ---------------- 侧栏数据档案 ---------------- */

.profile-box {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.profile-label {
  font-size: 12px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.38);
  margin-bottom: 6px;
}

.profile-row {
  display: flex;
  gap: 6px;
}

.profile-select {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  font-size: 13px;
  font-family: inherit;
  color: #dbe3f5;
  background: #141d33;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  outline: none;
  cursor: pointer;
}

.profile-select:hover { border-color: rgba(255, 255, 255, 0.32); }
.profile-select:focus { border-color: var(--primary-hover); }
.profile-select option { background: #141d33; color: #dbe3f5; }

.profile-add {
  flex: 0 0 auto;
  width: 30px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  font-family: inherit;
  color: var(--sidebar-text);
  background: #141d33;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.profile-add:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.32);
  background: #1a2540;
}

.nav {
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-icon { width: 18px; text-align: center; }

.sidebar .foot {
  margin-top: auto;
  padding: 12px 16px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.35);
}

/* ---------------- 主内容区 ---------------- */

.main {
  flex: 1;
  min-width: 0;
  height: 100vh;
  overflow: auto;
  padding: 20px 24px;
}

.page-title { font-size: 20px; font-weight: 600; margin: 0 0 16px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.section { margin-bottom: 22px; }
.section-title { font-size: 15px; font-weight: 600; margin: 0 0 10px; display: flex; align-items: center; gap: 10px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.6; }
.loading { color: var(--muted); padding: 20px 0; }

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 14px;
  line-height: 1.4;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover { border-color: #c8d0de; background: #f7f9fc; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:active { background: var(--primary-active); }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 3px 10px; font-size: 13px; }

/* ---------------- 表格 ---------------- */

.tbl {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.tbl th, .tbl td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  font-size: 14px;
}

.tbl th { background: #f3f5f9; font-weight: 600; white-space: nowrap; }
.tbl tbody tr:hover { background: #f8fafd; }
.tbl tr.et-editing { background: #eef3fb; }
.tbl tr.et-editing:hover { background: #eef3fb; }

.et-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.et-search { width: 220px; }
.et-count { color: var(--muted); font-size: 13px; margin-left: auto; }
.et-wrap { overflow-x: auto; }
.et-actions { white-space: nowrap; }
.et-actions .btn { margin-right: 6px; }
.et-actions .btn:last-child { margin-right: 0; }
.et-editor { width: 100%; min-width: 70px; }
.et-empty { text-align: center; color: var(--muted); padding: 28px 10px; }

/* ---------------- 标签页 ---------------- */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab {
  padding: 8px 14px;
  cursor: pointer;
  border: none;
  background: none;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }

/* ---------------- 表单控件 ---------------- */

.input,
select.input,
textarea.input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(47, 85, 151, 0.15);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px 18px;
  margin-bottom: 16px;
}

.field label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  color: var(--muted);
}

.field .input { width: 100%; }

.field-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.5;
}

/* ---------------- Toast 提示 ---------------- */

.toast-box {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  min-width: 200px;
  max-width: 380px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(20, 30, 60, 0.12);
  font-size: 14px;
  line-height: 1.5;
  animation: toast-in 0.2s ease;
  word-break: break-all;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info { border-left: 4px solid var(--primary); }
.toast.hide { opacity: 0; transition: opacity 0.3s; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---------------- Modal 确认框 ---------------- */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}

.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  width: 380px;
  max-width: 90vw;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-title { margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.modal-msg { margin: 0 0 18px; line-height: 1.7; white-space: pre-line; }
.modal-input { width: 100%; margin: 0 0 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------------- Badge ---------------- */

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.6;
  background: #eef1f6;
  color: var(--muted);
}

.badge-blue { background: #e7edf8; color: var(--primary); }
.badge-green { background: #e6f4ea; color: var(--success); }
.badge-red { background: #fbeae9; color: var(--danger); }
.badge-yellow { background: #fdf3e0; color: var(--warning); }

/* ---------------- 空状态 ---------------- */

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty-icon { font-size: 34px; margin-bottom: 10px; }
.empty-sub { font-size: 13px; margin-top: 4px; color: #aab2c2; }

/* ---------------- 提示卡片（预检等） ---------------- */

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 8px;
  background: #fff;
  font-size: 14px;
  line-height: 1.6;
}

.card-error { border-color: #f0c4c1; background: #fdf1f0; color: #94322c; }
.card-warn { border-color: #f0dcb4; background: #fdf8ec; color: #8a6116; }
.card-ok { border-color: #bfe3cb; background: #effaf2; color: #276b3d; }
.card-sub { font-size: 12px; opacity: 0.75; margin-top: 2px; }

/* ---------------- 排课方案与进度 ---------------- */

.preset-list { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

.preset-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
  background: #fff;
  min-width: 220px;
  flex: 1;
}

.preset-item:hover { border-color: var(--primary); }
.preset-item input { margin-top: 3px; }
.preset-name { font-weight: 600; }
.preset-desc { font-size: 13px; color: var(--muted); margin-top: 2px; }

.solve-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.solve-hint-error { color: var(--danger); font-size: 13px; }
.solve-hint-warn { color: var(--warning); font-size: 13px; }

.progress-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #fff;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.p-name { font-weight: 600; min-width: 56px; }

.state-badge { padding: 2px 10px; border-radius: 10px; font-size: 12px; }
.state-waiting { background: #eef1f6; color: var(--muted); }
.state-solving { background: #e7edf8; color: var(--primary); animation: pulse 1.2s ease-in-out infinite; }
.state-done { background: #e6f4ea; color: var(--success); }
.state-infeasible { background: #fbeae9; color: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.p-score { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.score-num { font-size: 16px; font-weight: 600; color: var(--primary); }

.diag {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  background: #fff;
  margin-top: 6px;
}

.diag h4 { margin: 8px 0 6px; font-size: 14px; }
.diag ul { margin: 0 0 8px; padding-left: 20px; }
.diag li { line-height: 1.8; }
.diag-reasons li { color: #94322c; }
.diag-suggestions li { color: #276b3d; }

/* ---------------- 导入导出 ---------------- */

.io-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0; }
.io-result { margin-top: 14px; }
.io-result .tbl { max-width: 420px; }
