/*
 * 橙智合官网 AI 客服 · 前端样式（任务包14 阶段B）
 * 所有类名以 .ozcs 为前缀，避免与官网主题样式冲突。
 * 桌面：右下角悬浮面板；移动：底部全宽抽屉。
 */

:root {
  --ozcs-accent: #b74c17;        /* 橙智合主色（对齐官网主题） */
  --ozcs-accent-pale: #fff1e8;
  --ozcs-ink: #24332f;
  --ozcs-muted: #65716d;
  --ozcs-line: #dfe5e2;
  --ozcs-paper: #ffffff;
  --ozcs-canvas: #f4f6f5;
  --ozcs-green: #24715b;
  --ozcs-danger: #a23b32;
  --ozcs-body: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --ozcs-radius: 14px;
}

/* ---------- 根容器：隔离官网样式 ---------- */
.ozcs-root,
.ozcs-panel {
  font-family: var(--ozcs-body);
  color: var(--ozcs-ink);
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
.ozcs-root * {
  box-sizing: border-box;
}

/* ---------- 启动按钮（悬浮） ---------- */
.ozcs-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99999;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: var(--ozcs-accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  display: grid;
  place-items: center;
  transition: transform 0.15s ease, background 0.15s ease;
}
.ozcs-launcher:hover {
  background: #953b10;
  transform: translateY(-2px);
}
.ozcs-launcher.active {
  transform: rotate(45deg);
}
.ozcs-launcher-icon {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1px;
  line-height: 1;
}
.ozcs-launcher.active .ozcs-launcher-icon {
  transform: rotate(-45deg);
}

/* ---------- 面板 ---------- */
.ozcs-panel {
  position: fixed;
  right: 20px;
  bottom: 92px;
  z-index: 100000;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: min(600px, calc(100vh - 120px));
  min-height: 360px;
  background: var(--ozcs-paper);
  border: 1px solid var(--ozcs-line);
  border-radius: var(--ozcs-radius);
  box-shadow: 0 24px 80px rgba(22, 44, 56, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ozcs-panel[hidden] {
  display: none;
}

/* ---------- 头部 ---------- */
.ozcs-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--ozcs-accent-pale);
  border-bottom: 1px solid var(--ozcs-line);
}
.ozcs-avatar {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--ozcs-accent);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
}
.ozcs-hinfo {
  flex: 1 1 auto;
  min-width: 0;
}
.ozcs-htitle {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ozcs-badges {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
/* “AI 助手”常显标识 */
.ozcs-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.ozcs-badge-ai {
  background: var(--ozcs-ink);
  color: #fff;
}
.ozcs-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.ozcs-dot-on {
  background: var(--ozcs-green);
}
.ozcs-dot-off {
  background: #b68439;
}
.ozcs-dot-label {
  font-size: 11px;
  color: var(--ozcs-muted);
}
.ozcs-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
  color: var(--ozcs-muted);
  font-size: 20px;
  line-height: 1;
}
.ozcs-close:hover {
  background: rgba(0, 0, 0, 0.06);
}
.ozcs-close-x {
  font-weight: 400;
}

/* ---------- 常显提示条 ---------- */
.ozcs-state-badge {
  flex: 0 0 auto;
  padding: 7px 16px 0;
  font-size: 12px;
  color: var(--ozcs-green);
  background: var(--ozcs-canvas);
}
.ozcs-disclaimer {
  flex: 0 0 auto;
  padding: 6px 16px 10px;
  font-size: 11px;
  color: var(--ozcs-muted);
  border-bottom: 1px solid var(--ozcs-line);
  background: var(--ozcs-canvas);
}

/* ---------- 消息区 ---------- */
.ozcs-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}
.ozcs-msg {
  max-width: 88%;
  width: 100%;
  align-self: flex-start;
}
.ozcs-msg.ozcs-customer {
  align-self: flex-end;
}
.ozcs-meta {
  font-size: 10px;
  color: var(--ozcs-muted);
  margin-bottom: 4px;
}
.ozcs-msg.ozcs-customer .ozcs-meta {
  text-align: right;
}
.ozcs-body {
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;   /* 保留换行，模型文本按纯文本渲染 */
  word-break: break-word;
  background: #f1f4f2;
  color: var(--ozcs-ink);
}
.ozcs-msg.ozcs-customer .ozcs-body {
  background: #e6f0e9;
  border-radius: 12px 0 12px 12px;
}
.ozcs-msg.ozcs-welcome .ozcs-body {
  background: #fff;
  border: 1px solid var(--ozcs-line);
}

/* 引用来源（服务端构造的标题/URL；文本用 textContent） */
.ozcs-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}
.ozcs-source {
  font-size: 11px;
  color: var(--ozcs-green);
  padding: 3px 8px;
  border: 1px solid var(--ozcs-line);
  border-radius: 6px;
  text-decoration: none;
  background: #fff;
}
.ozcs-source:hover {
  background: #f0f5f1;
}
.ozcs-source-text {
  color: var(--ozcs-muted);
  background: var(--ozcs-canvas);
  cursor: default;
}

/* ---------- 状态行 ---------- */
.ozcs-status {
  flex: 0 0 auto;
  min-height: 20px;
  padding: 0 16px;
  font-size: 12px;
  color: var(--ozcs-green);
}
.ozcs-status-err {
  color: var(--ozcs-danger);
}
.ozcs-status-busy {
  color: var(--ozcs-muted);
}

/* ---------- 联系/留言兜底 ---------- */
.ozcs-contact {
  flex: 0 0 auto;
  margin: 6px 16px 0;
  padding: 10px 12px;
  background: var(--ozcs-accent-pale);
  border: 1px solid #f0d9c4;
  border-radius: 10px;
  font-size: 12px;
  color: #78522e;
}
.ozcs-contact[hidden] {
  display: none;
}
.ozcs-contact-title {
  font-weight: 600;
  margin-bottom: 8px;
}
.ozcs-contact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.ozcs-contact-link {
  color: var(--ozcs-accent);
  text-decoration: underline;
}

/* ---------- 输入区 ---------- */
.ozcs-composer {
  flex: 0 0 auto;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--ozcs-line);
  background: #fff;
}
.ozcs-text {
  width: 100%;
  border: 1px solid var(--ozcs-line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  min-height: 58px;
  max-height: 140px;
  background: var(--ozcs-canvas);
  color: var(--ozcs-ink);
}
.ozcs-text:focus {
  outline: 2px solid var(--ozcs-accent);
  outline-offset: 1px;
}
.ozcs-composer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.ozcs-count {
  font-size: 11px;
  color: var(--ozcs-muted);
  flex: 1 1 auto;
}
.ozcs-count-over {
  color: var(--ozcs-danger);
  font-weight: 600;
}
.ozcs-btn {
  border: 1px solid var(--ozcs-line);
  background: #fff;
  color: var(--ozcs-ink);
  border-radius: 8px;
  padding: 8px 12px;
  min-height: 38px;
  font-size: 12px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}
.ozcs-btn:hover {
  background: #eaf0ec;
}
.ozcs-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.ozcs-btn.ozcs-handoff {
  color: var(--ozcs-accent);
}
.ozcs-btn.ozcs-primary {
  background: var(--ozcs-accent);
  border-color: var(--ozcs-accent);
  color: #fff;
}
.ozcs-btn.ozcs-primary:hover {
  background: #953b10;
}

/* ---------- 移动端：底部全宽抽屉 ---------- */
@media (max-width: 600px) {
  .ozcs-launcher {
    right: 14px;
    bottom: 14px;
    width: 54px;
    height: 54px;
  }
  .ozcs-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 88vh;
    min-height: 320px;
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
  .ozcs-messages {
    padding: 14px 12px;
  }
  .ozcs-msg {
    max-width: 92%;
  }
}

/* 降低动效偏好 */
@media (prefers-reduced-motion: reduce) {
  .ozcs-launcher,
  .ozcs-panel,
  .ozcs-btn {
    transition: none !important;
  }
}
