/* ============================================================
   TG 群管后台 - 现代化样式
   设计语言：柔和阴影 + 紫蓝渐变 + iOS 开关 + 圆角卡片
   ============================================================ */

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --bg: #f5f6fa;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --danger: #ef4444;
  --success: #10b981;
  --warn: #f59e0b;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.12);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   登录页
   ============================================================ */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-grad);
  padding: 20px;
}
.auth-wrap { width: 100%; max-width: 400px; text-align: center; }
.auth-card {
  background: var(--surface);
  border-radius: 24px;
  padding: 44px 36px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 80px; height: 80px; margin: 0 auto 16px;
  border-radius: 22px; background: var(--primary-grad); color: #fff;
  box-shadow: 0 8px 24px rgba(99,102,241,.35);
}
.auth-logo svg { width: 44px; height: 44px; }
.auth-card h1 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.auth-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form .field { text-align: left; }
.auth-form label {
  display: block; font-size: 13px; font-weight: 600;
  margin-bottom: 6px; color: var(--text);
}
.auth-form input {
  width: 100%; padding: 13px 16px; font-size: 15px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color .2s, box-shadow .2s;
  background: #f8fafc;
}
.auth-form input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
  background: #fff;
}
.auth-foot { color: rgba(255,255,255,.8); font-size: 12px; margin-top: 20px; }

/* ============================================================
   按钮
   ============================================================ */
.btn-primary, .btn-ghost, .btn-block, .btn-small {
  border: none; cursor: pointer; font-weight: 600;
  border-radius: var(--radius-sm); transition: all .18s;
  font-family: inherit;
}
.btn-primary {
  background: var(--primary-grad); color: #fff;
  padding: 11px 20px; font-size: 14px;
  box-shadow: 0 4px 12px rgba(99,102,241,.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(99,102,241,.4); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
  background: #f1f5f9; color: var(--text);
  padding: 11px 20px; font-size: 14px;
}
.btn-ghost:hover { background: #e2e8f0; }
.btn-block { width: 100%; padding: 13px; font-size: 15px; }
.btn-small {
  background: var(--primary); color: #fff;
  padding: 7px 14px; font-size: 13px;
}
.btn-small:hover { background: var(--primary-dark); }
.btn-danger {
  background: var(--danger); color: #fff;
  border: none; padding: 7px 14px; font-size: 13px;
  border-radius: var(--radius-sm); cursor: pointer; font-weight: 600;
}
.btn-danger:hover { background: #dc2626; }

/* ============================================================
   主布局：侧边栏 + 内容
   ============================================================ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px; background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  flex-shrink: 0;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 24px; border-bottom: 1px solid var(--border);
}
.brand-logo {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px; background: var(--primary-grad);
  color: #fff;
}
.brand-logo svg { width: 24px; height: 24px; }
.brand-name { font-size: 18px; font-weight: 700; }
.nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: block; padding: 12px 16px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 600; font-size: 14px;
  cursor: pointer; transition: all .15s; text-decoration: none;
}
.nav-item:hover { background: #f1f5f9; color: var(--text); }
.nav-item.active { background: var(--primary-grad); color: #fff; }
.nav-ico { display: inline-flex; vertical-align: middle; margin-right: 8px; }
.nav-ico svg { width: 18px; height: 18px; }
.sidebar-foot { padding: 16px; }

/* 按钮内 SVG 图标间距 */
.btn-primary svg, .btn-ghost svg, .btn-small svg, .btn-danger svg, .btn-block svg {
  vertical-align: middle; margin-right: 6px;
}
.back-link svg { vertical-align: middle; margin-right: 4px; }

.content { flex: 1; padding: 0; overflow-x: hidden; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 32px; background: rgba(255,255,255,.8);
  backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 10;
  border-bottom: 1px solid var(--border);
}
.topbar h2 { font-size: 22px; font-weight: 700; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.view { padding: 28px 32px; display: flex; flex-direction: column; gap: 20px; }

/* ============================================================
   卡片
   ============================================================ */
.card {
  background: var(--surface); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
}
.card-head h3 { font-size: 16px; font-weight: 700; }
.card-actions { margin-top: 14px; }

/* ============================================================
   机器人卡片网格
   ============================================================ */
.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.bot-card {
  background: var(--surface); border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow); transition: transform .18s, box-shadow .18s;
  cursor: pointer; border: 2px solid transparent;
}
.bot-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.bot-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.bot-avatar {
  width: 52px; height: 52px; border-radius: 14px; background: var(--primary-grad);
  display: flex; align-items: center; justify-content: center; color: #fff;
  flex-shrink: 0;
}
.bot-name { font-size: 16px; font-weight: 700; }
.bot-username { font-size: 13px; color: var(--text-muted); }
.status-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 4px 10px;
  border-radius: 20px; margin-top: 6px;
}
.status-online { background: #dcfce7; color: #15803d; }
.status-offline { background: #f1f5f9; color: #64748b; }
.status-dot::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor;
}
.bot-stats {
  display: flex; gap: 18px; padding: 14px 0;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.stat-item { flex: 1; }
.stat-num { font-size: 22px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-muted); }
.bot-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   群列表
   ============================================================ */
.chat-list { display: flex; flex-direction: column; gap: 10px; }
.chat-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; background: #f8fafc; border-radius: var(--radius-sm);
  border: 1px solid var(--border); transition: all .15s; cursor: pointer;
}
.chat-item:hover { background: #f1f5f9; border-color: var(--primary); }
.chat-info { display: flex; align-items: center; gap: 12px; }
.chat-icon {
  width: 40px; height: 40px; border-radius: 12px; background: #e0e7ff;
  display: flex; align-items: center; justify-content: center; color: var(--primary); font-size: 18px;
}
.chat-title { font-weight: 600; font-size: 14px; }
.chat-id { font-size: 12px; color: var(--text-muted); }
.toggle-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 11px; padding: 3px 9px; border-radius: 12px;
  font-weight: 600;
}
.badge-on { background: #dcfce7; color: #15803d; }
.badge-off { background: #f1f5f9; color: #94a3b8; }

/* ============================================================
   开关 (iOS 风格)
   ============================================================ */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row label { font-size: 14px; font-weight: 500; }
.switch {
  position: relative; width: 46px; height: 26px; cursor: pointer;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; background: #cbd5e1; border-radius: 30px;
  transition: .25s;
}
.slider::before {
  content: ''; position: absolute; width: 20px; height: 20px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .25s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--primary-grad); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ============================================================
   表单元素
   ============================================================ */
.input, .textarea {
  width: 100%; padding: 12px 14px; font-size: 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; background: #f8fafc; transition: all .18s;
}
.input:focus, .textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12); background: #fff;
}
.textarea { resize: vertical; line-height: 1.6; }
select.input { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%2394a3b8' d='M6 8L2 4h8z'/></svg>"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px;
}
.kw-row { margin-bottom: 18px; }
.kw-row label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }

/* ============================================================
   弹窗
   ============================================================ */
.modal {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(15,23,42,.5); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 20px;
  overflow-y: auto;  /* 弹窗本身也可滚动，避免内容高于视口 */
}
.modal.open { display: flex; }
.modal-card {
  background: var(--surface); border-radius: 20px; padding: 28px;
  width: 100%; max-width: 440px; box-shadow: var(--shadow-lg);
  animation: pop .2s ease;
  max-height: 90vh; overflow-y: auto;  /* 内容超长时卡片内滚动 */
}
.modal-lg { max-width: 720px; }
@keyframes pop {
  from { opacity: 0; transform: scale(.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-card h3 { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.modal-card .muted { font-size: 13px; margin-bottom: 16px; display: block; }
.modal-card .input { margin-bottom: 14px; }
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px;
}

/* ============================================================
   定时任务列表
   ============================================================ */
.job-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: #f8fafc; border-radius: var(--radius-sm);
  margin-bottom: 8px; border: 1px solid var(--border);
}
.job-time { font-weight: 700; color: var(--primary); font-size: 15px; min-width: 70px; }
.job-text { flex: 1; font-size: 13px; margin: 0 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================
   通用
   ============================================================ */
.muted { color: var(--text-muted); font-size: 13px; }
.err-msg { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; color: #cbd5e1; display: flex; justify-content: center; }
.section-title {
  font-size: 14px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px;
}
.detail-header {
  display: flex; align-items: center; gap: 14px; margin-bottom: 20px;
  padding-bottom: 18px; border-bottom: 1px solid var(--border);
}
.detail-header .bot-avatar {
  width: 44px; height: 44px; font-size: 22px;
}
.back-link {
  color: var(--primary); font-size: 13px; cursor: pointer; font-weight: 600;
  margin-bottom: 16px; display: inline-block;
}
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag {
  background: #eef2ff; color: var(--primary); font-size: 12px;
  padding: 4px 10px; border-radius: 12px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 5px;
}
.tag .remove { cursor: pointer; opacity: .6; }
.tag .remove:hover { opacity: 1; }

/* ============================================================
   Tabs 分页（群设置抽屉）
   ============================================================ */
.tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border); margin-bottom: 18px;
}
.tab {
  border: none; background: transparent; cursor: pointer;
  padding: 10px 16px; font-size: 14px; font-weight: 600;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  transition: all .15s; font-family: inherit; border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--text); background: #f1f5f9; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* 响应式 */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .view, .topbar { padding: 20px; }
  .bot-grid { grid-template-columns: 1fr; }
  .tab { padding: 8px 12px; font-size: 13px; }
}
