/* 伟星系统地暖 Web管理后台 黑金风格 */
:root {
  --primary: #d4af37;
  --primary-light: #f0d75e;
  --primary-dark: #b8960a;
  --bg-dark: #1a1a2e;
  --bg-card: #16213e;
  --bg-card-hover: #0f3460;
  --bg-page: #0f0f1e;
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.45);
  --text-gold: #d4af37;
  --border-gold: rgba(212, 175, 55, 0.25);
  --success: #67C23A;
  --warning: #E6A23C;
  --danger: #F56C6C;
  --info: #4A90E2;
  --system-energy: #00A651;
  --system-comfort: #0057A8;
  --system-premium: #E6A23C;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
}
a { text-decoration: none; color: inherit; cursor: pointer; }
button { cursor: pointer; border: none; font-family: inherit; }
input, select, textarea { font-family: inherit; outline: none; }

/* ========== 登录页 ========== */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #16213e 0%, #1a1a2e 70%, #0f0f1e 100%);
  position: relative;
  overflow: hidden;
}
.login-bg-particles span {
  position: absolute;
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
  opacity: 0.4;
  animation: floatUp 8s infinite ease-in-out;
}
.login-bg-particles span:nth-child(1) { left: 10%; animation-delay: 0s; }
.login-bg-particles span:nth-child(2) { left: 25%; animation-delay: 1.2s; }
.login-bg-particles span:nth-child(3) { left: 45%; animation-delay: 2.5s; }
.login-bg-particles span:nth-child(4) { left: 65%; animation-delay: 3.8s; }
.login-bg-particles span:nth-child(5) { left: 80%; animation-delay: 5s; }
.login-bg-particles span:nth-child(6) { left: 92%; animation-delay: 6.5s; }
@keyframes floatUp {
  0%, 100% { transform: translateY(0); opacity: 0.2; }
  50% { transform: translateY(-60px); opacity: 0.7; }
}
.login-card {
  width: 420px;
  background: rgba(22, 33, 62, 0.85);
  backdrop-filter: blur(10px);
  border-radius: 24px;
  padding: 50px 40px;
  border: 1px solid var(--border-gold);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  z-index: 1;
}
.login-brand { text-align: center; margin-bottom: 40px; }
.brand-en { font-size: 48px; font-weight: 800; color: var(--primary); letter-spacing: 8px; }
.brand-cn { font-size: 20px; color: var(--text-primary); margin-top: 8px; letter-spacing: 4px; }
.brand-slogan { font-size: 14px; color: var(--text-secondary); margin-top: 8px; letter-spacing: 2px; }
.login-form .form-group { margin-bottom: 24px; }
.login-form label { display: block; color: var(--text-secondary); font-size: 13px; margin-bottom: 8px; }
.login-form input {
  width: 100%;
  height: 48px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0 18px;
  color: var(--text-primary);
  font-size: 14px;
  transition: all 0.2s;
}
.login-form input:focus { border-color: var(--primary); background: rgba(212, 175, 55, 0.05); }
.login-btn {
  width: 100%;
  height: 50px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: var(--bg-dark);
  border-radius: 12px;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 4px;
  margin-top: 10px;
  transition: transform 0.15s;
}
.login-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(212, 175, 55, 0.4); }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.form-tip { color: var(--text-muted); font-size: 13px; min-height: 20px; margin-bottom: 8px; }
.login-footer { text-align: center; color: var(--text-muted); font-size: 12px; margin-top: 30px; }

/* ========== 主框架 ========== */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--bg-card);
  border-right: 1px solid var(--border-gold);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-gold);
}
.brand-icon { font-size: 28px; margin-right: 12px; }
.brand-name { color: var(--primary); font-size: 16px; font-weight: bold; }
.brand-sub { color: var(--text-muted); font-size: 12px; }
.menu { flex: 1; padding: 20px 0; }
.menu-item {
  display: flex;
  align-items: center;
  padding: 14px 24px;
  color: var(--text-secondary);
  font-size: 14px;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.menu-item:hover { background: rgba(212, 175, 55, 0.08); color: var(--text-primary); }
.menu-item.active {
  background: rgba(212, 175, 55, 0.12);
  color: var(--primary);
  border-left-color: var(--primary);
}
.menu-icon { margin-right: 12px; font-size: 18px; }
.sidebar-footer { padding: 20px; border-top: 1px solid var(--border-gold); }
.user-info { color: var(--text-secondary); font-size: 12px; margin-bottom: 12px; }
.logout-btn {
  width: 100%;
  height: 36px;
  background: rgba(245, 108, 108, 0.1);
  color: var(--danger);
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid rgba(245, 108, 108, 0.3);
}
.logout-btn:hover { background: rgba(245, 108, 108, 0.2); }

.main {
  flex: 1;
  margin-left: 240px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  height: 64px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-gold);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar h1 { color: var(--primary); font-size: 20px; font-weight: bold; }
.topbar-time { color: var(--text-muted); font-size: 13px; }
.content { padding: 30px; flex: 1; }

/* ========== 通用组件 ========== */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 30px; }
.stat-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 24px;
  border: 1px solid var(--border-gold);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), transparent);
}
.stat-label { color: var(--text-secondary); font-size: 13px; margin-bottom: 8px; }
.stat-value { color: var(--primary); font-size: 32px; font-weight: bold; }
.stat-unit { font-size: 14px; color: var(--text-muted); margin-left: 4px; }
.stat-trend { font-size: 12px; color: var(--success); margin-top: 8px; }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.chart-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 24px;
  border: 1px solid var(--border-gold);
}
.chart-title { color: var(--primary); font-size: 16px; font-weight: bold; margin-bottom: 16px; }
.chart-box { width: 100%; height: 300px; }

/* 筛选栏 */
.filter-bar {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid var(--border-gold);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}
.filter-item { display: flex; align-items: center; gap: 8px; }
.filter-item label { color: var(--text-secondary); font-size: 13px; white-space: nowrap; }
.filter-item input, .filter-item select {
  height: 36px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text-primary);
  font-size: 13px;
}
.btn {
  height: 36px;
  padding: 0 20px;
  border-radius: 8px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}
.btn:hover { background: rgba(255, 255, 255, 0.15); }
.btn-primary {
  background: var(--primary);
  color: var(--bg-dark);
  font-weight: bold;
}
.btn-primary:hover { background: var(--primary-light); }
.btn-export { background: rgba(212, 175, 55, 0.15); color: var(--primary); border: 1px solid var(--border-gold); }

/* 表格 */
.table-card {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-gold);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; text-align: left; font-size: 13px; }
th {
  background: rgba(212, 175, 55, 0.08);
  color: var(--primary);
  font-weight: bold;
  border-bottom: 1px solid var(--border-gold);
  white-space: nowrap;
}
td { border-bottom: 1px solid rgba(255, 255, 255, 0.05); color: var(--text-secondary); }
tr:hover td { background: rgba(255, 255, 255, 0.02); }
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 12px;
  color: #fff;
}
.badge-energy { background: var(--system-energy); }
.badge-comfort { background: var(--system-comfort); }
.badge-premium { background: var(--system-premium); }
.source-icon { font-size: 16px; }
.status-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 12px;
  border: 1px solid;
}
.row-action {
  color: var(--primary);
  cursor: pointer;
  font-size: 13px;
}
.row-action:hover { text-decoration: underline; }
.empty-row { text-align: center; padding: 40px; color: var(--text-muted); }

/* 分页 */
.pagination { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 20px; }
.page-btn {
  min-width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-size: 13px;
}
.page-btn.active { background: var(--primary); color: var(--bg-dark); font-weight: bold; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* 抽屉 */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: none;
}
.drawer-mask.show { display: block; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 90vw;
  background: var(--bg-card);
  border-left: 2px solid var(--primary);
  z-index: 201;
  transform: translateX(100%);
  transition: transform 0.3s;
  overflow-y: auto;
}
.drawer.show { transform: translateX(0); }
.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-gold);
}
.drawer-title { color: var(--primary); font-size: 18px; font-weight: bold; }
.drawer-close { color: var(--text-muted); font-size: 28px; cursor: pointer; line-height: 1; }
.drawer-body { padding: 24px; }
.detail-row { display: flex; padding: 12px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.detail-k { width: 100px; color: var(--text-muted); font-size: 13px; }
.detail-v { flex: 1; color: var(--text-primary); font-size: 13px; word-break: break-all; }

.section-block { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border-gold); }
.section-block-title { color: var(--primary); font-size: 15px; font-weight: bold; margin-bottom: 12px; }
.flow-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.flow-btn {
  padding: 6px 14px;
  border-radius: 14px;
  font-size: 12px;
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
}
.flow-btn.active { color: #fff; font-weight: bold; }

.follow-list { margin-bottom: 12px; }
.follow-item { background: rgba(255, 255, 255, 0.04); border-radius: 8px; padding: 12px; margin-bottom: 8px; }
.follow-time { color: var(--text-muted); font-size: 12px; margin-bottom: 4px; }
.follow-content { color: var(--text-secondary); font-size: 13px; }
.follow-input-row { display: flex; gap: 8px; }
.follow-input-row input { flex: 1; }
.follow-input-row .btn { white-space: nowrap; }

/* 设置页 */
.settings-form { max-width: 800px; }
.settings-group {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--border-gold);
}
.settings-group-title { color: var(--primary); font-size: 16px; font-weight: bold; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border-gold); }
.settings-row { display: flex; align-items: center; padding: 12px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.settings-row:last-child { border-bottom: none; }
.settings-label { width: 200px; color: var(--text-secondary); font-size: 13px; }
.settings-input { flex: 1; max-width: 500px; }
.settings-input input, .settings-input textarea, .settings-input select {
  width: 100%;
  height: 36px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text-primary);
  font-size: 13px;
}
.settings-input textarea { height: 80px; padding: 8px 12px; resize: vertical; }
.switch { position: relative; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  transition: 0.2s;
}
.switch-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}
.switch input:checked + .switch-slider { background: var(--primary); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); }

.settings-actions { margin-top: 20px; }

/* 提示 */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: 8px;
  border: 1px solid var(--primary);
  z-index: 9999;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.3s;
}
.toast.show { opacity: 1; }
.toast.success { color: var(--success); }
.toast.error { color: var(--danger); }

/* loading */
.loading-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 30, 0.7);
  z-index: 9998;
  display: none;
  align-items: center;
  justify-content: center;
}
.loading-mask.show { display: flex; }
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(212, 175, 55, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
}

/* ===== 会话管理（自研聊天） ===== */
.chat-admin {
  display: flex;
  height: calc(100vh - 180px);
  min-height: 480px;
  border-radius: 12px;
  overflow: hidden;
  background: #191b2c;
  border: 1px solid #2a2e45;
}
.chat-admin-list {
  width: 300px;
  border-right: 1px solid #2a2e45;
  overflow-y: auto;
  flex-shrink: 0;
}
.chat-session-item {
  padding: 14px 16px;
  border-bottom: 1px solid #22263c;
  cursor: pointer;
  transition: background .2s;
}
.chat-session-item:hover { background: #20233a; }
.chat-session-item.active { background: #262b45; border-left: 3px solid #d4af37; }
.cs-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.cs-nick { color: #e8eaf5; font-size: 14px; font-weight: 600; }
.cs-time { color: #5c6276; font-size: 11px; }
.cs-preview { color: #8a8fa5; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-unread {
  display: inline-block;
  background: #f56c6c;
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  padding: 0 6px;
  margin-left: 8px;
  line-height: 16px;
}
.chat-admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-admin-header {
  padding: 12px 16px;
  border-bottom: 1px solid #2a2e45;
  color: #c8cde0;
  font-size: 13px;
}
.chat-admin-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #141624;
}
.chat-msg { margin-bottom: 14px; max-width: 78%; }
.chat-msg-agent { margin-left: 0; }
.chat-msg-user { margin-left: auto; }
.chat-msg-meta { color: #5c6276; font-size: 11px; margin-bottom: 5px; }
.chat-msg-agent .chat-msg-meta { text-align: left; }
.chat-msg-user .chat-msg-meta { text-align: right; }
.chat-msg-bubble {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-all;
}
.chat-msg-agent .chat-msg-bubble { background: #232a44; color: #e6e9f5; border-top-left-radius: 2px; }
.chat-msg-user .chat-msg-bubble { background: linear-gradient(135deg, #f0d75e, #d4af37); color: #1a1a2e; border-top-right-radius: 2px; }
.chat-admin-input-row {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid #2a2e45;
  background: #191b2c;
}
