/* =========================================================
   座位编辑器样式
   配色方案：青绿（主）+ 暖砂/橙（辅），与本品类常见的紫粉方案刻意区分
   ========================================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --brand: #0f766e;        /* 主色：深青 */
  --brand-soft: #e6f4f1;   /* 主色浅底 */
  --accent: #e07a3f;       /* 辅色：暖橙 */
  --accent-soft: #fdeee1;
  --male: #0f8a7e;   --male-bg: #cfeee8;
  --female: #d2691e; --female-bg: #ffe2c9;
  --empty: #b0b7bd;  --empty-bg: #f2f4f5;
  --panel-line: #dfe7e5;
}
body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: linear-gradient(135deg, #116b64 0%, #0a4f4a 55%, #123f5e 100%);
  min-height: 100vh;
  display: flex;
  color: #22312f;
}

/* ============ 侧栏 ============ */
.sidebar {
  width: 320px; flex: 0 0 320px;
  background: #f2f6f5;
  padding: 20px 18px;
  height: 100vh;
  position: sticky; top: 0; align-self: flex-start;
  overflow-y: auto;
  box-shadow: 2px 0 14px rgba(0,0,0,.18);
}
.app-title { font-size: 20px; text-align: center; margin-bottom: 16px; color: var(--brand); letter-spacing: 1px; }

.panel {
  background: #fff; border-radius: 14px;
  padding: 18px 16px; margin-bottom: 16px;
  border: 1px solid var(--panel-line);
  box-shadow: 0 2px 8px rgba(15,118,110,.06);
}
.panel h2 { font-size: 16px; margin-bottom: 14px; color: var(--brand); display: flex; align-items: center; gap: 6px; }
.panel h2::before { content: ""; width: 4px; height: 14px; background: var(--accent); border-radius: 2px; }
.panel h2.center { justify-content: center; }
.panel h2.center::before { display: none; }
.panel h3 { font-size: 13px; margin: 14px 0 8px; color: #7b8b88; text-align: center; }
.panel h3.center { text-align: center; }
.sidebar-foot { text-align: center; font-size: 12px; color: #9aa8a5; padding: 4px 0 20px; }

/* 按钮 */
.btn {
  display: inline-block; border: none; cursor: pointer;
  border-radius: 999px; padding: 10px 18px;
  font-size: 14px; font-family: inherit;
  transition: transform .12s, box-shadow .12s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,.14); }
.btn:active { transform: translateY(0); }
.btn-sm { padding: 7px 14px; font-size: 13px; width: 100%; }
.btn-col { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.btn-teal   { background: var(--brand-soft); color: var(--brand); }
.btn-green  { background: #e2f2e6; color: #2f7d4f; }
.btn-sand   { background: var(--accent-soft); color: #b4601f; }
.btn-slate  { background: #e7ecf2; color: #4a5a6a; }
.btn-gray   { background: #e9edec; color: #55635f; }
.btn-outline { background: #fff; color: var(--brand); border: 1px solid #a9cfc8; width: 100%; }
.btn-teal-fill   { background: var(--brand); color: #fff; }
.btn-orange-fill { background: var(--accent); color: #fff; }
.btn-gradient {
  width: 100%; margin-top: 14px;
  background: linear-gradient(90deg, #0f766e, #e07a3f);
  color: #fff; font-size: 15px; padding: 12px; letter-spacing: 1px;
}

/* 表单 */
.form-row { margin-top: 14px; }
.form-row > label { display: block; font-size: 13px; color: #7b8b88; margin-bottom: 6px; }
.layout-inputs, .aisle-inputs { display: flex; align-items: center; gap: 8px; }
.layout-inputs input, .aisle-inputs input {
  width: 64px; padding: 8px; text-align: center;
  border: 1px solid #cfdbd8; border-radius: 8px; font-size: 14px;
}
select {
  width: 100%; padding: 8px 10px;
  border: 1px solid #cfdbd8; border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: #22312f;
}
.hint { font-size: 12px; color: #98a6a3; margin-top: 6px; line-height: 1.6; }

/* 开关 */
.switch-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; margin: 10px 0; }
.switch { position: relative; width: 44px; height: 24px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; cursor: pointer; background: #cfdbd8; border-radius: 999px; transition: .2s; }
.slider::before {
  content: ""; position: absolute; width: 18px; height: 18px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* 复选框 */
.check-col { display: flex; flex-direction: column; gap: 9px; margin: 6px 0; }
.check-item { font-size: 13.5px; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check-item input { width: 16px; height: 16px; accent-color: var(--brand); }

/* 优先级列表 */
.priority-list {
  min-height: 92px; border: 1.5px dashed #a9cfc8; border-radius: 10px;
  background: #f7fbfa; padding: 8px; display: flex; flex-direction: column; gap: 8px;
}
.priority-list.empty-hint { align-items: center; justify-content: center; color: #9ab8b3; font-size: 13px; }
.priority-item {
  background: var(--brand-soft); color: #0b5b55; border-radius: 8px;
  padding: 8px 12px; font-size: 13px; cursor: grab; user-select: none;
  display: flex; justify-content: space-between; align-items: center;
  border-left: 3px solid var(--brand);
}
.priority-item .rank { font-weight: bold; margin-right: 8px; color: var(--accent); }
.priority-item.dragging { opacity: .5; }

/* 特殊要求 */
.pair-picker { display: flex; align-items: center; gap: 6px; margin: 8px 0; }
.pair-picker select { font-size: 13px; }
.pair-picker .x { color: var(--accent); font-size: 12px; flex-shrink: 0; }
.forbid-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.forbid-item {
  display: flex; justify-content: space-between; align-items: center;
  background: #fff8f2; border: 1px solid #f3d9c4; border-radius: 8px;
  padding: 7px 10px; font-size: 13px;
}
.forbid-item button {
  border: none; background: #f6e2d4; color: #b4601f;
  border-radius: 6px; padding: 3px 9px; cursor: pointer; font-size: 12px;
}
.forbid-empty { font-size: 12px; color: #9aa8a5; text-align: center; padding: 8px 0; }

/* ============ 主区域 ============ */
.main { flex: 1; min-width: 0; padding: 24px 28px; height: 100vh; overflow: auto; }
.title-card {
  background: #fff; border-radius: 16px; padding: 16px 22px;
  text-align: center; margin-bottom: 16px;
  border: 1px solid var(--panel-line);
  box-shadow: 0 2px 10px rgba(0,0,0,.1);
}
.title-card h2 { font-size: 22px; color: var(--brand); letter-spacing: 2px; }
.legend { margin-top: 10px; display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; }
.legend-item { font-size: 13px; color: #4b5c59; display: flex; align-items: center; gap: 6px; }
.dot { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.dot.male   { background: var(--male-bg); border: 2px solid var(--male); }
.dot.female { background: var(--female-bg); border: 2px solid var(--female); }
.dot.empty  { background: var(--empty-bg); border: 2px dashed var(--empty); }
.dot.lock   { background: #fff; border: 2px solid #c2410c; box-shadow: inset 0 0 0 5px #fed7aa; }
.dot.group  { background: #fdf6e3; border: 2px solid #d9a441; }

.canvas-card {
  background: #fff; border-radius: 16px; padding: 22px;
  border: 1px solid var(--panel-line);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.podium {
  background: linear-gradient(90deg, var(--brand), #14a08f);
  color: #fff; text-align: center; font-size: 16px; font-weight: bold;
  border-radius: 8px; padding: 10px; width: 52%; margin: 0 auto 22px;
  letter-spacing: 3px;
  box-shadow: 0 3px 10px rgba(15,118,110,.35);
}
.hidden { display: none !important; }

/* 座位网格 */
.seat-grid { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.seat-row { display: flex; gap: 12px; align-items: stretch; }
.col-group {
  display: grid; gap: 12px;
  grid-template-columns: repeat(var(--gc), 96px);
  padding: 8px; border-radius: 12px;
}
.col-group.tint-0 { background: #f4fbf9; }
.col-group.tint-1 { background: #fdf7f1; }
.col-group.tint-2 { background: #f6f8fb; }
.col-group.tint-3 { background: #f7faf4; }
.col-group .group-tag {
  grid-column: 1 / -1; text-align: center;
  font-size: 11px; color: #a97c22; font-weight: bold;
}
.aisle { width: 26px; flex-shrink: 0; position: relative; }
.aisle::after {
  content: "过道"; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  writing-mode: vertical-lr; letter-spacing: 3px;
  font-size: 11px; color: #9ab8b3;
}

/* 座位卡 */
.seat {
  width: 96px; height: 84px; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; transition: transform .1s, box-shadow .1s;
  border: 2px solid; position: relative;
}
.seat:hover { transform: translateY(-2px); box-shadow: 0 5px 12px rgba(0,0,0,.15); }
.seat.dragging { opacity: .45; }
.seat.male   { background: var(--male-bg); border-color: var(--male); }
.seat.female { background: var(--female-bg); border-color: var(--female); }
.seat .name { font-size: 16px; font-weight: bold; color: #21302e; }
.seat .meta { font-size: 11px; color: #5c6f6b; margin-top: 5px; }
.seat.empty { background: var(--empty-bg); border: 2px dashed var(--empty); }
.seat.empty .name { color: var(--empty); font-weight: normal; font-size: 13px; }
.seat.empty.drop-hint { border-color: var(--brand); background: var(--brand-soft); }
/* 拖放目标会让禁邻两人变相邻时，提前红色警示 */
.seat.drop-warn { border-color: #dc2626 !important; background: #fee2e2 !important; box-shadow: 0 0 0 3px #fca5a5; }
/* 拖动某人时，标记出他/她的禁邻对象 */
.seat.forbid-peer { outline: 2px dashed #d97706; outline-offset: 2px; }
.seat.forbid-peer::after {
  content: "禁邻"; position: absolute; bottom: -9px; left: 50%;
  transform: translateX(-50%);
  background: #d97706; color: #fff; font-size: 10px;
  border-radius: 4px; padding: 1px 5px;
}

/* 禁邻提醒弹窗 */
.modal-sm { width: 420px; }
.warn-title { color: #c2410c !important; }
.alert-body { font-size: 14px; line-height: 1.8; color: #4b5563; }
.alert-line {
  background: #fff7ed; border-left: 3px solid #f59e0b;
  border-radius: 6px; padding: 8px 12px; margin-bottom: 8px;
}
.alert-line b { color: #c2410c; }
.seat .no-badge {
  position: absolute; top: -8px; left: -8px;
  background: var(--brand); color: #fff; font-size: 10px;
  border-radius: 50%; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
}
.seat .lock-badge {
  position: absolute; top: -8px; right: -8px;
  background: #fff; border: 2px solid #c2410c; color: #c2410c;
  border-radius: 50%; width: 22px; height: 22px; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
}
.seat.locked { border-style: solid; box-shadow: 0 0 0 2px #fed7aa; }
.seat.conflict { box-shadow: 0 0 0 3px #ef4444; }

/* 右键菜单 */
.ctx-menu {
  position: fixed; z-index: 300;
  background: #fff; border-radius: 10px;
  border: 1px solid var(--panel-line);
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
  padding: 6px; min-width: 150px;
}
.ctx-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; font-size: 13.5px; color: #2c3b38;
  border-radius: 7px; cursor: pointer; user-select: none;
}
.ctx-item:hover { background: var(--brand-soft); color: var(--brand); }
.ctx-ico { width: 18px; text-align: center; color: var(--brand); }

/* 换座位 / 设禁邻的"点选目标"模式 */
.seat.pick-target { cursor: crosshair; animation: pickPulse 1.2s infinite; }
@keyframes pickPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(15,118,110,.45); }
  50%      { box-shadow: 0 0 0 5px rgba(15,118,110,.18); }
}

/* 职务标签 */
.seat .role-badge {
  margin-top: 3px;
  background: var(--accent); color: #fff;
  font-size: 10px; line-height: 1;
  padding: 2px 6px; border-radius: 4px;
}

/* 名单管理弹窗 */
.roster-table {
  margin-top: 12px; max-height: 48vh; overflow-y: auto;
  border: 1px solid var(--panel-line); border-radius: 10px;
}
.roster-row {
  display: grid;
  grid-template-columns: 42px minmax(64px,1fr) 38px 50px 58px 54px 74px 104px;
  gap: 6px; align-items: center;
  padding: 8px 10px; font-size: 13px; color: #2c3b38;
  border-bottom: 1px solid var(--panel-line);
}
.roster-row:last-child { border-bottom: none; }
.roster-row.head {
  background: var(--brand-soft); color: var(--brand);
  font-weight: bold; position: sticky; top: 0; z-index: 1;
}
.roster-row .seat-at { font-size: 12px; color: #6b7c78; }
.roster-row .ops { display: flex; gap: 6px; }
.roster-row .ops button {
  border: none; border-radius: 6px; cursor: pointer;
  padding: 3px 8px; font-size: 12px;
  background: var(--brand-soft); color: var(--brand);
}
.roster-row .ops button.del { background: #fdecea; color: #b4232a; }
.roster-empty { text-align: center; color: #9aa8a5; padding: 20px 0; font-size: 13px; }

/* 编辑学生信息弹窗 */
.edit-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px 14px; margin-top: 12px;
}
.edit-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #5c6f6b; }
.edit-grid input, .edit-grid select {
  padding: 8px 10px; border: 1px solid #cfdbd8; border-radius: 8px;
  font-size: 14px; font-family: inherit; color: #22312f; background: #fff;
}
#editForbidList { max-height: 150px; overflow-y: auto; }

/* 导出栏 */
.export-bar { margin-top: 18px; text-align: center; display: flex; gap: 14px; justify-content: center; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: #fff; border-radius: 16px; padding: 24px;
  width: 560px; max-width: 92vw; max-height: 86vh; overflow-y: auto;
}
.modal h3 { margin-bottom: 10px; font-size: 18px; color: var(--brand); }
.modal textarea {
  width: 100%; margin: 12px 0; padding: 10px;
  border: 1px solid #cfdbd8; border-radius: 8px;
  font-size: 13px; font-family: Consolas, monospace; resize: vertical;
}
.file-input { font-size: 13px; }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }

.history-list { display: flex; flex-direction: column; gap: 10px; max-height: 46vh; overflow-y: auto; }
.history-item {
  display: flex; justify-content: space-between; align-items: center;
  background: #f6f9f8; border: 1px solid var(--panel-line); border-radius: 10px; padding: 10px 14px;
  font-size: 13px;
}
.history-item .ops { display: flex; gap: 8px; }
.history-empty { text-align: center; color: #9aa8a5; padding: 24px 0; font-size: 13px; }

/* Toast */
.toast {
  position: fixed; top: 26px; left: 50%; transform: translateX(-50%);
  background: rgba(20,45,42,.92); color: #fff;
  padding: 10px 22px; border-radius: 999px; font-size: 14px; z-index: 200;
  max-width: 80vw; text-align: center;
}
@keyframes fadein { from { opacity: 0; transform: translate(-50%, -8px); } }

/* 手机端才显示的「设置」折叠按钮 */
#btnTogglePanel { display: none; width: 100%; margin-bottom: 12px; }

/* 座位区横向可滚动：列数多时不再撑破布局 */
.canvas-card { overflow-x: auto; }
.seat-grid { width: max-content; margin: 0 auto; }

/* 平板：压缩，仍保持左右布局 */
@media (max-width: 1000px) {
  .sidebar { width: 250px; flex: 0 0 250px; padding: 14px 10px; }
  .main { padding: 14px 12px; }
  .seat { width: 76px; height: 70px; }
  .col-group { grid-template-columns: repeat(var(--gc), 76px); gap: 8px; }
  .seat .name { font-size: 14px; }
  .seat .meta { font-size: 10px; }
  .aisle { width: 18px; }
  .podium { width: 64%; }
}

/* 手机：上下堆叠，侧栏可折叠，座位区左右滑动 */
@media (max-width: 720px) {
  body { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto;
    position: static; overflow: visible;
    padding: 12px; box-shadow: none;
  }
  .app-title { margin-bottom: 10px; }
  /* 折叠时只保留「基础操作」，其余面板收起 */
  .sidebar.collapsed .panel:not(.panel-basic) { display: none; }
  #btnTogglePanel { display: block; }

  .main { padding: 12px 8px; height: auto; overflow: visible; }
  .title-card { padding: 12px 14px; }
  .title-card h2 { font-size: 18px; }
  .legend { gap: 12px; font-size: 12px; }
  .canvas-card { padding: 12px 8px; }
  .seat { width: 62px; height: 58px; border-radius: 8px; }
  .col-group { grid-template-columns: repeat(var(--gc), 62px); gap: 6px; padding: 5px; }
  .seat .name { font-size: 13px; }
  .seat .meta { font-size: 9px; margin-top: 2px; }
  .seat .no-badge { width: 17px; height: 17px; font-size: 9px; top: -6px; left: -6px; }
  .seat .lock-badge { width: 18px; height: 18px; font-size: 10px; top: -6px; right: -6px; }
  .seat .role-badge { font-size: 9px; padding: 1px 4px; }
  .aisle { width: 12px; }
  .aisle::after { font-size: 9px; letter-spacing: 1px; }
  .podium { width: 70%; font-size: 14px; padding: 8px; margin-bottom: 14px; }
  .export-bar { flex-direction: column; align-items: stretch; gap: 8px; }

  /* 弹窗在手机上铺满、表单单列 */
  .modal { width: 96vw; padding: 16px; }
  .edit-grid { grid-template-columns: 1fr; }
  .modal-btns .btn { flex: 1; }
  .roster-table { overflow-x: auto; }
  .roster-row { min-width: 520px; }
  .ctx-menu { min-width: 140px; }
  .ctx-item { padding: 11px 12px; font-size: 14px; }
}

@media (max-width: 380px) {
  .seat { width: 56px; height: 54px; }
  .col-group { grid-template-columns: repeat(var(--gc), 56px); gap: 5px; }
}
