/* ============================================================
 * 智能客服对话弹窗样式 smartkefu.css（新官网版）
 * 配色已适配新官网设计系统（主色 #0F4C81 / 点缀 #4ECDC4）
 * 全部使用 sk- 前缀，与 site.css 共存无冲突
 * ============================================================ */

/* 基础 reset 使用 :where()（零优先级），仅用于压住站点全局
   * { margin:0; padding:0 }（本文件后加载，同优先级靠后生效），
   不会覆盖下方各组件类名设置的 margin/padding/line-height。
   注意：不要写成 #sk-dialog * —— ID 优先级会反过来清零组件自身的间距。 */
:where(#sk-dialog),
:where(#sk-dialog) * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}

#sk-dialog button,
#sk-dialog input,
#sk-dialog textarea {
  font-family: inherit;
}

#sk-dialog {
  position: fixed;
  right: 90px;
  bottom: 30px;
  width: 420px;
  height: 680px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 60px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(10, 37, 64, 0.25);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  animation: sk-slide-in 0.25s ease;
}

#sk-dialog.sk-open {
  display: flex;
}

@keyframes sk-slide-in {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 头部 ---------- */
.sk-header {
  background: linear-gradient(135deg, #0F4C81 0%, #1976b8 100%);
  color: #fff;
  padding: 14px 16px 0;
  flex-shrink: 0;
}

.sk-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sk-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
}

.sk-title small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  opacity: 0.85;
  margin-top: 2px;
}

.sk-close {
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  opacity: 0.85;
  padding: 4px;
  background: none;
  border: none;
  color: #fff;
}

.sk-close:hover { opacity: 1; }

/* 模式切换 Tab */
.sk-tabs {
  display: flex;
  margin-top: 12px;
}

.sk-tab {
  flex: 1;
  text-align: center;
  padding: 9px 0;
  font-size: 13px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.75);
  border-bottom: 2px solid transparent;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: all 0.2s;
}

.sk-tab.sk-active {
  color: #fff;
  font-weight: 600;
  border-bottom-color: #4ECDC4;
}

/* ---------- 主体 ---------- */
.sk-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f4f7fa;
}

.sk-screen {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.sk-screen.sk-active { display: flex; }

/* ---------- 业务板块选择 ---------- */
.sk-boards {
  padding: 20px 16px;
  overflow-y: auto;
}

.sk-boards-tip {
  font-size: 13px;
  color: #666;
  margin-bottom: 14px;
  text-align: center;
}

.sk-board-card {
  background: #fff;
  border: 1px solid #e3e8ef;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all 0.2s;
}

.sk-board-card:hover {
  border-color: #1976b8;
  box-shadow: 0 4px 14px rgba(15, 76, 129, 0.15);
  transform: translateY(-1px);
}

.sk-board-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, #e8f1f8, #d4e5f2);
  color: #0F4C81;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  flex-shrink: 0;
}

.sk-board-info h4 {
  font-size: 15px;
  color: #1a2332;
  margin-bottom: 4px;
}

.sk-board-info p {
  font-size: 12px;
  color: #888;
  line-height: 1.5;
}

/* ---------- 聊天区 ---------- */
.sk-chat-bar {
  background: #fff;
  border-bottom: 1px solid #eceff3;
  padding: 8px 12px;
  font-size: 12px;
  color: #666;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.sk-chat-bar .sk-board-name {
  color: #0F4C81;
  font-weight: 600;
}

.sk-reselect {
  color: #1976b8;
  cursor: pointer;
  background: none;
  border: none;
  font-size: 12px;
}

.sk-reselect:hover { text-decoration: underline; }

.sk-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
}

.sk-msg-row {
  display: flex;
  margin-bottom: 12px;
  align-items: flex-start;
}

.sk-msg-row.sk-user { justify-content: flex-end; }

.sk-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: #fff;
}

.sk-msg-row.sk-bot .sk-avatar { background: #0F4C81; margin-right: 8px; }
.sk-msg-row.sk-agent .sk-avatar { background: #0d9488; margin-right: 8px; }
.sk-msg-row.sk-user .sk-avatar { background: #90a4ae; margin-left: 8px; order: 2; }

.sk-msg-wrap {
  /* 宽度约束放在包裹层（相对消息行，宽度确定）；
     不要把 max-width 百分比放在 .sk-bubble 上——其父层是收缩适应宽度，
     百分比会形成循环依赖，导致短消息被压成竖条 */
  max-width: 78%;
  min-width: 0;
}

.sk-bubble {
  display: inline-block;
  max-width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
  text-align: left;
}

.sk-msg-row.sk-bot .sk-bubble,
.sk-msg-row.sk-agent .sk-bubble {
  background: #fff;
  color: #333;
  border: 1px solid #e8ecf1;
  border-top-left-radius: 2px;
}

.sk-msg-row.sk-user .sk-bubble {
  background: #1976b8;
  color: #fff;
  border-top-right-radius: 2px;
}

.sk-msg-time {
  display: block;
  font-size: 10px;
  color: #aaa;
  margin-top: 4px;
}

.sk-msg-row.sk-user .sk-msg-time { text-align: right; }

.sk-sys-tip {
  text-align: center;
  font-size: 11px;
  color: #999;
  margin: 8px 0;
}

/* 输入中动画 */
.sk-typing .sk-bubble {
  display: flex;
  align-items: center;
  padding: 12px 14px;
}

.sk-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b0bec5;
  margin-right: 4px;
  animation: sk-blink 1.2s infinite;
}

.sk-dot:nth-child(2) { animation-delay: 0.2s; }
.sk-dot:nth-child(3) { animation-delay: 0.4s; margin-right: 0; }

@keyframes sk-blink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

/* 常见问题 */
.sk-faqs {
  padding: 8px 12px;
  background: #f4f7fa;
  flex-shrink: 0;
}

.sk-faqs-title {
  font-size: 11px;
  color: #999;
  margin-bottom: 6px;
}

.sk-faq-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sk-faq-item {
  background: #fff;
  border: 1px solid #cfe0f5;
  color: #0F4C81;
  font-size: 12px;
  border-radius: 14px;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.sk-faq-item:hover {
  background: #1976b8;
  color: #fff;
  border-color: #1976b8;
}

/* ---------- 输入区 ---------- */
.sk-input-area {
  background: #fff;
  border-top: 1px solid #eceff3;
  padding: 10px 12px;
  display: flex;
  align-items: flex-end;
  flex-shrink: 0;
}

.sk-input {
  flex: 1;
  border: 1px solid #dde3ea;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  resize: none;
  height: 38px;
  max-height: 90px;
  line-height: 1.5;
  outline: none;
  font-family: inherit;
}

.sk-input:focus { border-color: #1976b8; }

.sk-send {
  margin-left: 8px;
  background: #0F4C81;
  color: #fff;
  border: none;
  border-radius: 8px;
  height: 38px;
  padding: 0 16px;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.sk-send:hover { background: #0a3a63; }
.sk-send:disabled { background: #b0bec5; cursor: not-allowed; }

/* ---------- 人工服务 ---------- */
.sk-human-form {
  padding: 24px 20px;
  overflow-y: auto;
}

.sk-human-form h4 {
  font-size: 15px;
  color: #1a2332;
  margin-bottom: 6px;
}

.sk-human-form .sk-form-tip {
  font-size: 12px;
  color: #999;
  margin-bottom: 16px;
  line-height: 1.6;
}

.sk-field { margin-bottom: 14px; }

.sk-field label {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 5px;
}

.sk-field input {
  width: 100%;
  border: 1px solid #dde3ea;
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}

.sk-field input:focus { border-color: #1976b8; }

.sk-form-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.sk-btn {
  flex: 1;
  border-radius: 8px;
  padding: 10px 0;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid #0F4C81;
  transition: all 0.2s;
}

.sk-btn-primary { background: #0F4C81; color: #fff; }
.sk-btn-primary:hover { background: #0a3a63; }
.sk-btn-plain { background: #fff; color: #0F4C81; }
.sk-btn-plain:hover { background: #e8f1f8; }

.sk-human-note {
  background: #fff8e1;
  border: 1px solid #ffe0a3;
  color: #8d6e1f;
  font-size: 11px;
  border-radius: 8px;
  padding: 7px 10px;
  margin: 8px 12px 0;
  line-height: 1.6;
  flex-shrink: 0;
}

/* ---------- 移动端适配 ---------- */
@media (max-width: 768px) {
  #sk-dialog {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }
}
