* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: "Microsoft YaHei", -apple-system, "PingFang SC", Arial, sans-serif; background: #eef1f6; color: #333; }
button { cursor: pointer; font-family: inherit; }

/* ---------- 访客布局 ---------- */
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.side { width: 300px; background: #2a5298; color: #fff; display: flex; flex-direction: column; padding: 20px; }
.side-head { display: flex; align-items: center; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,.2); }
.logo { font-size: 30px; }
.site-name { font-size: 17px; font-weight: 700; }
.status { margin-left: auto; font-size: 12px; background: rgba(255,255,255,.15); padding: 3px 8px; border-radius: 12px; }
.status .dot { display: inline-block; width: 7px; height: 7px; background: #4caf50; border-radius: 50%; margin-right: 3px; }
.ai-tip { margin-top: 18px; background: rgba(255,255,255,.1); border-radius: 10px; padding: 14px; display: flex; gap: 12px; font-size: 13px; line-height: 1.6; }
.ai-avatar { width: 38px; height: 38px; min-width: 38px; border-radius: 50%; background: linear-gradient(135deg,#00b4db,#0083b0); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.side-foot { margin-top: auto; font-size: 12px; opacity: .7; }

.chat { flex: 1; display: flex; flex-direction: column; background: #f7f9fc; min-height: 0; overflow: hidden; }
.chat-head { background: #fff; padding: 14px 20px; display: flex; align-items: center; border-bottom: 1px solid #e6ebf2; }
.chat-title { font-size: 16px; font-weight: 700; }
.chat-sub { font-size: 12px; color: #999; margin-top: 2px; }
.chat-actions { margin-left: auto; }
.icon-btn { border: 1px solid #d5dbe6; background: #fff; border-radius: 8px; padding: 5px 9px; font-size: 15px; }

.msg-list { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.msg-row { display: flex; gap: 10px; max-width: 78%; }
.msg-row.right { align-self: flex-end; flex-direction: row-reverse; }
.avatar { width: 36px; height: 36px; min-width: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; }
.avatar.v { background: #ff9800; }
.avatar.a { background: linear-gradient(135deg,#00b4db,#0083b0); }
.bubble { background: #fff; padding: 10px 13px; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06); font-size: 14px; line-height: 1.6; word-break: break-word; white-space: pre-wrap; }
.msg-row.right .bubble { background: #e3f2fd; }
.bubble img.msg-img { max-width: 260px; max-height: 220px; border-radius: 8px; display: block; cursor: pointer; }
.bubble .emoji { font-size: 26px; }
.msg-meta { font-size: 11px; color: #aaa; margin-top: 4px; text-align: right; }
.name-tag { font-size: 11px; color: #999; margin-bottom: 3px; }
.typing { font-size: 12px; color: #999; padding: 4px 10px; }

/* 工单投诉按钮 */
.complaint-btn { display: inline-block; margin-top: 10px; padding: 10px 20px; background: #e53935; color: #fff; border-radius: 8px; text-decoration: none; font-size: 14px; font-weight: 600; text-align: center; box-shadow: 0 2px 8px rgba(229,57,53,.25); }
.complaint-btn:hover { background: #c62828; }

.toolbar { position: relative; background: #fff; border-top: 1px solid #e6ebf2; padding: 8px 14px; display: flex; align-items: center; gap: 8px; }
.tbtn { border: none; background: #f4f6fb; border-radius: 8px; font-size: 14px; cursor: pointer; display: flex; align-items: center; gap: 4px; padding: 5px 10px; }
.tbtn:hover { background: #e8edf7; }
.tbtn .t-icon { font-size: 18px; }
.tbtn .t-label { font-size: 12px; color: #555; }
.tool-hint { font-size: 12px; color: #b0b6c0; margin-left: 6px; }

/* 消息发送状态 */
.send-state { font-size: 11px; color: #999; margin-top: 6px; }
.send-state.fail { color: #e53935; cursor: pointer; text-decoration: underline; }

/* 图片上传进度 */
.upload-state { margin-top: 6px; }
.upload-state .up-text { font-size: 12px; color: #888; margin-bottom: 4px; }
.progress { height: 6px; background: #e8edf3; border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg,#2a5298,#4f9fff); border-radius: 4px; transition: width .2s; }

/* AI 输入中提示 */
.typing { font-size: 12px; color: #999; padding: 8px 20px; align-items: center; gap: 6px; }
.typing-dots { width: 8px; height: 8px; border-radius: 50%; background: #4f9fff; animation: blink 1s infinite; display: inline-block; }
.typing-dots::after { content: ""; }
@keyframes blink { 0%,100% { opacity: .3; } 50% { opacity: 1; } }

/* 拖拽上传高亮 */
.msg-list.dragging { outline: 2px dashed #4f9fff; outline-offset: -6px; background: rgba(79,159,255,.05); }

/* ---------- 后台布局 ---------- */
.adm { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.adm-side { width: 230px; background: #1f2d3d; color: #c8d0da; display: flex; flex-direction: column; }
.adm-logo { padding: 18px; font-size: 16px; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.adm-menu { flex: 1; padding: 10px 0; }
.adm-menu a { display: block; padding: 12px 20px; color: #c8d0da; text-decoration: none; font-size: 14px; }
.adm-menu a:hover, .adm-menu a.active { background: rgba(255,255,255,.06); color: #fff; border-left: 3px solid #4f9fff; }
.adm-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.adm-overlay { display: none; }
.adm-mobilebar { display: none; align-items: center; gap: 10px; background: #2a5298; color: #fff; padding: 10px 14px; }
.menu-toggle { background: transparent; border: none; color: #fff; font-size: 20px; padding: 2px 6px; cursor: pointer; }
.adm-mobilebar-title { font-size: 15px; font-weight: 600; }

.view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.view.active { display: flex; }
.vhead { padding: 16px 22px; background: #fff; border-bottom: 1px solid #e6ebf2; display: flex; align-items: center; gap: 12px; }
.vhead h2 { font-size: 17px; }
.vbody { flex: 1; overflow-y: auto; padding: 20px 22px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card { background: #fff; border-radius: 10px; padding: 18px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.card .num { font-size: 26px; font-weight: 700; color: #2a5298; }
.card .lbl { font-size: 13px; color: #888; margin-top: 4px; }

table.tbl { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; }
table.tbl th, table.tbl td { padding: 11px 14px; text-align: left; border-bottom: 1px solid #eef1f6; font-size: 13px; }
table.tbl th { background: #f7f9fc; font-weight: 600; }
table.tbl tr:hover td { background: #fafbfd; }

.btn { padding: 8px 16px; background: #2a5298; color: #fff; border: none; border-radius: 8px; font-size: 14px; }
.btn:hover { background: #1e3c72; }
.btn.green { background: #1e7e34; }
.btn.red { background: #c62828; }
.btn.ghost { background: #fff; color: #555; border: 1px solid #d5dbe6; }
.btn.sm { padding: 4px 10px; font-size: 12px; }

.f-label { font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
.f-input, .f-textarea, .f-select { width: 100%; padding: 9px 12px; border: 1px solid #d5dbe6; border-radius: 8px; font-size: 14px; font-family: inherit; }
.f-textarea { min-height: 120px; resize: vertical; }
.f-input:focus, .f-textarea:focus { outline: none; border-color: #2a5298; }
.form-card { background: #fff; border-radius: 10px; padding: 20px 24px; box-shadow: 0 1px 4px rgba(0,0,0,.06); max-width: 860px; }
.form-row { display: flex; gap: 16px; }
.form-row .f-group { flex: 1; }
.f-group { margin-bottom: 4px; }
.hint { font-size: 12px; color: #999; margin-top: 4px; }

.login-wrap { height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#1e3c72,#2a5298); }
.login-box { width: 360px; background: #fff; border-radius: 12px; padding: 34px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-box h1 { font-size: 20px; margin-bottom: 6px; }
.login-box p { color: #888; font-size: 13px; margin-bottom: 22px; }

.sess-wrap { display: flex; flex: 1; overflow: hidden; min-height: 0; }
.visitor-list { width: 300px; border-right: 1px solid #e6ebf2; background: #fff; overflow-y: auto; }
.visitor-item { padding: 12px 16px; border-bottom: 1px solid #f0f2f6; cursor: pointer; }
.visitor-item:hover, .visitor-item.active { background: #f0f4ff; }
.visitor-item .vname { font-size: 14px; font-weight: 600; }
.visitor-item .vsub { font-size: 12px; color: #999; margin-top: 3px; }
.unread-badge { display: inline-block; background: #e53935; color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 10px; margin-left: 6px; }
.conv { flex: 1; display: flex; flex-direction: column; background: #f7f9fc; min-height: 0; overflow: hidden; }
.conv-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: #bbb; font-size: 15px; }
.filter-bar { padding: 10px 16px; border-bottom: 1px solid #e6ebf2; background: #fafbfd; display: flex; gap: 8px; }

.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.tag.online { background: #e8f5e9; color: #1e7e34; }
.tag.offline { background: #eceff1; color: #777; }

.toast { position: fixed; top: 20px; right: 20px; background: #333; color: #fff; padding: 12px 18px; border-radius: 8px; z-index: 999; opacity: 0; transition: opacity .3s; }
.toast.show { opacity: 1; }

@media (max-width: 860px) {
  .side { display: none; }
  .app { flex-direction: column; }
  .visitor-list { width: 120px; }
  /* 移动端：确保聊天输入区不被消息顶出屏幕 */
  .app, .adm { height: 100vh; height: 100dvh; }
  .chat, .conv, .sess-wrap, .msg-list { min-height: 0; }
  .conv, .chat { overflow: hidden; }

  /* 后台移动端：侧边菜单改为可滑出的抽屉 */
  .adm-mobilebar { display: flex; }
  .adm-side {
    position: fixed; top: 0; left: -250px; bottom: 0; z-index: 110;
    width: 230px; transition: left .25s ease; box-shadow: 2px 0 12px rgba(0,0,0,.3);
  }
  .adm-menu-open .adm-side { left: 0; }
  .adm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 105; }
  .adm-main { min-height: 0; }
}

.emoji-panel { position: absolute; bottom: 46px; left: 14px; width: 300px; max-height: 220px; overflow-y: auto; background: #fff; border: 1px solid #e6ebf2; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 10px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; z-index: 50; }
.emoji-panel span { font-size: 22px; text-align: center; padding: 4px; border-radius: 6px; cursor: pointer; }
.emoji-panel span:hover { background: #f0f4ff; }

.input-area { display: flex; gap: 10px; background: #fff; padding: 12px 14px; border-top: 1px solid #e6ebf2; }
.input-area textarea { flex: 1; resize: none; border: 1px solid #d5dbe6; border-radius: 10px; padding: 10px 12px; font-size: 14px; font-family: inherit; outline: none; }
.input-area textarea:focus { border-color: #2a5298; }
.send-btn { padding: 0 22px; background: #2a5298; color: #fff; border: none; border-radius: 10px; font-size: 15px; }
