/* frontend/static/style.css - 智能客服单页样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #4f6ef7;
  --primary-dark: #3b55d9;
  --bg: #eef1f8;
  --bubble-bot: #ffffff;
  --bubble-user: linear-gradient(135deg, #4f6ef7, #6a8bff);
  --text: #2b2f36;
  --text-sub: #8a919f;
  --radius: 14px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
}

#app, .chat-app {
  height: 100%;
  display: flex;
  justify-content: center;
}

.chat-app {
  width: 100%;
  max-width: 760px;
  flex-direction: column;
  background: #f7f8fc;
  box-shadow: 0 0 40px rgba(80, 100, 180, .12);
}

/* ===== 顶部导航 ===== */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, #4f6ef7, #7a5cff);
  color: #fff;
  flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.bot-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255, 255, 255, .2);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.header-info { display: flex; flex-direction: column; }
.bot-name { font-size: 16px; font-weight: 600; }
.status { font-size: 12px; display: flex; align-items: center; gap: 4px; opacity: .92; }
.status i {
  width: 8px; height: 8px; border-radius: 50%;
  background: #52e29a; display: inline-block;
  box-shadow: 0 0 6px #52e29a;
}
.status.offline i { background: #ffd76a; box-shadow: 0 0 6px #ffd76a; }
.header-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px; border: none; border-radius: 10px;
  background: rgba(255, 255, 255, .16); color: #fff; font-size: 16px;
  cursor: pointer; transition: background .2s;
}
.icon-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .3); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ===== 情感指示器 ===== */
.emotion-indicator {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 16px; font-size: 12px; flex-shrink: 0;
  background: #eceffd; border-bottom: 1px solid #dfe4fa;
}
.emotion-indicator .emoji { font-size: 16px; }
.emotion-indicator .score { color: var(--text-sub); }
.emotion-indicator.negative { background: #fdeeee; border-color: #f7d9d9; }
.emotion-indicator.positive { background: #e9f9ef; border-color: #d3f0de; }

/* ===== 消息区 ===== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  scroll-behavior: smooth;
}

.welcome { text-align: center; padding: 36px 16px 16px; }
.welcome-icon { font-size: 52px; margin-bottom: 10px; }
.welcome h2 { font-size: 20px; margin-bottom: 8px; }
.welcome p { font-size: 13px; color: var(--text-sub); margin-bottom: 20px; }
.quick-services { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.quick-services button {
  padding: 9px 16px; border: 1px solid #d6dcf5; border-radius: 18px;
  background: #fff; color: var(--primary); font-size: 13px; cursor: pointer;
  transition: all .2s;
}
.quick-services button:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

.message-bubble { display: flex; margin-bottom: 16px; gap: 8px; }
.message-bubble.is-user { flex-direction: row; }
.avatar span { font-size: 26px; }
.bubble-wrapper { max-width: 78%; display: flex; flex-direction: column; }
.is-user .bubble-wrapper { align-items: flex-end; }
.msg-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; font-size: 11px; }
.intent-tag {
  background: #eceffd; color: var(--primary); padding: 2px 8px; border-radius: 8px;
}
.intent-tag em { font-style: normal; opacity: .7; }
.sentiment-tag { padding: 2px 8px; border-radius: 8px; }
.sentiment-tag.positive { background: #e9f9ef; color: #1a9e56; }
.sentiment-tag.neutral { background: #f0f1f5; color: #6b7280; }
.sentiment-tag.negative { background: #fdeeee; color: #d94848; }
.tool-tag { background: #fff4e5; color: #c07a1a; padding: 2px 8px; border-radius: 8px; }

.bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
  white-space: normal;
}
.bubble-bot { background: var(--bubble-bot); border-top-left-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.bubble-user { background: var(--bubble-user); color: #fff; border-top-right-radius: 4px; }
.message-time { font-size: 11px; color: var(--text-sub); margin-top: 4px; }

/* 打字动画 */
.typing { display: flex; gap: 5px; padding: 4px 2px; }
.typing span {
  width: 8px; height: 8px; border-radius: 50%;
  background: #b9c2f7; animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ===== 快捷回复 ===== */
.quick-reply {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 8px 16px; flex-shrink: 0;
  background: #f2f4fb; border-top: 1px solid #e6e9f5;
}
.qr-title { font-size: 12px; color: var(--text-sub); }
.quick-reply button {
  padding: 5px 12px; border: 1px solid #d6dcf5; border-radius: 14px;
  background: #fff; color: var(--primary); font-size: 12px; cursor: pointer;
}
.quick-reply button:hover { background: #eceffd; }

/* ===== 输入框 ===== */
.input-box {
  display: flex; gap: 10px; padding: 12px 16px;
  background: #fff; border-top: 1px solid #e6e9f5; flex-shrink: 0;
}
.input-box input {
  flex: 1; padding: 11px 14px; border: 1px solid #dde2f0; border-radius: 12px;
  font-size: 14px; outline: none; transition: border .2s;
}
.input-box input:focus { border-color: var(--primary); }
.send-btn {
  padding: 0 22px; border: none; border-radius: 12px;
  background: var(--primary); color: #fff; font-size: 14px; cursor: pointer;
  transition: background .2s;
}
.send-btn:hover:not(:disabled) { background: var(--primary-dark); }
.send-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ===== 弹窗 ===== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 24, 40, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  width: 90%; max-width: 420px; background: #fff; border-radius: 16px;
  padding: 22px; animation: pop .2s ease;
}
.modal.dashboard { max-width: 480px; max-height: 85vh; overflow-y: auto; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h3 { font-size: 17px; margin-bottom: 16px; }
.modal h4 { font-size: 14px; margin: 16px 0 8px; color: var(--text-sub); }
.stars { display: flex; justify-content: center; gap: 8px; font-size: 34px; margin: 8px 0 16px; }
.star { color: #dfe3ee; cursor: pointer; transition: color .15s, transform .15s; }
.star.active { color: #ffb02e; }
.star:hover { transform: scale(1.15); }
.modal textarea {
  width: 100%; padding: 10px; border: 1px solid #dde2f0; border-radius: 10px;
  font-size: 13px; resize: vertical; outline: none;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.btn { padding: 9px 20px; border-radius: 10px; border: none; font-size: 14px; cursor: pointer; }
.btn.ghost { background: #f0f1f5; color: #555; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }

/* 数据看板 */
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.metric {
  background: #f6f7fd; border-radius: 12px; padding: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.metric b { font-size: 20px; color: var(--primary); }
.metric span { font-size: 12px; color: var(--text-sub); }
.dist-list { display: flex; flex-direction: column; gap: 8px; }
.dist-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.dist-name { width: 76px; text-align: right; color: #555; flex-shrink: 0; }
.dist-bar { flex: 1; height: 10px; background: #eef0f8; border-radius: 5px; overflow: hidden; }
.dist-bar i { display: block; height: 100%; background: linear-gradient(90deg, #4f6ef7, #7a5cff); border-radius: 5px; }
.dist-val { width: 44px; color: var(--text-sub); }
.dash-empty, .dash-loading { font-size: 13px; color: var(--text-sub); padding: 8px 0; }
.sentiment-dist { display: flex; gap: 10px; flex-wrap: wrap; }
.s-tag { padding: 5px 12px; border-radius: 14px; font-size: 12px; }
.s-tag.positive { background: #e9f9ef; color: #1a9e56; }
.s-tag.neutral { background: #f0f1f5; color: #6b7280; }
.s-tag.negative { background: #fdeeee; color: #d94848; }

/* 移动端适配 */
@media (max-width: 520px) {
  .bubble-wrapper { max-width: 86%; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}

/* 滚动条 */
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: #d5d9ea; border-radius: 3px; }
