/* ============ Reset & Base ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: #f0f2f5; display: flex; flex-direction: column; align-items: center;
  min-height: 100vh; padding: 20px;
}

/* ============ App Layout ============ */
#app {
  display: flex; gap: 24px; align-items: flex-start; justify-content: center;
}

/* ============ Phone Frame (企微) ============ */
.phone-frame {
  width: 375px; height: 720px; background: #ededed; border-radius: 32px;
  overflow: hidden; box-shadow: 0 8px 40px rgba(0,0,0,0.12);
  display: flex; flex-direction: column; position: relative;
  border: 8px solid #1a1a1a;
}

/* ============ Status Bar ============ */
.status-bar {
  background: #f7f7f7; padding: 4px 16px; display: flex; justify-content: space-between;
  font-size: 12px; color: #333; flex-shrink: 0;
}

/* ============ Chat Header (企微原生 · 蓝色) ============ */
.chat-header {
  background: #f7f7f7; border-bottom: 1px solid #d9d9d9;
  padding: 10px 16px; display: flex; align-items: center; gap: 8px;
  flex-shrink: 0; border-left: 3px solid #4a5bc7;
}
.back-arrow { font-size: 22px; color: #333; cursor: pointer; }
.contact-info { flex: 1; }
.contact-name { font-size: 16px; font-weight: 600; color: #1a1a1a; }
.contact-sub { font-size: 11px; color: #888; }
.more-btn { font-size: 20px; color: #333; cursor: pointer; }

/* ============ Chat Area (企微原生 · 蓝色) ============ */
.chat-area {
  flex: 1; overflow-y: auto; padding: 12px 16px;
  background: #ededed; border-left: 3px solid #4a5bc7;
}
.msg-time { text-align: center; font-size: 11px; color: #999; margin: 8px 0; }
.msg { display: flex; margin-bottom: 16px; gap: 8px; }
.msg-customer { flex-direction: row; }
.msg-agent { flex-direction: row-reverse; }
.avatar {
  width: 36px; height: 36px; border-radius: 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
}
.customer-avatar { background: #07c160; }
.agent-avatar { background: #4a5bc7; }
.bubble {
  max-width: 240px; padding: 10px 14px; border-radius: 8px;
  font-size: 14px; line-height: 1.5; position: relative;
}
.bubble-customer { background: #fff; color: #1a1a1a; }
.bubble-agent { background: #95ec69; color: #1a1a1a; text-align: left; }
.sender-label { font-size: 10px; color: #888; margin-bottom: 2px; }
.msg-time-stamp { font-size: 10px; color: #999; margin-top: 4px; text-align: right; }

/* ============ Chat Toolbar (企微原生 · 蓝色) ============ */
.chat-toolbar {
  background: #f7f7f7; border-top: 1px solid #d9d9d9;
  padding: 8px 16px; border-left: 3px solid #4a5bc7; flex-shrink: 0;
}
.toolbar-icons { display: flex; gap: 20px; }
.toolbar-icon {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; transition: opacity 0.15s;
}
.toolbar-icon:hover { opacity: 0.7; }
.toolbar-icon span { font-size: 11px; color: #555; }
.icon-ai {
  width: 36px; height: 36px; border-radius: 8px; background: #6c5ce7;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff;
}
.icon-generic {
  width: 36px; height: 36px; border-radius: 8px; background: #e8e8e8;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

/* ============ Input Bar (企微原生) ============ */
.input-bar {
  background: #f7f7f7; border-top: 1px solid #d9d9d9;
  padding: 8px 12px; display: flex; align-items: center; gap: 8px;
  flex-shrink: 0; padding-bottom: 20px;
}
.input-icon { font-size: 22px; cursor: pointer; }
.input-field {
  flex: 1; height: 36px; background: #fff; border-radius: 6px;
  border: 1px solid #ddd; padding: 0 12px; line-height: 36px;
  font-size: 14px; color: #999;
}

/* ============ Sidebar H5 (自建 · 紫色 · 从右侧滑出) ============ */
.sidebar-overlay {
  position: absolute; top: 0; right: 0; bottom: 0; width: 100%;
  background: rgba(0,0,0,0.3); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.sidebar-overlay.active { opacity: 1; pointer-events: auto; }

.sidebar-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 85%;
  background: #f5f6f8; z-index: 51;
  transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: -6px 0 20px rgba(108, 92, 231, 0.22);
  border-left: 3px solid #6c5ce7; border-radius: 16px 0 0 16px;
}
.sidebar-overlay.active .sidebar-panel { transform: translateX(0); }

/* Slide handle */
.slide-handle {
  background: #ede8ff; padding: 8px; text-align: center;
  cursor: pointer; border-bottom: 1px solid #d8c8ff;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.handle-bar {
  width: 36px; height: 4px; border-radius: 2px; background: #6c5ce7; opacity: 0.4;
}
.handle-label { font-size: 11px; color: #6c5ce7; font-weight: 700; }

/* H5 Header */
.h5-header {
  background: #ede8ff; padding: 12px 16px;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid #d8c8ff;
}
.h5-icon { font-size: 18px; }
.h5-title { font-size: 15px; font-weight: 700; color: #6c5ce7; flex: 1; }
.h5-badge {
  font-size: 12px; padding: 2px 10px; border-radius: 999px;
  background: #6c5ce7; color: #fff;
}

/* H5 Body */
.h5-body { flex: 1; overflow-y: auto; padding: 16px; }

/* Step labels */
.step-label {
  font-size: 12px; font-weight: 700; color: #888;
  margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.05em;
}

/* Customer context card */
.customer-context {
  background: #eef1ff; border: 1px solid #d8deff; border-radius: 8px;
  padding: 10px 12px; margin-bottom: 14px;
}
.ctx-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.ctx-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 600;
}
.ctx-tag.blue { background: rgba(74,91,199,0.15); color: #4a5bc7; }
.ctx-tag.purple { background: rgba(108,92,231,0.15); color: #6c5ce7; }
.ctx-tag.green { background: rgba(7,193,96,0.15); color: #07c160; }
.ctx-info { font-size: 12px; color: #888; }

/* Input area */
.input-area { margin-bottom: 12px; }
.input-area textarea {
  width: 100%; min-height: 80px; border: 1px solid #ddd; border-radius: 8px;
  padding: 10px 12px; font-size: 14px; font-family: inherit; resize: none;
  outline: none; transition: border-color 0.15s;
}
.input-area textarea:focus { border-color: #6c5ce7; }

/* Quick tags */
.quick-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.quick-tag {
  font-size: 12px; padding: 4px 10px; border-radius: 6px;
  background: #fff; border: 1px solid #ddd; color: #666; cursor: pointer;
  transition: all 0.15s;
}
.quick-tag:hover { border-color: #6c5ce7; color: #6c5ce7; }

/* ============ Buttons ============ */
.btn {
  padding: 10px 16px; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: all 0.15s;
}
.btn-primary { background: #6c5ce7; color: #fff; width: 100%; }
.btn-primary:hover { background: #5b4ed4; }
.btn-ghost { background: #f0f0f0; color: #555; }
.btn-ghost:hover { background: #e5e5e5; }
.btn-green { background: #07c160; color: #fff; }
.btn-green:hover { background: #06ad55; }
.btn-warn { background: #fff3e0; color: #e65100; }
.btn-warn:hover { background: #ffe0b2; }

/* ============ Draft Result ============ */
.intent-box {
  background: #eef1ff; border: 1px solid #d8deff; border-radius: 8px;
  padding: 10px 12px; margin-bottom: 14px;
}
.intent-title { font-size: 12px; font-weight: 700; color: #4a5bc7; margin-bottom: 4px; }
.intent-body { font-size: 13px; color: #333; }

.draft-box {
  background: #fff; border: 1px solid #ddd; border-radius: 8px;
  padding: 12px; margin-bottom: 14px;
}
.draft-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid #eee;
}
.draft-header span:first-child { font-size: 14px; font-weight: 700; color: #6c5ce7; }
.draft-time { font-size: 12px; color: #888; }
.draft-editor {
  font-size: 14px; line-height: 1.6; color: #1a1a1a;
  min-height: 80px; outline: none; padding: 8px;
  border-radius: 6px; background: #fafafa; border: 1px solid #eee;
}
.draft-editor:focus { border-color: #6c5ce7; background: #fff; }

/* Checks */
.checks { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.check { display: flex; align-items: center; gap: 4px; font-size: 12px; }
.check.pass { color: #07c160; }
.check-icon { font-weight: 700; }

/* Compliance summary */
.compliance-summary {
  background: #f5f6f8; border: 1px solid #ddd; border-radius: 6px;
  padding: 8px 12px; margin-bottom: 14px; cursor: pointer;
  font-size: 12px; color: #888; display: flex; align-items: center; gap: 4px;
}
.compliance-summary:hover { background: #f0f0f0; }
.expand-hint { margin-left: auto; font-size: 11px; }
.summary-detail {
  margin-top: 8px; padding-top: 8px; border-top: 1px solid #eee;
  font-size: 12px; color: #888; line-height: 1.6;
}

/* Draft actions */
.draft-actions { display: flex; gap: 8px; margin-bottom: 14px; }
.draft-actions .btn { flex: 1; }

/* Compliance notice */
.compliance-notice {
  background: #ede8ff; border: 1px solid #d8c8ff; border-radius: 6px;
  padding: 8px 12px; display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: #6c5ce7;
}
.notice-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #6c5ce7; flex-shrink: 0;
}

/* Loading */
.loading {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 40px 0; color: #888; font-size: 14px;
}
.spinner {
  width: 32px; height: 32px; border: 3px solid #ddd;
  border-top-color: #6c5ce7; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ System Confirm Dialog (企微原生 · 蓝色) ============ */
.sys-confirm-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 100;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.sys-confirm-overlay.active { opacity: 1; pointer-events: auto; }

.sys-confirm-dialog {
  background: #fff; border-radius: 12px; width: 300px; overflow: hidden;
  border-top: 3px solid #4a5bc7;
}
.sys-dialog-title {
  padding: 14px 16px; font-size: 15px; font-weight: 700; color: #1a1a1a;
  text-align: center; border-bottom: 1px solid #eee;
}
.sys-dialog-preview {
  padding: 14px 16px; font-size: 14px; color: #333; line-height: 1.6;
  max-height: 200px; overflow-y: auto;
}
.sys-dialog-warn {
  padding: 8px 16px; font-size: 12px; color: #e65100; text-align: center;
  border-top: 1px solid #f5f5f5;
}
.sys-dialog-btns { display: flex; border-top: 1px solid #eee; }
.sys-dialog-btns .btn { flex: 1; border-radius: 0; padding: 14px; font-size: 15px; }

/* ============ Customer WeChat View (绿色) ============ */
.side-view {
  width: 260px; display: flex; flex-direction: column; gap: 12px;
}
.side-view-title {
  font-size: 13px; font-weight: 700; color: #07c160; text-align: center;
  padding: 8px; background: #e8f8ee; border-radius: 8px;
  border-left: 3px solid #07c160;
}
.wechat-mini {
  background: #ededed; border-radius: 16px; overflow: hidden;
  border: 6px solid #1a1a1a; border-left: 3px solid #07c160;
}
.wechat-header {
  background: #ededed; padding: 10px 12px; display: flex;
  justify-content: space-between; align-items: center;
  border-bottom: 1px solid #d9d9d9; font-size: 14px; font-weight: 600;
}
.wechat-header span:first-child, .wechat-header span:last-child { color: #333; }
.wechat-header span:nth-child(2) { flex: 1; text-align: center; font-size: 13px; }
.wechat-chat { padding: 12px; min-height: 300px; }
.wc-msg { margin-bottom: 12px; }
.wc-customer { display: flex; justify-content: flex-end; }
.wc-bubble {
  max-width: 180px; padding: 8px 12px; border-radius: 8px;
  font-size: 13px; line-height: 1.5;
}
.wc-green { background: #95ec69; color: #1a1a1a; }
.wc-agent { display: flex; justify-content: flex-start; }
.wc-white { background: #fff; color: #1a1a1a; }
.wc-waiting { text-align: center; font-size: 12px; color: #999; padding: 8px; }
.wc-sent { text-align: center; font-size: 11px; color: #07c160; padding: 4px; }

/* ============ Info Bar ============ */
.info-bar {
  margin-top: 20px; display: flex; gap: 24px; flex-wrap: wrap;
  background: #fff; border-radius: 8px; padding: 12px 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.info-item { font-size: 13px; }
.info-label { color: #888; }
.info-value { color: #333; font-weight: 600; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
.dot.blue { background: #4a5bc7; }
.dot.purple { background: #6c5ce7; }
.dot.green { background: #07c160; }

/* ============ Responsive ============ */
@media (max-width: 700px) {
  #app { flex-direction: column; }
  .side-view { width: 375px; }
}
