/* ===== CSS Variables ===== */
:root {
  --bg: #F5F5FA;
  --surface: #FFFFFF;
  --border: #E2E4EA;
  --text: #1A1A2E;
  --text2: #6B7280;
  --primary: #534AB7;
  --primary-light: #EEEDFE;
  --accent: #BA7517;
  --accent-light: #FAEEDA;
  --danger: #D85A30;
  --info: #378ADD;
  --success: #1D9E75;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

/* ===== Reset ===== */
* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ===== 顶部栏 ===== */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar h1 { font-size: 18px; font-weight: 700; }
.topbar h1 span { color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-right select {
  padding: 6px 28px 6px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 8px center;
  appearance: none;
  cursor: pointer;
  min-width: 180px;
  outline: none;
}
.topbar-right select:focus { border-color: var(--primary); }

/* ===== 图例栏 ===== */
.legend-bar {
  background: #FAFAFE;
  border-bottom: 1px solid var(--border);
  padding: 8px 24px;
  display: flex;
  gap: 20px;
  align-items: center;
  font-size: 12px;
  color: var(--text2);
  flex-wrap: wrap;
}
.legend-group { display: flex; align-items: center; gap: 6px; }
.legend-group::after { content: ""; width: 1px; height: 14px; background: var(--border); margin-left: 8px; }
.legend-group:last-child::after { display: none; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }
.legend-icon { width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; font-size: 10px; color: #fff; }
.legend-label { color: var(--text2); }

/* ===== 主体布局 ===== */
.main { display: flex; height: calc(100vh - 90px); }

/* ===== 左侧面板 ===== */
.left-panel {
  width: 360px;
  min-width: 360px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.panel-header { padding: 16px; border-bottom: 1px solid var(--border); }
.panel-header h2 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }

/* ===== 按钮系统 ===== */
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: #4740a0; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ai {
  background: linear-gradient(135deg, #534AB7 0%, #7C6FE0 100%);
  color: #fff;
  border-color: #534AB7;
  position: relative;
  overflow: hidden;
}
.btn-ai::after {
  content: "";
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: linear-gradient(45deg, transparent 40%, rgba(255,255,255,0.15) 50%, transparent 60%);
  animation: aiShine 2s infinite;
}
@keyframes aiShine { 0%{transform:translateX(-100%)} 100%{transform:translateX(100%)} }
.btn-ai:hover { background: linear-gradient(135deg, #4740a0 0%, #6B5ED4 100%); }

/* ===== 搜索框 ===== */
.search-box { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.search-box input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  outline: none;
}
.search-box input:focus { border-color: var(--primary); }

/* ===== 名单分组 ===== */
.group-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.group-section { padding: 0 16px; margin-bottom: 12px; }
.group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.group-section:first-child .group-title { color: var(--accent); border-bottom-color: #F0DFC0; }

/* ===== 名牌（左侧名单） ===== */
.nametag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  margin: 3px;
  border-radius: 7px;
  font-size: 13px;
  cursor: grab;
  border: 1.5px solid transparent;
  transition: all .15s;
  position: relative;
  user-select: none;
}
.nametag:active { cursor: grabbing; }
.nametag.member { background: var(--primary-light); color: #3C3489; border-color: #D5D2F5; }
.nametag.experience { background: var(--accent-light); color: #633806; border-color: #F0DFC0; }
.nametag:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,0.1); }
.nametag.dragging { opacity: 0.4; }
.nametag .ai-note-badge {
  position: absolute;
  bottom: -3px;
  right: -3px;
  background: var(--primary);
  color: #fff;
  font-size: 8px;
  padding: 1px 4px;
  border-radius: 3px;
  max-width: 40px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.type-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.type-dot.member { background: var(--primary); }
.type-dot.experience { background: var(--accent); }

.role-badge {
  position: absolute;
  top: -5px; right: -5px;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.role-badge.boss { background: var(--danger); }
.role-badge.manager { background: var(--info); }
.role-badge.mentor { background: var(--success); }

/* ===== 右侧座位区 ===== */
.right-panel { flex: 1; display: flex; flex-direction: column; background: #F8F8FC; }

/* ===== 右侧工具栏 ===== */
.toolbar {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.toolbar-left { display: flex; align-items: center; gap: 10px; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }
.toolbar label { font-size: 13px; color: var(--text2); }
.toolbar select, .toolbar input[type="number"] {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  outline: none;
  width: 70px;
}
.toolbar select:focus, .toolbar input[type="number"]:focus { border-color: var(--primary); }

/* ===== 特殊设置面板 ===== */
.special-panel {
  display: none;
  padding: 12px 20px;
  background: #FFFBF5;
  border-bottom: 1px solid #F0DFC0;
}
.special-panel.show { display: block; }
.special-panel h3 { font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--accent); }
.special-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.special-row label { min-width: 36px; }
.special-row input { width: 60px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 5px; font-size: 13px; }
.special-row input[type="text"] { width: 80px; }
.special-row .btn { padding: 3px 8px; font-size: 11px; }

/* ===== 座位区域 ===== */
.seat-area { flex: 1; overflow: auto; padding: 20px; display: flex; flex-direction: column; align-items: center; }

/* ===== 屏幕/讲台 ===== */
.screen-area { width: 80%; max-width: 600px; text-align: center; margin-bottom: 8px; position: relative; }
.screen-body {
  background: linear-gradient(135deg, #1E293B 0%, #334155 100%);
  border-radius: 8px;
  padding: 16px 40px;
  color: #94A3B8;
  font-size: 14px;
  letter-spacing: 6px;
  border: 3px solid #475569;
  position: relative;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.screen-body::before { content: ""; position: absolute; top: 4px; left: 50%; transform: translateX(-50%); width: 40px; height: 3px; background: #475569; border-radius: 2px; }
.screen-stand { width: 60px; height: 6px; background: #9CA3AF; margin: 0 auto; border-radius: 2px; }

.podium-area { width: 80%; max-width: 600px; margin: 0 auto 20px; text-align: center; }
.podium-strip {
  border: 2px dashed #C0C4CC;
  border-radius: 8px;
  padding: 10px 0;
  background: #F9FAFB;
  color: #9CA3AF;
  font-size: 12px;
  letter-spacing: 3px;
  position: relative;
}
.podium-strip::before, .podium-strip::after {
  content: "";
  position: absolute;
  bottom: -10px;
  width: 2px;
  height: 10px;
  background: #C0C4CC;
}
.podium-strip::before { left: 30%; }
.podium-strip::after { right: 30%; }

/* ===== 桌子网格 ===== */
.tables-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
  width: 100%;
  max-width: 1400px;
  padding: 8px 16px;
}
.table-row {
  display: flex;
  justify-content: center;
  gap: 40px;
  width: 100%;
}

/* ===== 单桌布局 ===== */
.table-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  position: relative;
  padding-top: 8px;
  border-radius: 12px;
  transition: box-shadow .2s, opacity .2s;
}
.table-unit.dragging { opacity: 0.4; }
.table-unit.drag-over-left {
  box-shadow: -4px 0 0 3px var(--primary);
}
.table-unit.drag-over-right {
  box-shadow: 4px 0 0 3px var(--primary);
}
.table-unit.drag-over-center {
  box-shadow: 0 0 0 3px var(--primary);
}
.table-layout { position: relative; }

/* ===== 拖拽手柄 ===== */
.drag-handle {
  cursor: grab;
  color: #C0C4CC;
  padding: 2px 0 4px;
  opacity: 0;
  transition: opacity .15s, color .15s;
  z-index: 5;
}
.table-unit:hover .drag-handle { opacity: 1; }
.drag-handle:hover { color: var(--primary); }
.drag-handle:active { cursor: grabbing; }

/* ===== 拼接桌 ===== */
.joined-tables {
  position: absolute;
  display: flex;
  border: 2px solid #7A6548;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 3px 12px rgba(0,0,0,0.12);
}
.desk-slab {
  flex-shrink: 0;
  background: linear-gradient(145deg, #8B7355 0%, #A0896E 40%, #9A8262 70%, #8B7355 100%);
  border-right: 1px solid rgba(122,101,72,0.5);
}
.desk-slab:last-child { border-right: none; }

.desk-label {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, -50%);
}
.table-number { font-size: 14px; font-weight: 700; color: #F5F0E8; text-shadow: 0 1px 2px rgba(0,0,0,0.3); letter-spacing: 1px; white-space: nowrap; }
.table-special { font-size: 10px; color: #F5F0E8CC; margin-top: 1px; }

/* ===== 座位槽位 ===== */
.seat {
  position: absolute;
  height: 34px;
  width: 76px;
  border: 1.5px dashed var(--border);
  border-radius: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  background: #FDFDFE;
}
.seat.drag-over { border-color: var(--primary); background: var(--primary-light); transform: scale(1.05); }
.seat.occupied { border-style: solid; cursor: default; }
.seat.occupied:hover { box-shadow: 0 0 0 2px rgba(83,74,183,0.2); }

/* ===== 座位内名牌 ===== */
.seated-tag {
  width: 100%; height: 100%;
  border-radius: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 600;
  position: relative;
  cursor: grab;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seated-tag.member { background: var(--primary-light); color: #3C3489; }
.seated-tag.experience { background: var(--accent-light); color: #633806; }
.seated-tag .role-badge { top: -4px; right: -4px; width: 15px; height: 15px; font-size: 8px; }
.seat-hint { font-size: 9px; color: #C0C4CC; letter-spacing: 1px; }

/* ===== 桌号标签 ===== */
.table-label { margin-top: 8px; font-size: 11px; color: var(--text2); font-weight: 600; }

/* ===== 空状态 ===== */
.empty-state { flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column; color: var(--text2); gap: 8px; }
.empty-state svg { width: 48px; height: 48px; color: #D1D5DB; }

/* ===== 隐藏元素 ===== */
#fileInput { display: none; }

/* ===== Toast提示 ===== */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  animation: toastIn .3s ease-out;
  max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }
.toast.fade-out { animation: toastOut .3s ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(30px); } }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 3px; }

/* ===== 弹窗 ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: var(--surface);
  border-radius: 12px;
  width: 520px;
  max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  animation: modalIn .2s ease-out;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px;
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 16px 20px; }
.modal-body textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  font-family: inherit;
}
.modal-body textarea:focus { border-color: var(--primary); }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}
