/* ============================================================
 * Telegram 群管后台样式表
 * 说明：
 * - 采用「深色侧边栏 + 浅色内容区」的经典后台布局；
 * - 全部样式使用原生 CSS，不依赖任何 UI 框架，宝塔环境零构建即可运行；
 * - 断点 900px：小屏下侧边栏折叠为顶部横向导航，表格改为卡片式滚动。
 * ============================================================ */

:root {
  --brand: #2481cc;
  --brand-dark: #1c6cb0;
  --brand-soft: #e8f2fb;
  --bg: #f4f6fa;
  --panel: #ffffff;
  --sidebar: #1d2739;
  --sidebar-active: #2b3a52;
  --text: #1f2937;
  --text-2: #6b7280;
  --text-3: #9aa3b2;
  --border: #e5e8ef;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --success: #16a34a;
  --success-soft: #e9f8ef;
  --warning: #d97706;
  --warning-soft: #fdf3e2;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.05);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a {
  color: var(--brand);
  text-decoration: none;
}

/* ==================== 登录页 ==================== */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #1d2739 0%, #2f4a6d 100%);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(8, 15, 30, 0.35);
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 20px;
}

.login-tip {
  margin: 0 0 22px;
  color: var(--text-3);
  font-size: 13px;
}

/* ==================== 整体布局 ==================== */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 216px;
  flex: 0 0 216px;
  background: var(--sidebar);
  color: #cbd5e1;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 18px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}

.sidebar-brand span.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
}

.sidebar-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #c7d2e0;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.16s, color 0.16s;
  user-select: none;
}

.sidebar-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.sidebar-item.active {
  background: var(--sidebar-active);
  color: #fff;
}

.sidebar-item .badge {
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  border-radius: 9px;
  padding: 0 6px;
  line-height: 17px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 12px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: #93a2b8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 22px 26px 48px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.page-head h2 {
  margin: 0;
  font-size: 19px;
}

.page-head p {
  margin: 2px 0 0;
  color: var(--text-3);
  font-size: 13px;
}

/* ==================== 卡片 / 面板 ==================== */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.card-body {
  padding: 18px;
}

.card-body.tight {
  padding: 0;
}

.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.stat .label {
  color: var(--text-3);
  font-size: 13px;
}

.stat .value {
  font-size: 26px;
  font-weight: 600;
  margin-top: 4px;
}

/* ==================== 表单 ==================== */

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  color: var(--text-2);
}

.field .hint {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-3);
}

input[type='text'],
input[type='password'],
input[type='number'],
textarea,
select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(36, 129, 204, 0.12);
}

textarea {
  resize: vertical;
  min-height: 76px;
  line-height: 1.6;
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin: 0 0 12px;
}

.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.form-row > .field {
  flex: 1;
  min-width: 160px;
}

.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.inline-form input[type='text'] {
  flex: 1;
  min-width: 180px;
}

/* 模板的内联按钮编辑器：每行一个按钮（文字 + 链接 + 删除） */
.button-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.button-row input[type='text'] {
  flex: 1;
  min-width: 160px;
}

/* ==================== 按钮 ==================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: #cfd6e3;
  background: #fafbfd;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn-danger {
  color: var(--danger);
  border-color: #f3c6c7;
  background: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-soft);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-block {
  width: 100%;
}

.btn-link {
  border: none;
  background: none;
  color: var(--brand);
  padding: 0;
  cursor: pointer;
  font-size: 13px;
}

/* ==================== 表格 ==================== */

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data th,
table.data td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.data th {
  background: #f9fafc;
  color: var(--text-2);
  font-weight: 600;
  white-space: nowrap;
}

table.data tbody tr:hover {
  background: #fafbfe;
}

table.data td.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-2);
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.stack-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.hint {
  font-size: 12px;
  color: var(--text-3);
}

/* ==================== 标签 / 开关 ==================== */

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 12px;
  line-height: 18px;
  background: #f1f3f7;
  color: var(--text-2);
  white-space: nowrap;
}

.tag.on {
  background: var(--success-soft);
  color: var(--success);
}

.tag.off {
  background: #f1f3f7;
  color: var(--text-3);
}

.tag.warn {
  background: var(--warning-soft);
  color: var(--warning);
}

.tag.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.tag.brand {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.switch-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  cursor: pointer;
}

.switch-field:last-child {
  border-bottom: none;
}

.switch-field .meta strong {
  display: block;
  font-weight: 500;
  font-size: 14px;
}

.switch-field .meta small {
  color: var(--text-3);
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex: 0 0 42px;
  border-radius: 12px;
  background: #d5dae4;
  transition: background 0.18s;
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.18s;
}

.switch.on {
  background: var(--brand);
}

.switch.on::after {
  transform: translateX(18px);
}

/* ==================== 标签页 ==================== */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  padding: 0 18px;
  overflow-x: auto;
}

.tabs button {
  border: none;
  background: none;
  padding: 12px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tabs button.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}

/* ==================== 提示条 ==================== */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px 3px 10px;
  border-radius: 20px;
  background: #f1f3f7;
  font-size: 13px;
}

.chip.black {
  background: var(--danger-soft);
  color: #9b2c2f;
}

.chip.white {
  background: var(--success-soft);
  color: #166534;
}

.chip button {
  border: none;
  background: rgba(0, 0, 0, 0.06);
  width: 17px;
  height: 17px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  color: inherit;
}

.chip button:hover {
  background: rgba(0, 0, 0, 0.14);
}

.empty {
  padding: 28px 18px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}

.alert.warn {
  background: var(--warning-soft);
  color: #92400e;
}

.alert.info {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

/* ==================== Toast ==================== */

.toast-layer {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  padding: 9px 18px;
  border-radius: 8px;
  background: #1f2937;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(8, 15, 30, 0.25);
  max-width: 80vw;
}

.toast.success {
  background: #15803d;
}

.toast.error {
  background: #b42318;
}

/* ==================== 小屏适配 ==================== */

@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex: none;
    flex-direction: row;
    overflow-x: auto;
    padding: 10px 12px;
    align-items: center;
    gap: 6px;
  }

  .sidebar-brand {
    padding: 0 10px 0 4px;
    white-space: nowrap;
  }

  .sidebar-item {
    white-space: nowrap;
  }

  .sidebar-footer {
    margin: 0 0 0 auto;
    border-top: none;
    padding: 0 4px;
  }

  .main {
    padding: 16px 14px 40px;
  }

  .page-head h2 {
    font-size: 17px;
  }
}
