/* ══════════════════════════════════════════
   Surf Studio · 后台管理界面
   ══════════════════════════════════════════ */

:root {
  --bg: #f5f6fa;
  --panel: #ffffff;
  --panel-2: #fafbfd;
  --border: #e6e9f0;
  --border-strong: #d5dae5;
  --text: #1a1a1a;
  --text-2: #3c4043;
  --text-3: #5f6368;
  --accent: #1a73e8;
  --accent-deep: #0f2a5c;
  --accent-soft: #e8f0fe;
  --gold: #c49a6c;
  --gold-ink: #a17c50;
  --gold-soft: #f7f0e7;
  --ok: #1e7a46;
  --ok-soft: #e7f4ec;
  --warn: #a0671a;
  --warn-soft: #fcf3e4;
  --err: #b3261e;
  --err-soft: #fcedeb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.08);

  --font-serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", SimSun, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC",
    "Source Han Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
}

a {
  color: inherit;
  text-decoration: none;
}

.admin {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

/* ── 侧边栏 ───────────────────────────── */
.sidebar {
  background: var(--accent-deep);
  color: #c9d6ea;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  display: grid;
  place-items: center;
  flex: 0 0 34px;
}

.side-title {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin: 0;
  letter-spacing: 0.01em;
}

.side-sub {
  font-family: var(--font-serif);
  font-size: 12px;
  color: var(--gold);
  margin: 1px 0 0;
  letter-spacing: 0.06em;
}

.side-nav {
  padding: 16px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 15px;
  color: #c9d6ea;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-weight: 550;
}

.nav-ico {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex: 0 0 20px;
}

.side-foot {
  padding: 16px 20px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.side-link {
  font-size: 13.5px;
  color: #8fa3c4;
  transition: color 0.15s;
}

.side-link:hover {
  color: #fff;
}

/* ── 主内容 ───────────────────────────── */
.content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.content-head {
  padding: 22px 30px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.content-head h1 {
  font-family: var(--font-serif);
  font-size: 25px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.005em;
}

.view-sub {
  font-size: 14px;
  color: var(--text-3);
  margin: 3px 0 0;
}

.head-actions {
  display: flex;
  gap: 9px;
  align-items: center;
}

.content-body {
  padding: 26px 30px 44px;
  flex: 1;
}

.loading {
  padding: 60px;
  text-align: center;
  color: var(--text-3);
  font-size: 15px;
}

/* ── 按钮 ─────────────────────────────── */
.btn {
  font-family: inherit;
  font-size: 14.5px;
  padding: 8px 17px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: all 0.14s;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--panel-2);
  border-color: #b9c0cc;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 550;
}

.btn.primary:hover:not(:disabled) {
  background: #1557b8;
}

.btn.danger {
  color: var(--err);
  border-color: #f0b4b4;
}

.btn.danger:hover:not(:disabled) {
  background: var(--err-soft);
}

.btn-tiny {
  font-family: inherit;
  font-size: 13px;
  padding: 4px 11px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.14s;
}

.btn-tiny:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #c7d8f7;
}

.btn-tiny.danger:hover {
  background: var(--err-soft);
  color: var(--err);
  border-color: #f0b4b4;
}

/* ── 统计卡片 ─────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 26px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 13.5px;
  color: var(--text-3);
  margin: 0 0 7px;
}

.stat-value {
  font-size: 31px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stat-value.accent {
  color: var(--accent);
}
.stat-value.ok {
  color: var(--ok);
}
.stat-value.gold {
  color: var(--gold-ink);
}

.stat-unit {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-3);
  margin-left: 3px;
}

/* ── 区块 ─────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  overflow: hidden;
}

.panel-head {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-head h2 {
  font-size: 16.5px;
  font-weight: 620;
  margin: 0;
}

.panel-body {
  padding: 18px 20px;
}

.panel-body.flush {
  padding: 0;
}

/* ── 分身卡片 ─────────────────────────── */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 15px;
}

.agent-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 19px 20px;
  box-shadow: var(--shadow);
  transition: all 0.18s;
  position: relative;
}

.agent-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #c7d8f7;
  transform: translateY(-2px);
}

.agent-card.paused {
  opacity: 0.72;
  background: var(--panel-2);
}

.agent-top {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-bottom: 12px;
}

.agent-avatar {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: linear-gradient(135deg, #eaf1fd 0%, #fbf5ec 100%);
  border: 1px solid #dfe6f5;
  display: grid;
  place-items: center;
  font-size: 21px;
  color: var(--accent);
  flex: 0 0 44px;
}

.agent-meta {
  flex: 1;
  min-width: 0;
}

.agent-name {
  font-size: 17px;
  font-weight: 620;
  margin: 0 0 2px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 7px;
}

.agent-style {
  font-family: var(--font-serif);
  font-size: 13px;
  color: var(--gold-ink);
  margin: 0;
}

.agent-persona {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.75;
  margin: 0 0 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.agent-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.agent-stat {
  font-size: 13px;
  color: var(--text-3);
}

.agent-actions {
  display: flex;
  gap: 6px;
}

.tag {
  font-size: 11.5px;
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
  flex: 0 0 auto;
}

.tag.default {
  background: var(--gold-soft);
  color: var(--gold-ink);
}

.tag.active {
  background: var(--ok-soft);
  color: var(--ok);
}

.tag.paused {
  background: #f1f3f5;
  color: var(--text-3);
}

.tag.done {
  background: var(--ok-soft);
  color: var(--ok);
}

.tag.failed,
.tag.stopped {
  background: var(--err-soft);
  color: var(--err);
}

.tag.running,
.tag.waiting,
.tag.queued {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ── 表格 ─────────────────────────────── */
.table-scroll {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  min-width: 720px;
}

table.data th {
  background: var(--panel-2);
  text-align: left;
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

table.data td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: top;
}

table.data tbody tr:last-child td {
  border-bottom: none;
}

table.data tbody tr:hover {
  background: var(--panel-2);
}

.cell-strong {
  color: var(--text);
  font-weight: 500;
}

.cell-agent {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.cell-avatar {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 14px;
  flex: 0 0 26px;
}

.cell-task {
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.cell-mono {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.empty-row {
  padding: 50px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 14.5px;
}

/* ── 筛选栏 ───────────────────────────── */
.filter-bar {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-bar select,
.filter-bar input {
  font-family: inherit;
  font-size: 14px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
}

.filter-bar select:focus,
.filter-bar input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

/* ── 表单 ─────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 15px;
  flex: 1;
  min-width: 0;
}

.field > span {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 550;
}

.field input,
.field select,
.field textarea {
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 14.5px;
  background: var(--panel-2);
  color: var(--text);
  width: 100%;
  line-height: 1.65;
}

.field textarea {
  resize: vertical;
  min-height: 96px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.field-row {
  display: flex;
  gap: 14px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 14.5px;
  color: var(--text-2);
  margin-bottom: 12px;
  cursor: pointer;
  line-height: 1.6;
}

.check input {
  margin-top: 4px;
  flex: 0 0 auto;
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

.avatar-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.avatar-opt {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  font-size: 18px;
  color: var(--accent);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.14s;
}

.avatar-opt:hover {
  border-color: var(--accent);
}

.avatar-opt.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.18);
}

.tip {
  font-size: 13.5px;
  color: var(--text-3);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 14px;
  margin: 6px 0 0;
  line-height: 1.7;
}

.tip strong {
  color: var(--text-2);
}

.divider {
  margin: 20px 0 16px;
  border-top: 1px solid var(--border);
  position: relative;
  text-align: center;
}

.divider span {
  position: relative;
  top: -10px;
  background: var(--panel);
  padding: 0 10px;
  font-size: 12.5px;
  color: var(--text-3);
}

/* ── 弹窗 ─────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, 0.5);
  display: grid;
  place-items: center;
  z-index: 100;
  backdrop-filter: blur(2px);
  padding: 20px;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  background: var(--panel);
  border-radius: 15px;
  width: min(620px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 56px rgba(16, 24, 40, 0.24);
  animation: popIn 0.18s ease-out;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 620;
}

.modal-close {
  border: none;
  background: none;
  font-size: 16px;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 7px;
  line-height: 1;
}

.modal-close:hover {
  background: var(--panel-2);
  color: var(--text);
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
}

.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 9px;
  align-items: center;
}

.spacer {
  flex: 1;
}

/* ── 提示条 ───────────────────────────── */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-deep);
  color: #fff;
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 14.5px;
  box-shadow: 0 8px 26px rgba(16, 24, 40, 0.24);
  z-index: 200;
  animation: toastIn 0.2s ease-out;
}

.toast.err {
  background: var(--err);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ── 响应式 ───────────────────────────── */
@media (max-width: 1100px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 820px) {
  .admin {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 12px 16px;
    gap: 14px;
    overflow-x: auto;
  }
  .side-brand {
    border-bottom: none;
    padding: 0;
  }
  .side-nav {
    flex-direction: row;
    padding: 0;
    gap: 6px;
  }
  .nav-item span:not(.nav-ico) {
    display: none;
  }
  .side-foot {
    display: none;
  }
  .content-body,
  .content-head {
    padding-left: 18px;
    padding-right: 18px;
  }
  .field-row {
    flex-direction: column;
  }
}

/* ── 语言切换器（右上角）───────────────── */
.lang-switcher {
  position: relative;
  display: inline-block;
  font-size: 14px;
  line-height: 1;
}

#langSwitch {
  margin-left: auto;
}

.lang-current {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 13px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
}

.lang-current:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.lang-current svg {
  color: var(--text-3);
  flex: 0 0 auto;
}

.lang-current[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 158px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.12);
  padding: 6px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: langPop 0.14s ease-out;
}

.lang-dropdown[hidden] {
  display: none;
}

@keyframes langPop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 8px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.lang-option:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.lang-option.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.lang-option.active::after {
  content: "✓";
  font-size: 12px;
  color: var(--accent);
}
