/* ============================================================
 * 管理端样式 — 标准产品后台
 * 浅色侧边栏 + 工作区
 * ============================================================ */

body {
  background: var(--bg);
}

/* ============================================================
 * 整体布局
 * ============================================================ */

.adm-layout {
  display: flex;
  min-height: 100vh;
}

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

.adm-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: var(--space-5) 0;
}

.adm-brand {
  padding: 0 var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--space-3);
}
.adm-brand-name {
  font-size: var(--fs-card-title);
  font-weight: 700;
  color: var(--text);
}
.adm-brand-tag {
  font-size: var(--fs-caption);
  color: var(--text-muted);
  margin-top: 4px;
}

.adm-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 var(--space-3);
}
.adm-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  color: var(--text);
  font-size: var(--fs-body);
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all var(--t-fast) var(--easing);
}
.adm-nav a:hover {
  background: var(--bg);
  text-decoration: none;
}
.adm-nav a.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.adm-nav a .icon {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-muted);
}
.adm-nav a.active .icon {
  background: var(--brand);
  color: #fff;
}

.adm-sidebar-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--line);
  font-size: var(--fs-caption);
  color: var(--text-muted);
}

/* ----- 工作区 ----- */

.adm-content {
  flex: 1;
  padding: var(--space-6);
  min-width: 0;
  max-width: 1240px;
}

.adm-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.adm-page-header .titles h1 {
  font-size: var(--fs-page-title);
  font-weight: 700;
  margin-bottom: 4px;
}
.adm-page-header .titles p {
  font-size: var(--fs-meta);
  color: var(--text-muted);
}
.adm-page-header .actions {
  display: flex;
  gap: var(--space-2);
}

/* ============================================================
 * 表格
 * ============================================================ */

.adm-table {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}
.adm-table thead th {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--fs-caption);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.adm-table tbody td {
  padding: var(--space-4);
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-body);
  color: var(--text);
  vertical-align: middle;
}
.adm-table tbody tr:last-child td { border-bottom: none; }
.adm-table tbody tr:hover { background: var(--surface-2); }
.adm-table .col-id { color: var(--text-muted); font-variant-numeric: tabular-nums; width: 60px; }
.adm-table .col-actions { text-align: right; white-space: nowrap; }
.adm-table .col-actions .btn { margin-left: var(--space-2); }
.adm-table .col-num { font-variant-numeric: tabular-nums; }

/* ============================================================
 * 编辑卡片（segmented sections）
 * ============================================================ */

.adm-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
  overflow: hidden;
}
.adm-section-head {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.adm-section-head .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: var(--fs-meta);
  font-weight: 700;
  margin-right: var(--space-3);
}
.adm-section-head h2 {
  font-size: var(--fs-card-title);
  font-weight: 600;
  color: var(--text);
  display: inline;
}
.adm-section-head .help {
  font-size: var(--fs-caption);
  color: var(--text-muted);
  margin-left: var(--space-2);
}
.adm-section-body {
  padding: var(--space-5);
}

/* ----- 重复行（题目、按钮 etc）----- */

.repeater {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.repeater-row {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
}
.repeater-row textarea,
.repeater-row input[type="text"] {
  flex: 1;
}
.repeater-row textarea {
  min-height: 60px;
}
.repeater-row .btn-del {
  flex-shrink: 0;
  height: 40px;
  padding: 0 var(--space-3);
  background: var(--surface);
  color: var(--error);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--fs-meta);
}
.repeater-row .btn-del:hover {
  background: var(--error-soft);
  border-color: var(--error);
}

/* ----- 题目分组卡（按钮配置）----- */

.q-group {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}
.q-group-title {
  font-size: var(--fs-label);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.q-group-title .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

/* ----- 底部 sticky action bar ----- */

.adm-action-bar {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-5);
  margin-top: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  box-shadow: var(--shadow);
}
.adm-action-bar .lock-tip {
  font-size: var(--fs-meta);
  color: var(--review);
  flex: 1;
}
.adm-action-bar .actions {
  display: flex;
  gap: var(--space-2);
}

/* ============================================================
 * 日志页
 * ============================================================ */

.log-filters {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  align-items: center;
}
.log-filters input,
.log-filters select {
  width: auto;
  height: 36px;
  font-size: var(--fs-meta);
}
.log-filters input[type="text"] { width: 160px; }
.log-filters select { width: 200px; }

.log-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.log-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--fs-meta);
}
.log-item .ts {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.log-item .scope {
  flex-shrink: 0;
}
.log-item .desc {
  flex: 1;
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: var(--fs-caption);
  word-break: break-all;
}

/* ============================================================
 * 账号管理
 * ============================================================ */

.acc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}
@media (max-width: 900px) {
  .acc-grid { grid-template-columns: 1fr; }
}
.acc-add {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.acc-add input { flex: 1; }

/* ============================================================
 * 移动顶栏（仅 ≤ 880px 显示）
 * ============================================================ */

.adm-mobile-bar {
  display: none;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: var(--space-3) var(--space-4);
  align-items: center;
  gap: var(--space-3);
  position: sticky;
  top: 0;
  z-index: 30;
}
.adm-mobile-bar .menu-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
}
.adm-mobile-bar .menu-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}
.adm-mobile-bar .brand {
  font-size: var(--fs-card-title);
  font-weight: 700;
  color: var(--text);
}

.adm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  z-index: 40;
}
.adm-overlay.is-open { display: block; }

/* ============================================================
 * 移动端响应（≤ 880px）
 * ============================================================ */

@media (max-width: 880px) {
  .adm-layout {
    flex-direction: column;
    min-height: 100vh;
  }

  .adm-mobile-bar { display: flex; }

  /* 侧边栏 → 抽屉 */
  .adm-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 50;
    width: 240px;
    transform: translateX(-100%);
    transition: transform .3s var(--easing);
    box-shadow: var(--shadow-lg);
    border-right: none;
  }
  .adm-sidebar.is-open {
    transform: translateX(0);
  }

  .adm-content {
    padding: var(--space-4);
    max-width: none;
  }

  .adm-page-header {
    flex-direction: column;
    align-items: stretch;
  }
  .adm-page-header .titles h1 { font-size: 22px; }
  .adm-page-header .actions {
    width: 100%;
  }
  .adm-page-header .actions .btn { flex: 1; }

  /* 表格横向滚动包装 */
  .adm-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    border-radius: var(--radius);
  }
  .adm-table thead, .adm-table tbody, .adm-table tr {
    display: table;
    width: 100%;
    table-layout: auto;
  }

  /* 表单 repeater 行 → 列布局 */
  .repeater-row {
    flex-direction: column;
    align-items: stretch;
  }
  .repeater-row .btn-del {
    align-self: flex-end;
    height: 32px;
  }

  /* 账号 grid 单列 */
  .acc-grid { grid-template-columns: 1fr; }
  .acc-add { flex-wrap: wrap; }
  .acc-add input { min-width: 0; }

  /* 编辑页 sticky 操作栏在移动端紧凑 */
  .adm-action-bar {
    padding: var(--space-3) var(--space-4);
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  .adm-action-bar .actions { width: 100%; }
  .adm-action-bar .actions .btn { flex: 1; }
  .adm-action-bar .lock-tip {
    width: 100%;
    flex: none;
  }

  /* 日志 filter 行换行 */
  .log-filters { flex-wrap: wrap; }
  .log-filters input,
  .log-filters select { width: 100%; }
}

/* 更窄的手机 */
@media (max-width: 480px) {
  .adm-content { padding: var(--space-3); }
  .adm-section-body { padding: var(--space-4); }
  .adm-section-head { padding: var(--space-3) var(--space-4); }
  .adm-table th, .adm-table td {
    padding: var(--space-3);
    font-size: var(--fs-meta);
  }
}
