* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #eef2f7;
  color: #172033;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.chat-page {
  height: 100vh;
  display: grid;
  grid-template-columns: 360px 1fr;
}

.chat-sidebar {
  background: #ffffff;
  border-right: 1px solid #e5eaf3;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-head {
  padding: 20px;
  border-bottom: 1px solid #eef2f7;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-head h1 {
  margin: 0;
  font-size: 20px;
}

.sidebar-head p {
  margin: 6px 0 0;
  color: #667085;
  font-size: 13px;
}

button,
.head-actions a {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: #0f766e;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
}

button:hover,
.head-actions a:hover {
  opacity: 0.92;
}

.conversation-list {
  padding: 12px;
  overflow: auto;
}

.conversation-item {
  padding: 14px;
  border: 1px solid #edf1f7;
  background: #fbfcff;
  border-radius: 14px;
  margin-bottom: 10px;
  cursor: pointer;
}

.conversation-item:hover {
  background: #f3fbf9;
}

.conversation-item.active {
  border-color: #0f766e;
  background: #ecfdf5;
}

.conv-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.conv-name {
  font-weight: 800;
  font-size: 14px;
}

.conv-phone {
  color: #667085;
  font-size: 12px;
  margin-top: 4px;
}

.conv-last {
  margin-top: 8px;
  color: #475467;
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.badge {
  padding: 3px 8px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 11px;
  white-space: nowrap;
}

.chat-main {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  height: 100vh;
}

.chat-main-head {
  padding: 20px 24px;
  border-bottom: 1px solid #e5eaf3;
  background: #fff;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.chat-main-head h2 {
  margin: 0;
  font-size: 20px;
}

.chat-main-head p {
  margin: 6px 0 0;
  color: #667085;
  font-size: 13px;
}

.head-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.message-list {
  padding: 24px;
  overflow: auto;
  background: linear-gradient(180deg, #f8fafc, #eef2f7);
}

.message-row {
  display: flex;
  margin-bottom: 14px;
}

.message-row.inbound {
  justify-content: flex-start;
}

.message-row.outbound {
  justify-content: flex-end;
}

.bubble {
  max-width: 68%;
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.inbound .bubble {
  background: #ffffff;
  border: 1px solid #e6eaf2;
}

.outbound .bubble {
  background: #0f766e;
  color: #ffffff;
}

.msg-text {
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 14px;
}

.msg-time {
  margin-top: 8px;
  font-size: 11px;
  opacity: 0.72;
}

.reply-box {
  background: #ffffff;
  border-top: 1px solid #e5eaf3;
  padding: 16px 24px;
}

.reply-box textarea {
  width: 100%;
  min-height: 86px;
  border: 1px solid #d9e0ec;
  border-radius: 14px;
  padding: 12px 14px;
  resize: vertical;
  outline: none;
  font-size: 14px;
}

.reply-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

#aiDraftBtn {
  background: #334155;
}

#replyResult {
  margin: 10px 0 0;
  background: #0f172a;
  color: #d1fae5;
  border-radius: 12px;
  padding: 10px;
  min-height: 0;
  max-height: 140px;
  overflow: auto;
  display: none;
}

.empty {
  color: #98a2b3;
  padding: 24px;
  text-align: center;
  border: 1px dashed #d7deea;
  border-radius: 14px;
  background: rgba(255,255,255,0.6);
}

@media (max-width: 900px) {
  .chat-page {
    grid-template-columns: 1fr;
  }

  .chat-sidebar {
    height: 42vh;
  }

  .chat-main {
    height: 58vh;
  }
}
