/* ==========================================================
   ZOONN 之城 - 留言对话窗口样式
   ========================================================== */

.chat-widget {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 900;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

/* ===== 右下角圆形入口 ===== */
.chat-launcher {
  position: relative;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: #4a90d9;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(46, 106, 184, 0.45);
  transition: transform 0.2s ease, background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-launcher:hover {
  background: #2e6ab8;
  transform: translateY(-2px) scale(1.04);
}

.chat-launcher-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.chat-widget.is-open .chat-launcher {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.7);
}

.chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #e74c3c;
  color: #fff;
  font-size: 0.7rem;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* ===== 面板 ===== */
.chat-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 340px;
  max-width: calc(100vw - 32px);
  height: 480px;
  max-height: calc(100vh - 44px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.chat-widget.is-open .chat-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ===== 头部 ===== */
.chat-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 12px 12px 16px;
  background: linear-gradient(135deg, #4a90d9 0%, #2e6ab8 100%);
  color: #fff;
  flex-shrink: 0;
}

.chat-head-text {
  flex: 1;
  min-width: 0;
}

.chat-head-title {
  font-size: 0.95rem;
  font-weight: bold;
  line-height: 1.3;
}

.chat-head-status {
  font-size: 0.7rem;
  opacity: 0.85;
  margin-top: 2px;
}

.chat-head-status.is-warn { color: #ffe08a; }
.chat-head-status.is-ok { color: #c8f0d8; }

.chat-head-btn {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.chat-head-btn:hover {
  background: rgba(255, 255, 255, 0.32);
}

/* ===== 开场填写昵称 ===== */
.chat-intro {
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-intro p {
  font-size: 0.85rem;
  color: #6b7a8c;
  line-height: 1.7;
}

.chat-name-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cce0f5;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.chat-name-input:focus {
  outline: none;
  border-color: #4a90d9;
  box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.1);
}

.chat-begin {
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: #4a90d9;
  color: #fff;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease;
}

.chat-begin:hover { background: #2e6ab8; }

/* ===== 消息区 ===== */
.chat-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* hidden 属性会被上面的 display:flex 盖掉，必须显式压回 */
.chat-body[hidden],
.chat-intro[hidden] {
  display: none !important;
}

.chat-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f7fafd;
}

.chat-empty {
  margin: auto;
  color: #9dabb9;
  font-size: 0.82rem;
  text-align: center;
  line-height: 1.8;
  padding: 0 20px;
}

.chat-row {
  display: flex;
  flex-direction: column;
  max-width: 86%;
}

.chat-row.is-visitor {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-row.is-host {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-bubble {
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 0.86rem;
  line-height: 1.65;
  text-align: left;
}

.is-visitor .chat-bubble {
  background: #4a90d9;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.is-host .chat-bubble {
  background: #fff;
  color: #33414f;
  border: 1px solid #e2ecf6;
  border-bottom-left-radius: 4px;
}

.chat-meta {
  font-size: 0.66rem;
  color: #a6b3c0;
  margin-top: 4px;
  padding: 0 4px;
}

/* ===== 输入区 ===== */
.chat-compose {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #e8f0f8;
  background: #fff;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  min-height: 38px;
  max-height: 96px;
  padding: 9px 12px;
  border: 1px solid #cce0f5;
  border-radius: 10px;
  font-size: 0.86rem;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  overflow-y: auto;
  transition: border-color 0.2s ease;
}

.chat-input:focus {
  outline: none;
  border-color: #4a90d9;
  box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.1);
}

.chat-send {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: #4a90d9;
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease;
}

.chat-send:hover { background: #2e6ab8; }

.chat-foot {
  min-height: 0;
  font-size: 0.68rem;
  color: #9dabb9;
  text-align: center;
  padding: 0 12px 8px;
  background: #fff;
}

/* ===== 手机端：铺满下方 ===== */
@media (max-width: 600px) {
  .chat-widget {
    right: 14px;
    bottom: 14px;
  }

  .chat-panel {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 78vh;
    max-height: 78vh;
    border-radius: 16px 16px 0 0;
  }
}
