/* 抖房通公共样式 — 深色主题 + 通用组件（所有页面共用） */
:root {
  --bg: #0f1220; --card: #1a1e30; --card2: #22273d; --border: #2e3450;
  --text: #e8eaf2; --muted: #8a90a8; --accent: #4f8cff;
  --green: #22c55e; --orange: #f59e0b; --red: #ef4444;
  --purple: #a855f7; --blue: #38bdf8; --pink: #f472b6;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
}
a { color: var(--accent); }

/* 顶部导航 */
.topnav { display: flex; gap: 6px; padding: 8px 20px; border-bottom: 1px solid var(--border); background: var(--card); flex-wrap: wrap; }
.topnav a { padding: 6px 14px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 13px; transition: all 0.15s; }
.topnav a:hover { color: var(--text); background: var(--card2); }
.topnav a.active { color: #fff; background: var(--accent); }

/* 页头 */
.header { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.header h1 { font-size: 20px; }
.header h1 span { color: var(--accent); }

/* 按钮 */
.btn { padding: 9px 18px; border-radius: 8px; border: none; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.9; }
.btn-ghost { background: var(--card2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--red); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--card2); }

/* 卡片 */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; position: relative; overflow: hidden; }
.card::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 3px; background: var(--c, var(--accent)); }
.card .label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.card .value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* 面板 */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.panel h3 { font-size: 15px; margin-bottom: 14px; font-weight: 600; }

/* 徽章 */
.badge { padding: 2px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge.boss { background: rgba(245,158,11,0.15); color: var(--orange); }
.badge.operator { background: rgba(79,140,255,0.15); color: var(--accent); }
.badge.editor { background: rgba(34,197,94,0.15); color: var(--green); }
.badge.good { background: rgba(34,197,94,0.15); color: var(--green); }
.badge.warn { background: rgba(245,158,11,0.15); color: var(--orange); }
.badge.red { background: rgba(239,68,68,0.15); color: var(--red); }

/* 通用工具类 */
.muted { color: var(--muted); }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-dot.on { background: var(--green); }
.status-dot.off { background: var(--muted); }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; align-items: center; }
.section-title { font-size: 15px; font-weight: 600; color: var(--text); margin: 20px 0 12px; }

/* 输入 */
input, select, textarea {
  background: var(--card2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px; font-size: 14px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="date"] { color-scheme: dark; }

/* toast 提示 */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--card2); border: 1px solid var(--border); padding: 12px 20px; border-radius: 10px; font-size: 14px; display: none; z-index: 1000; }

/* 弹窗遮罩（通用） */
.modal-mask { position: fixed; inset: 0; z-index: 999; background: rgba(0,0,0,0.65); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 24px; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; }

/* ===== 白天主题（切换按钮配合 common.js 的 toggleTheme）===== */
[data-theme="light"] {
  --bg: #f4f6fb; --card: #ffffff; --card2: #eef1f7; --border: #dde2ec;
  --text: #1c2333; --muted: #6b7280; --accent: #2f6bff;
  --green: #16a34a; --orange: #d97706; --red: #dc2626;
  --blue: #0ea5e9; --purple: #8b5cf6; --pink: #ec4899;
}

/* 主题切换按钮（右下角悬浮圆钮，emoji 严格居中） */
.theme-toggle {
  position: fixed; right: 20px; bottom: 20px; z-index: 999;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); cursor: pointer;
  font-size: 20px; box-shadow: 0 2px 10px rgba(0,0,0,0.18);
  transition: transform .15s;
  display: flex; align-items: center; justify-content: center;
  line-height: 1; padding: 0;
}
.theme-toggle:hover { transform: scale(1.08); }

/* 用户徽章（右上角，只显示用户名，点击弹菜单）*/
.user-badge {
  position: fixed; right: 20px; top: 20px; z-index: 999;
  display: flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; padding: 7px 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  font-size: 14px; cursor: pointer;
}
.user-badge:hover { border-color: var(--accent); }
.user-badge .ub-name { color: var(--text); font-weight: 600; }
.user-badge .ub-arrow { color: var(--muted); font-size: 11px; }
.user-badge .ub-unread {
  position: absolute; top: -6px; right: -6px;
  min-width: 18px; height: 18px; border-radius: 9px;
  background: #ef4444; color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px; line-height: 1;
}

/* 用户下拉菜单 */
.user-menu {
  position: fixed; right: 20px; top: 62px; z-index: 1000;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 6px; min-width: 170px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  display: none;
}
.user-menu.open { display: block; }
.um-item {
  padding: 10px 14px; border-radius: 8px; cursor: pointer;
  font-size: 14px; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.um-item:hover { background: var(--card2); }
.um-badge {
  background: #ef4444; color: #fff; border-radius: 9px;
  padding: 0 7px; font-size: 11px; margin-left: auto;
}

/* 消息中心弹窗 */
.notif-mask {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center;
}
.notif-panel {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  width: 480px; max-width: 92vw; max-height: 70vh; display: flex; flex-direction: column;
}
.notif-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.notif-close { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; }
.notif-body { flex: 1; overflow-y: auto; padding: 8px 18px; }
.notif-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.notif-item.unread .notif-title { font-weight: 700; }
.notif-title { font-size: 14px; }
.notif-content { font-size: 12px; color: var(--muted); margin-top: 4px; white-space: pre-wrap; }
.notif-time { font-size: 11px; color: var(--muted); margin-top: 4px; }
.notif-foot { padding: 10px 18px; border-top: 1px solid var(--border); text-align: right; }
.notif-foot button { background: var(--card2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 6px 14px; cursor: pointer; font-size: 13px; }

/* ── AI 悬浮助手（右下角按钮 + 右侧滑出面板）── */
.chat-fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 9990;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none;
  font-size: 26px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  transition: transform .15s;
}
.chat-fab:hover { transform: scale(1.08); }
.chat-panel {
  position: fixed; top: 0; right: -420px; width: 400px; height: 100vh; z-index: 9991;
  background: var(--card); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: right .25s ease;
  box-shadow: -4px 0 24px rgba(0,0,0,0.15);
}
.chat-panel.open { right: 0; }
.chat-panel-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.chat-panel-close { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; }
.chat-panel-body { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.chat-hint { color: var(--muted); font-size: 13px; line-height: 1.8; text-align: center; margin: auto; }
.chat-msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.6; word-break: break-word; }
.chat-msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.ai { align-self: flex-start; background: var(--card2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-panel-input { border-top: 1px solid var(--border); padding: 12px 14px; display: flex; gap: 8px; }
.chat-panel-input input { flex: 1; background: var(--card2); color: var(--text); border: 1px solid var(--border); border-radius: 20px; padding: 10px 16px; font-size: 14px; outline: none; }
.chat-panel-input input:focus { border-color: var(--accent); }
.chat-panel-input button { background: var(--accent); color: #fff; border: none; border-radius: 20px; padding: 0 20px; font-size: 14px; cursor: pointer; }
