/* ============================================================
 * 航嘉智能客服悬浮窗 样式表
 * 配套 service-widget.js 使用（零依赖，兼容现代浏览器）
 * ============================================================ */
:root {
  --hk-blue: #005BAC;
  --hk-blue-dark: #1f56d6;
  --hk-border: #dbe6ff;
  --hk-text: #1f2329;
  --hk-sub: #8a919f;
  --hk-bg-soft: #f4f6fa;
  --hk-radius: 14px;
}

/* ---------- 1. 右下角悬浮入口图标 ---------- */
#hk-launcher {
  position: fixed; right: 28px; bottom: 28px; z-index: 99998;
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, var(--hk-blue), #6a9bff);
  color: #fff; border: none; cursor: pointer;
  box-shadow: 0 6px 20px rgba(47, 107, 255, .40);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s ease, box-shadow .2s ease;
}
#hk-launcher:hover { transform: scale(1.06); box-shadow: 0 8px 26px rgba(47,107,255,.5); }
#hk-launcher svg { width: 30px; height: 30px; }

/* ---------- 2. 对话弹窗 ---------- */
#hk-chat-panel {
  position: fixed; right: 28px; bottom: 50px; z-index: 99999;
  width: min(420px, calc(100vw - 24px));
  height: min(640px, calc(100vh - 120px));
  background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 12px 48px rgba(31, 35, 41, .18);
  display: none; flex-direction: column;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--hk-text);
}
#hk-chat-panel.hk-open { display: flex; animation: hk-pop .18s ease-out; }
@keyframes hk-pop { from { opacity: 0; transform: translateY(12px) scale(.98);} to { opacity: 1; transform: none; } }

/* 头部 */
.hk-header {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: 14px 16px; background: linear-gradient(135deg, var(--hk-blue), #5d8dff); color: #fff;
}
.hk-header .hk-avatar { width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.22); display:flex; align-items:center; justify-content:center; }
.hk-header .hk-avatar svg { width: 18px; height: 18px; }
.hk-header .hk-title { font-size: 15px; font-weight: 600; flex: 1; }
.hk-header .hk-title small { display:block; font-size: 11px; font-weight: 400; opacity:.85; }
.hk-close {
  width: 28px; height: 28px; border: none; border-radius: 50%;
  background: rgba(255,255,255,.18); color:#fff; font-size: 16px; line-height: 28px;
  cursor: pointer; padding: 0;
}
.hk-close:hover { background: rgba(255,255,255,.32); }

/* 常驻公告栏 */
.hk-notice {
  flex: 0 0 auto; padding: 9px 14px; font-size: 14px; line-height: 1.6;
  color: #7a4a00; background: #fff7e6; border-bottom: 1px solid #ffe7ba;
}
.hk-notice b { color: var(--hk-blue); }
.hk-notice a { color: var(--hk-blue); text-decoration: none; }

/* 消息区 */
.hk-msgs {
  flex: 1 1 auto; overflow-y: auto; padding: 16px 14px 8px;
  background: #fff; scroll-behavior: smooth;
}
.hk-row { display: flex; margin-bottom: 12px; }
.hk-row.hk-me { justify-content: flex-end; }
.hk-bubble {
  max-width: 95%; padding: 10px 13px; border-radius: 12px;
  font-size: 14px; line-height: 1.65; word-break: break-word; white-space: normal;
}
.hk-row.hk-bot .hk-bubble { background: var(--hk-bg-soft); border-top-left-radius: 4px; }
.hk-row.hk-me .hk-bubble { background: var(--hk-blue); color: #fff; border-top-right-radius: 4px; }
.hk-bubble p { margin: 0 0 6px; } .hk-bubble p:last-child { margin-bottom: 0; }
.hk-bubble pre { background: #20242c; color: #e8edf5; border-radius: 8px; padding: 10px; overflow-x: auto; font-size: 12.5px; margin: 6px 0; }
.hk-bubble code { background: rgba(47,107,255,.10); border-radius: 4px; padding: 1px 5px; font-size: 12.5px; }
.hk-bubble pre code { background: none; padding: 0; }
.hk-bubble a { color: var(--hk-blue); }
.hk-row.hk-me .hk-bubble a { color:#dbe7ff; }
/* AI 回复富文本：加粗着色、有序/无序列表序号 */
.hk-bubble strong { font-weight: bold; color: #005BAC; }
.hk-bubble ol { padding-left: 20px; margin: 6px 0; }
.hk-bubble ul { padding-left: 20px; margin: 6px 0; }
.hk-bubble ol li {list-style: decimal; margin: 2px 0; }
.hk-bubble ul li {list-style: disc; }
.hk-bubble h1, .hk-bubble h2, .hk-bubble h3, .hk-bubble h4, .hk-bubble h5, .hk-bubble h6 {
    font-weight: bold; margin: 12px 0 6px; line-height: 1.4; color: var(--hk-text);
}
.hk-bubble h1 { font-size: 17px; padding-bottom: 6px; border-bottom: 1px solid var(--hk-border); }
.hk-bubble h2 { font-size: 16px; }
.hk-bubble h3 { font-size: 15px; }
.hk-bubble h4, .hk-bubble h5, .hk-bubble h6 { font-size: 14px; }
.hk-bubble hr { border: none; border-top: 1px solid #e3e6ea; margin: 12px 0; }
.hk-bubble blockquote {
    border-left: 3px solid var(--hk-blue); padding: 6px 12px; margin: 8px 0;
    color: #66707f; background: #f7f9fc; border-radius: 0 6px 6px 0;
}
.hk-bubble table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 13px; }
.hk-bubble th, .hk-bubble td { border: 1px solid #e0e4ea; padding: 6px 10px; text-align: left; }
.hk-bubble th { background: #f4f6fa; font-weight: bold; }
.hk-bubble tr:nth-child(even) td { background: #fafbfd; }
.hk-bubble img { max-width: 100%; border-radius: 6px; }

/* 气泡内附件（图片缩略图 / 文件卡片） */
.hk-files-in-bubble { display:flex; flex-wrap:wrap; gap:6px; margin-top:6px; }
.hk-files-in-bubble .hk-mini {
  display:flex; align-items:center; gap:5px; background:#fff; color:var(--hk-text);
  border:1px solid var(--hk-border); border-radius:8px; padding:4px 8px; font-size:12px; max-width:100%;
}
.hk-files-in-bubble img.hk-mini { max-height:90px; max-width:140px; padding:0; object-fit:cover; display:block; cursor: zoom-in; }
.hk-files-in-bubble .hk-mini span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
/* 客服发来的文件下载链接 */
.hk-files-in-bubble a.hk-mini.hk-file-link {
  text-decoration: none; cursor: pointer; word-break: break-all;
}
.hk-files-in-bubble a.hk-mini.hk-file-link:hover { border-color: var(--hk-blue); color: var(--hk-blue); background: #f0f5ff; }

/* 打字中动效 */
.hk-typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.hk-typing i { width: 6px; height: 6px; border-radius: 50%; background: #b6bec9; animation: hk-blink 1.2s infinite; }
.hk-typing i:nth-of-type(2){ animation-delay:.2s } .hk-typing i:nth-of-type(3){ animation-delay:.4s }
.hk-typing-text { font-size: 16px; color: var(--hk-sub); margin-right: 6px; }
@keyframes hk-blink { 0%,60%,100%{ opacity:.3 } 30%{ opacity:1 } }

/* ---------- 3. 底部输入区 ---------- */
.hk-input-wrap {
  flex: 0 0 auto; margin: 0 12px 6px; padding: 10px 12px 8px;
  border: 1.5px solid var(--hk-border); border-radius: var(--hk-radius);
  background: #fff; box-shadow: 0 2px 10px rgba(31,35,41,.05);
  transition: border-color .15s ease;
}
.hk-input-wrap:focus-within { border-color: var(--hk-blue); }
.hk-input-wrap input[type="file"] { display: none !important; }

/* 待发送图片预览 */
.hk-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.hk-attachments:empty { display: none; }
.hk-thumb {
  position: relative; width: 42px; height: 42px; border-radius: 10px;
  border: 1px solid var(--hk-border); background: var(--hk-bg-soft);
  display: flex; align-items: center; justify-content: center; overflow: visible;
  flex: 0 0 auto;
}
.hk-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; cursor: zoom-in; }
.hk-thumb.hk-file { width: auto; min-width: 120px; max-width: 170px; padding: 0 10px; gap: 8px; justify-content: flex-start; }
.hk-thumb .hk-ext { font-size: 12px; color: var(--hk-sub); font-weight: 600; }
.hk-thumb .hk-fname { font-size: 12px; color: var(--hk-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
.hk-thumb .hk-del {
  position: absolute; top: -7px; right: -7px; width: 18px; height: 18px;
  border-radius: 50%; border: none; cursor: pointer; padding: 0;
  background: rgba(31, 35, 41, .72); color: #fff; font-size: 12px; line-height: 18px;
  display: none; z-index: 2;
}
.hk-thumb:hover .hk-del { display: block; }
.hk-thumb .hk-del:hover { background: #000; }

/* 文本输入 */
.hk-input-line { display: flex; align-items: flex-end; gap: 8px; }
#hk-input {
  flex: 1; border: none; outline: none; resize: none; min-height: 50px; max-height: 120px;
  font-size: 14px; line-height: 1.5; padding: 6px 2px; font-family: inherit; color: var(--hk-text);
  background: transparent;
}
#hk-input:focus { outline: none; box-shadow: none; border: none; }
#hk-input::placeholder { color: #a8b0bd; }

/* 工具栏 */
.hk-toolbar { display: flex; align-items: center; gap: 6px; margin-top: 6px; height: 30px; }
.hk-tool {
  border: none; background: none; cursor: pointer; padding: 0; margin-right: 6px;
  display: inline-flex; align-items: center; gap: 3px;
  color: var(--hk-sub); font-size: 14px; font-family: inherit;
}
.hk-tool:hover { color: var(--hk-blue); }
.hk-tool svg { width: 18px; height: 18px; }
.hk-toolbar .spacer { flex: 1; }

/* 发送按钮：初始隐藏（.hk-hidden），有输入后显示 */
#hk-send {
  width: 30px; height: 30px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--hk-blue); color: #fff; padding: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(47,107,255,.35);
  transition: background .15s, transform .1s;
  flex: 0 0 auto;
}
#hk-send:hover { background: var(--hk-blue-dark); }
#hk-send:active { transform: scale(.92); }
#hk-send svg { width: 17px; height: 17px; }
#hk-send.hk-hidden { display: none; }
#hk-send[disabled] { background: #b9c6ea; cursor: not-allowed; box-shadow: none; }

/* 底部常驻免责声明 */
.hk-disclaimer {
  flex: 0 0 auto; padding: 0 14px 10px; text-align: center;
  font-size: 12px; color: var(--hk-sub);
}

/* 图片大图查看 lightbox */
.hk-lightbox {
  position: fixed; inset: 0; z-index: 100000;
  background: rgba(15, 18, 25, .82);
  display: none; align-items: center; justify-content: center;
}
.hk-lightbox.hk-show { display: flex; }
.hk-lightbox figure { margin: 0; max-width: 88vw; max-height: 88vh; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.hk-lightbox img {
  max-width: 88vw; max-height: 80vh; object-fit: contain;
  border-radius: 8px; background: #fff; box-shadow: 0 12px 48px rgba(0,0,0,.5);
}
.hk-lightbox figcaption { color: #dfe5ef; font-size: 13px; max-width: 88vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hk-lb-close {
  position: absolute; top: 20px; right: 24px; width: 40px; height: 40px;
  border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.14); color: #fff; font-size: 24px;
  display: flex; align-items: center; justify-content: center;
}
.hk-lb-close:hover { background: rgba(255,255,255,.28); }

/* 小屏适配 */
@media (max-width: 480px) {
  #hk-chat-panel { right: 0; bottom: 0; width: 100vw; height: calc(100vh - 56px); border-radius: 16px 16px 0 0; }
  #hk-launcher { right: 16px; bottom: 16px; width: 52px; height: 52px; }
}
