/* ========== 客服工作台样式 ========== */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Microsoft YaHei", "PingFang SC", sans-serif; background: #f0f2f5; color: #333; }
button { cursor: pointer; font-family: inherit; }

/* 登录页 */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { background: #fff; padding: 36px 40px; border-radius: 14px; box-shadow: 0 10px 34px rgba(0,0,0,.12); width: 360px; text-align: center; }
.login-box h2 { margin-bottom: 22px; color: #1e5fd6; }
.login-box input { width: 100%; padding: 11px 12px; margin-bottom: 12px; border: 1px solid #dfe3ea; border-radius: 8px; font-size: 14px; outline: none; }
.login-box input:focus { border-color: #2f7df6; }
.login-box button { width: 100%; padding: 12px; background: #2f7df6; color: #fff; border: none; border-radius: 8px; font-size: 15px; }
.login-box button:hover { background: #1e63d8; }
.login-box .demo-btn { margin-top: 10px; background: #fff; color: #2f7df6; border: 1px solid #b9d3ff; font-size: 13px; padding: 9px; }
.login-box .demo-btn:hover { background: #f2f7ff; }
.login-box .tip { margin-top: 14px; color: #aaa; font-size: 12px; }

/* 主框架 */
.app { height: 100vh; display: flex; flex-direction: column; }
.app-header { background: #fff; display: flex; align-items: center; padding: 0 18px; height: 54px; border-bottom: 1px solid #e8ebf0; gap: 18px; }
.app-title { font-size: 17px; font-weight: bold; color: #1e5fd6; }
.app-nav { display: flex; gap: 4px; flex: 1; }
.app-nav .tab { border: none; background: none; padding: 8px 14px; border-radius: 8px; color: #666; font-size: 14px; }
.app-nav .tab.active { background: #e7f0ff; color: #1e5fd6; font-weight: bold; }
.app-nav .tab .cnt { color: #e67e22; font-weight: bold; margin-left: 4px; }
.app-user { display: flex; align-items: center; gap: 10px; }
.app-user select { padding: 5px 8px; border-radius: 6px; border: 1px solid #dfe3ea; }
.app-user button { border: none; background: #f2f4f7; border-radius: 6px; padding: 6px 12px; font-size: 13px; cursor: pointer; color: #4a5058; }
.app-user button:hover { background: #e6eaf0; }
#btn-sound { background: #eef6ff; color: #2f7df6; font-weight: 600; }
#btn-sound.off { background: #f2f4f7; color: #8f959e; }
#btn-settings { border: 1px solid #dfe3ea; background: #fff; border-radius: 6px; padding: 6px 12px; }

/* 主体布局 */
.app-body { flex: 1; display: flex; overflow: hidden; }

/* 左侧会话列表 */
.session-list { width: 300px; background: #fff; border-right: 1px solid #e8ebf0; overflow-y: auto; }
.session-item { padding: 12px 14px; border-bottom: 1px solid #f2f4f8; cursor: pointer; transition: background .12s; position: relative; }
.session-item:hover { background: #f6f9ff; }
.session-item.active { background: #e7f0ff; }
.session-item .si-top { display: flex; justify-content: space-between; align-items: center; }
.session-item .si-name { font-weight: bold; font-size: 14px; }
.session-item .si-time { color: #aaa; font-size: 12px; }
.session-item .si-meta { color: #888; font-size: 12px; margin: 4px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item .si-os { background: #eef3fb; color: #3b6db5; border-radius: 4px; padding: 1px 6px; margin-left: 4px; font-size: 11px; }
.session-item .si-last { color: #999; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item .si-tags { margin-top: 4px; }
.session-item .si-tags .t { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; margin-right: 4px; background: #e7f0ff; color: #1e5fd6; }
.session-item .badge { position: absolute; top: 12px; right: 12px; background: #f5222d; color: #fff; font-size: 11px; min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
.session-item .si-status { font-size: 11px; color: #e67e22; }

/* 右侧聊天 */
.chat-panel { flex: 1; display: flex; flex-direction: column; }
.chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: #bbb; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-head { background: #fff; border-bottom: 1px solid #e8ebf0; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; }
.chat-head-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chat-head-info b { font-size: 15px; }
.chat-head-info .meta { color: #999; font-size: 12px; }
.status-tag { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #e7f0ff; color: #1e5fd6; }
.status-tag.closed { background: #f0f1f3; color: #999; }
.status-tag.pending { background: #fff7e6; color: #e67e22; }
.tag-row .t { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; margin-left: 4px; background: #e7f0ff; color: #1e5fd6; }
.chat-head-actions button { border: 1px solid #dfe3ea; background: #fff; border-radius: 6px; padding: 5px 10px; font-size: 12px; margin-left: 6px; }
.chat-head-actions button:hover { border-color: #2f7df6; color: #2f7df6; }

.chat-body { flex: 1; overflow-y: auto; padding: 16px; background: #f5f7fa; }
.msg { display: flex; margin-bottom: 12px; gap: 8px; }
.msg .bubble { max-width: 62%; padding: 9px 12px; border-radius: 12px; font-size: 14px; line-height: 1.5; word-break: break-word; white-space: pre-wrap; position: relative; }
.msg.from-visitor { flex-direction: row; }
.msg.from-visitor .bubble { background: #fff; border: 1px solid #e6e9f0; border-bottom-left-radius: 4px; }
.msg.from-agent .bubble { background: #2f7df6; color: #fff; border-bottom-right-radius: 4px; }
.msg.from-robot .bubble { background: #eef4ff; border: 1px solid #c9dcff; border-bottom-left-radius: 4px; }
.msg .who { font-size: 11px; color: #aaa; margin-bottom: 3px; }
.msg.recalled .bubble { background: #f0f1f3 !important; color: #999 !important; border: none; font-size: 12px; }
.msg .bubble img { max-width: 260px; border-radius: 8px; display: block; }
.msg .bubble a { color: #2f7df6; }
.msg .recall-btn { display: none; font-size: 11px; color: #666; background: none; border: none; align-self: center; padding: 2px 6px; }
.msg.from-agent:hover .recall-btn { display: block; }
/* 触屏设备无 hover：撤回按钮常显 */
@media (hover: none) {
  .msg.from-agent .recall-btn { display: block; }
}
.msg-time { text-align: center; color: #bbb; font-size: 11px; margin: 8px 0; }

.chat-footer { background: #fff; border-top: 1px solid #e8ebf0; padding: 10px 14px; }
.qr-panel { max-height: 200px; overflow-y: auto; border: 1px solid #e8ebf0; border-radius: 8px; margin-bottom: 8px; padding: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.qr-panel .qr-item { border: 1px solid #dfe3ea; background: #fff; border-radius: 6px; padding: 6px 10px; font-size: 12px; max-width: 100%; }
.qr-panel .qr-item:hover { border-color: #2f7df6; }
.qr-panel .qr-title { color: #999; font-size: 11px; margin: 4px 0; }
.chat-tools { display: flex; gap: 10px; margin-bottom: 8px; }
.chat-tools button, .chat-tools label { background: #f2f4f8; border: none; border-radius: 6px; padding: 6px 10px; font-size: 12px; color: #555; }
.chat-inputrow { display: flex; gap: 8px; }
.chat-inputrow textarea { flex: 1; border: 1px solid #dfe3ea; border-radius: 8px; padding: 9px 12px; font-size: 14px; resize: none; height: 46px; outline: none; }
.chat-inputrow textarea:focus { border-color: #2f7df6; }
.chat-inputrow button { background: #2f7df6; color: #fff; border: none; border-radius: 8px; padding: 0 20px; font-size: 14px; }

/* 弹窗 */
.modal-mask { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.4); z-index: 1000; }
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); background: #fff; border-radius: 12px; width: 620px; max-width: 92vw; max-height: 84vh; display: flex; flex-direction: column; z-index: 1001; box-shadow: 0 16px 48px rgba(0,0,0,.25); }
.modal-head { padding: 14px 18px; border-bottom: 1px solid #eef0f4; display: flex; justify-content: space-between; align-items: center; }
.modal-close { border: none; background: none; font-size: 20px; color: #999; }
.modal-nav { padding: 10px 18px 0; display: flex; gap: 4px; border-bottom: 1px solid #eef0f4; }
.modal-nav button { border: none; background: none; padding: 8px 14px; border-radius: 8px 8px 0 0; color: #666; }
.modal-nav button.active { background: #e7f0ff; color: #1e5fd6; font-weight: bold; }
.modal-body { flex: 1; overflow-y: auto; padding: 16px 18px; }

/* 表单与列表 */
.f-row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; align-items: center; }
.f-row input, .f-row select, .f-row textarea { border: 1px solid #dfe3ea; border-radius: 6px; padding: 8px 10px; font-size: 13px; outline: none; }
.f-row input:focus { border-color: #2f7df6; }
.btn-main { background: #2f7df6; color: #fff; border: none; border-radius: 6px; padding: 8px 16px; }
.btn-line { background: #fff; border: 1px solid #dfe3ea; border-radius: 6px; padding: 8px 14px; }
.item-list .item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f2f4f8; }
.item-list .item .name { flex: 1; font-size: 14px; }
.item-list .item .sub { color: #999; font-size: 12px; }
.item-list .item button { border: none; background: #f2f4f8; border-radius: 6px; padding: 4px 10px; font-size: 12px; }
.item-list .item button.del { color: #f5222d; }
/* 机器人规则列表项：关键词横排胶囊 + 回复独立行 + 右侧操作区 */
.rb-item { align-items: flex-start; gap: 12px; }
.rb-main { flex: 1; min-width: 0; }
.rb-kws { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rb-kw { background: #e7f0ff; color: #1e5fd6; border-radius: 4px; padding: 2px 8px; font-size: 12px; }
.rb-mode { font-size: 11px; color: #999; margin-left: 2px; }
.rb-reply { color: #555; font-size: 13px; margin-top: 6px; line-height: 1.5; word-break: break-word; }
.rb-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex-shrink: 0; }
.rb-badge { font-size: 11px; color: #999; }
.rb-ops { display: flex; gap: 6px; }
.rb-ops button { border: none; background: #f2f4f8; border-radius: 6px; padding: 4px 10px; font-size: 12px; }
.rb-ops button.del { color: #f5222d; }
.check-row { display: flex; gap: 8px; flex-wrap: wrap; }
.check-row .ck { border: 1px solid #dfe3ea; border-radius: 6px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.check-row .ck.on { background: #e7f0ff; border-color: #2f7df6; color: #1e5fd6; }
.loading { color: #999; text-align: center; padding: 40px 0; font-size: 13px; }
.empty-tip { color: #bbb; text-align: center; padding: 30px 0; font-size: 13px; }

/* ===== 手机端适配（窄屏精简布局） ===== */
@media (max-width: 768px) {
  .app-header { padding: 0 10px; gap: 8px; height: 48px; }
  .app-title { display: none; }
  .app-nav .tab { padding: 6px 10px; font-size: 13px; }
  .app-user select, .app-user span { display: none; }
  .app-user button { padding: 5px 8px; font-size: 12px; }
  .session-list { width: 38vw; }
  .chat-head { padding: 8px 10px; }
  .chat-head-actions button { padding: 4px 7px; font-size: 11px; margin-left: 4px; }
  .chat-body { padding: 10px; }
  .msg .bubble { max-width: 80%; font-size: 13px; }
  .modal { width: 94vw; }
}
