/* ====== 君安舆情对抗演练系统 - 后台管理样式 ====== */
:root {
  --bg: #0a0e1a;
  --bg-panel: #131829;
  --bg-card: #1a2138;
  --bg-input: #0f1424;
  --border: #2a3150;
  --text: #e8eaf0;
  --text-dim: #8b91a8;
  --text-muted: #5a6076;
  --accent: #00d4ff;
  --accent-dim: rgba(0, 212, 255, 0.15);
  --red: #e74c3c;
  --red-dim: rgba(231, 76, 60, 0.15);
  --blue: #3498db;
  --blue-dim: rgba(52, 152, 219, 0.15);
  --green: #2ecc71;
  --yellow: #f39c12;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ====== 登录页 ====== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at center, #131829 0%, #0a0e1a 100%);
}
.login-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 400px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo { margin-bottom: 16px; display: flex; justify-content: center; }
.login-box h1 { font-size: 22px; color: var(--text); margin-bottom: 6px; }
.login-subtitle { color: var(--text-dim); font-size: 14px; margin-bottom: 30px; }
.login-form { text-align: left; }
.login-field { margin-bottom: 18px; }
.login-field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.login-field input {
  width: 100%; padding: 12px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text); font-size: 15px; outline: none; transition: border-color 0.2s;
}
.login-field input:focus { border-color: var(--accent); }
.login-error { color: var(--red); font-size: 13px; min-height: 20px; margin-bottom: 8px; }
.login-btn {
  width: 100%; padding: 13px; border: none; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #0099cc);
  color: #0a0e1a; font-size: 16px; font-weight: 600; cursor: pointer;
  transition: all 0.2s;
}
.login-btn:hover { box-shadow: 0 4px 20px rgba(0, 212, 255, 0.3); }
.login-btn:active { transform: scale(0.98); }
.login-hint { margin-top: 20px; font-size: 12px; color: var(--text-muted); }

/* ====== 管理面板布局 ====== */
.admin-app { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: 220px; background: var(--bg-panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; height: 100vh;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px; padding: 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo span { font-size: 16px; font-weight: 700; color: var(--text); }
.sidebar-nav { flex: 1; padding: 12px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  color: var(--text-dim); text-decoration: none; border-radius: 8px;
  font-size: 14px; margin-bottom: 4px; transition: all 0.2s;
}
.nav-item:hover { background: var(--bg-card); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-item svg { flex-shrink: 0; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.sidebar-link {
  display: block; width: 100%; text-align: left; padding: 10px 14px;
  color: var(--text-dim); text-decoration: none; border-radius: 8px;
  font-size: 13px; background: none; border: none; cursor: pointer; transition: all 0.2s;
}
.sidebar-link:hover { background: var(--bg-card); color: var(--text); }

/* 主内容区 */
.admin-main { flex: 1; margin-left: 220px; padding: 24px 32px; min-width: 0; }

/* 页面头 */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h2 { font-size: 20px; font-weight: 700; }

/* ====== 按钮 ====== */
.btn-primary {
  padding: 10px 20px; border: none; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #0a0e1a; font-size: 14px; font-weight: 600;
  transition: all 0.2s;
}
.btn-primary:hover { background: #33dfff; box-shadow: 0 2px 12px rgba(0,212,255,0.3); }
.btn-secondary {
  padding: 10px 20px; border: 1px solid var(--border); border-radius: 8px;
  background: transparent; color: var(--text-dim); font-size: 14px; cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--text-dim); color: var(--text); }
.btn-large { padding: 14px 32px; font-size: 15px; }
.btn-small { padding: 6px 14px; font-size: 13px; border: none; border-radius: 6px; background: var(--accent-dim); color: var(--accent); cursor: pointer; }
.btn-small:hover { background: rgba(0,212,255,0.25); }
.btn-ai {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px;
  border: 1px solid var(--accent); border-radius: 8px; background: var(--accent-dim);
  color: var(--accent); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all 0.2s; margin-top: 12px;
}
.btn-ai:hover { background: rgba(0,212,255,0.25); }
.btn-block { display: block; width: 100%; margin-top: 12px; text-align: center; }

/* ====== 方案列表 ====== */
.scenario-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 16px;
}
.scenario-card-admin {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; transition: border-color 0.2s;
}
.scenario-card-admin:hover { border-color: var(--accent); }
.scenario-card-admin h4 { font-size: 16px; margin-bottom: 8px; }
.scenario-card-admin .sc-desc { color: var(--text-dim); font-size: 13px; margin-bottom: 12px; }
.scenario-card-admin .sc-roles {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px;
}
.sc-role-tag {
  padding: 3px 8px; border-radius: 4px; font-size: 11px;
}
.sc-role-tag.red { background: var(--red-dim); color: var(--red); }
.sc-role-tag.blue { background: var(--blue-dim); color: var(--blue); }
.scenario-card-admin .sc-actions {
  display: flex; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border);
}

/* ====== 创建方案 ====== */
.create-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.create-left, .create-right { display: flex; flex-direction: column; gap: 20px; }

.form-section {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px;
}
.form-section h3 { font-size: 15px; margin-bottom: 8px; }
.form-hint { color: var(--text-muted); font-size: 12px; margin-bottom: 12px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.form-row input, .form-row textarea, .form-row select {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text); font-size: 14px; outline: none; font-family: inherit;
  transition: border-color 0.2s;
}
.form-row input:focus, .form-row textarea:focus, .form-row select:focus { border-color: var(--accent); }
.form-textarea {
  width: 100%; padding: 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text); font-size: 14px; outline: none; resize: vertical;
  font-family: inherit; line-height: 1.6;
}
.form-textarea:focus { border-color: var(--accent); }

/* 角色配置 */
.roles-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.roles-group { margin-top: 16px; }
.roles-group-header {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-radius: 8px; font-size: 14px; font-weight: 600; margin-bottom: 10px;
}
.roles-group-header.red { background: var(--red-dim); color: var(--red); }
.roles-group-header.blue { background: var(--blue-dim); color: var(--blue); }
.roles-group-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.roles-group-header.red .roles-group-dot { background: var(--red); }
.roles-group-header.blue .roles-group-dot { background: var(--blue); }
.roles-list { display: flex; flex-direction: column; gap: 8px; }
.role-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 8px;
}
.role-item-info { flex: 1; }
.role-item-name { font-weight: 600; font-size: 14px; }
.role-item-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.role-item-actions { display: flex; gap: 6px; }
.role-item-btn {
  width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 6px;
  background: transparent; color: var(--text-dim); cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.role-item-btn:hover { border-color: var(--text-dim); color: var(--text); }
.role-item-btn.delete:hover { border-color: var(--red); color: var(--red); }

.create-actions { display: flex; gap: 12px; margin-top: 8px; }

/* ====== AI配置 ====== */
.config-layout { display: flex; flex-direction: column; gap: 20px; max-width: 800px; }
.config-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 24px;
}
.config-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.config-card-header h3 { font-size: 16px; }
.config-badge {
  padding: 3px 10px; border-radius: 4px; font-size: 12px;
  background: var(--red-dim); color: var(--red);
}
.config-badge.active { background: rgba(46,204,113,0.15); color: var(--green); }
.config-form { display: flex; flex-direction: column; gap: 4px; }
.config-actions { display: flex; gap: 12px; margin-top: 16px; }

.recommend-box { margin-top: 12px; }
.recommend-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.recommend-logo strong { display: block; font-size: 16px; }
.recommend-logo span { font-size: 12px; color: var(--text-dim); }
.recommend-info { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.recommend-item { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.recommend-item span { color: var(--text-dim); min-width: 60px; }
.recommend-item code { color: var(--accent); font-size: 12px; }
.recommend-item a { color: var(--accent); text-decoration: none; }
.recommend-item a:hover { text-decoration: underline; }

.api-list { display: flex; flex-direction: column; gap: 12px; }
.api-item {
  padding: 12px 16px; background: var(--bg-input); border-radius: 8px;
  border: 1px solid var(--border);
}
.api-item strong { display: block; font-size: 14px; margin-bottom: 4px; }
.api-item code { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; word-break: break-all; }
.api-item span { font-size: 12px; color: var(--accent); }

/* ====== 角色模板 ====== */
.roles-template-layout { display: flex; flex-direction: column; gap: 24px; }
.roles-template-section {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 20px;
}
.roles-template-header {
  padding: 10px 16px; border-radius: 8px; font-size: 15px; font-weight: 600; margin-bottom: 16px;
}
.roles-template-header.red { background: var(--red-dim); color: var(--red); }
.roles-template-header.blue { background: var(--blue-dim); color: var(--blue); }
.role-template-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px;
}
.role-template-card {
  padding: 16px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 10px;
}
.role-template-card.red { border-left: 3px solid var(--red); }
.role-template-card.blue { border-left: 3px solid var(--blue); }
.role-template-card h4 { font-size: 15px; margin-bottom: 6px; }
.role-template-card p { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.role-template-actions { font-size: 11px; color: var(--text-muted); }

/* ====== 弹窗 ====== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6); display: none; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px;
  width: 460px; max-width: 90vw; max-height: 90vh; overflow-y: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 24px; cursor: pointer; line-height: 1; }
.modal-body { padding: 20px; }
.modal-footer { display: flex; gap: 12px; padding: 16px 20px; border-top: 1px solid var(--border); justify-content: flex-end; }

/* ====== Toast ====== */
.admin-toast {
  position: fixed; top: 20px; right: 20px; padding: 12px 20px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 14px; z-index: 2000;
  transform: translateX(400px); opacity: 0; transition: all 0.3s;
}
.admin-toast.show { transform: translateX(0); opacity: 1; }
.admin-toast.success { border-color: var(--green); color: var(--green); }
.admin-toast.error { border-color: var(--red); color: var(--red); }

/* ====== Tab切换 ====== */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ====== 加载状态 ====== */
.loading { text-align: center; padding: 40px; color: var(--text-dim); }
.ai-loading { display: inline-flex; align-items: center; gap: 6px; }
.ai-loading::before {
  content: ''; width: 14px; height: 14px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 角色操作复选框 ===== */
.actions-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 6px;
}
.action-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
  background: rgba(255,255,255,0.03);
}
.action-checkbox:hover {
  border-color: var(--accent);
}
.action-checkbox input[type="checkbox"] {
  accent-color: #00d4ff;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ===== 演练流程设计 ===== */
.drillflow-badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.drillflow-badge.active {
  background: rgba(0,212,255,0.12);
  color: var(--accent);
  border-color: rgba(0,212,255,0.4);
}
.drillflow-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  border: 1px dashed var(--border);
  border-radius: 10px;
}
.drillflow-block {
  margin-bottom: 14px;
}
.drillflow-block > label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.drillflow-block select,
.drillflow-block textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input, rgba(255,255,255,0.04));
  color: var(--text, #e8e8f0);
  font-size: 13px;
  font-family: inherit;
  box-sizing: border-box;
}
.drillflow-stages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}
.drillflow-stage {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: rgba(255,255,255,0.02);
}
.drillflow-stage-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.drillflow-stage-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a237e, #0d47a1);
  color: #00d4ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.drillflow-stage-header input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  color: var(--text, #e8e8f0);
  font-size: 13px;
  font-weight: 600;
}
.drillflow-stage .df-focus {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  color: var(--text, #e8e8f0);
  font-size: 12px;
  margin-bottom: 8px;
  box-sizing: border-box;
}
.drillflow-stage-goals,
.drillflow-win {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.drillflow-stage-goals .goal,
.drillflow-win .goal {
  border-radius: 8px;
  padding: 8px;
  border: 1px solid;
}
.drillflow-stage-goals .goal.red,
.drillflow-win .goal.red {
  border-color: rgba(231,76,60,0.35);
  background: rgba(231,76,60,0.06);
}
.drillflow-stage-goals .goal.blue,
.drillflow-win .goal.blue {
  border-color: rgba(52,152,219,0.35);
  background: rgba(52,152,219,0.06);
}
.drillflow-stage-goals .goal > span,
.drillflow-win .goal > span {
  display: block;
  font-size: 11px;
  margin-bottom: 4px;
  color: var(--text-muted);
}
.drillflow-stage-goals .goal.red > span { color: #ff7b6f; }
.drillflow-stage-goals .goal.blue > span { color: #6fb7ff; }
.drillflow-stage-goals textarea,
.drillflow-win textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: rgba(0,0,0,0.2);
  color: var(--text, #e8e8f0);
  font-size: 12px;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
}
.sc-drillflow-state {
  font-size: 11px;
  color: var(--accent);
  margin: 6px 0;
}

/* 角色双方人数平衡条 */
.role-balance-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  font-size: 13px;
  margin-bottom: 10px;
  min-height: 20px;
}
.role-balance-bar:empty { display: none; }
.role-balance-bar .ok { color: #2ecc71; font-weight: 600; }
.role-balance-bar .warn { color: #f1c40f; font-weight: 700; }
.role-balance-bar .vs { color: var(--text-muted); }
.role-balance-bar .btn-balance {
  margin-left: auto;
  border: 1px solid rgba(241,196,15,0.5);
  background: rgba(241,196,15,0.12);
  color: #f1c40f;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
}
.role-balance-bar .btn-balance:hover { background: rgba(241,196,15,0.22); }

/* AI平台内容预览 */
#platform-preview:empty { display: none; }
.pp-head { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--accent, #00d4ff); margin-bottom: 4px; }
.pp-head b { color: #2ecc71; }
.pp-sub { font-size: 12px; color: var(--text-muted); margin: 0 0 8px; line-height: 1.5; }
.pp-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.pp-item { display: flex; align-items: baseline; gap: 8px; font-size: 12px; padding: 6px 10px; background: rgba(255,255,255,0.03); border-radius: 6px; flex-wrap: wrap; }
.pp-platform { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 4px; background: rgba(0,212,255,0.12); color: var(--accent); flex-shrink: 0; }
.pp-author { font-weight: 600; color: var(--text-secondary); flex-shrink: 0; }
.pp-content { color: var(--text-secondary); line-height: 1.5; }
