/* ==========================================================
   企微侧边栏知识库 · 侧边栏 H5 样式
   360px 窄屏 · 北欧简约浅色 · v1（2026-08-21）
   ========================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
[v-cloak] { display: none; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f7fa;
  color: #1f2d3d;
  font-size: 14px;
  max-width: 360px;
  margin: 0 auto;
  overflow: hidden;
}
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ---------- 顶部搜索 ---------- */
.kb-header {
  padding: 12px 12px 8px;
  background: #f5f7fa;
  flex-shrink: 0;
}
.search-box {
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid #e4e9f0;
  border-radius: 8px;
  padding: 8px 10px;
  gap: 6px;
}
.search-box:focus-within { border-color: #4a90b0; }
.search-ico { color: #9fb0c3; flex-shrink: 0; }
.search-box input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
  color: #1f2d3d;
}
.search-box input::placeholder { color: #b4bfcc; }
.search-clear {
  color: #b4bfcc;
  font-size: 16px;
  padding: 0 2px;
  cursor: pointer;
  line-height: 1;
}

/* ---------- 分类 chips（1 级） ---------- */
.kb-cats {
  display: flex;
  flex-wrap: wrap;          /* 允许换行：360px 窄屏下分类多时自动换行，无需横向滚动 */
  gap: 6px;
  padding: 0 12px 8px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.kb-cats::-webkit-scrollbar { display: none; }
.cat-chip {
  flex-shrink: 0;
  padding: 5px 14px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #e4e9f0;
  color: #5c6b7a;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.cat-chip.on {
  background: #2f6f8f;
  border-color: #2f6f8f;
  color: #fff;
}

/* ---------- 知识列表 ---------- */
.kb-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 8px;
  -webkit-overflow-scrolling: touch;
}
.kb-card {
  display: flex;
  gap: 10px;
  background: #fff;
  border: 1px solid #e4e9f0;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: box-shadow .15s;
}
.kb-card:active { box-shadow: 0 2px 8px rgba(47,111,143,.15); }
.card-body { flex: 1; min-width: 0; }
.card-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-preview {
  font-size: 12px;
  color: #5c6b7a;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-media {
  width: 100%;
  max-height: 120px;
  object-fit: cover;
  border-radius: 6px;
  background: #eef3f7;
  display: block;
}
.card-media.video {
  position: relative;
  width: 100%;
  height: 120px;
  overflow: hidden;
  border-radius: 6px;
  background: #eef3f7;
}
.card-media.video img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.play-ico {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  border-left: 16px solid rgba(255,255,255,.9);
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-radius: 2px;
}
.play-ico.big { border-left-width: 22px; border-top-width: 14px; border-bottom-width: 14px; }
.card-file, .card-link {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f0f4f8;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  color: #5c6b7a;
}
.file-tag {
  flex-shrink: 0;
  background: #d98e4a;
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}
.file-name, .link-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-title { color: #2f6f8f; font-weight: 500; }
.link-url { color: #9fb0c3; font-size: 11px; max-width: 90px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 类型徽标 ---------- */
.type-badge {
  flex-shrink: 0;
  align-self: flex-start;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  color: #fff;
  font-weight: 500;
  margin-top: 1px;
}
.type-badge.mini { padding: 1px 5px; }
.t-text { background: #4a90b0; }
.t-image { background: #4c8c6f; }
.t-video { background: #7f77dd; }
.t-file { background: #d98e4a; }
.t-link { background: #2f6f8f; }

/* ---------- 列表提示 ---------- */
.list-tip {
  text-align: center;
  color: #b4bfcc;
  font-size: 12px;
  padding: 14px 0;
}
.list-tip.empty { color: #9fb0c3; }

/* ---------- 最近使用 ---------- */
.kb-recent {
  flex-shrink: 0;
  background: #fff;
  border-top: 1px solid #e4e9f0;
  padding: 8px 12px;
  max-height: 120px;
  overflow-y: auto;
}
.recent-title { font-size: 12px; color: #9fb0c3; margin-bottom: 6px; }
.recent-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  cursor: pointer;
}
.recent-name {
  font-size: 13px;
  color: #5c6b7a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 发送面板 ---------- */
.send-panel {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  margin: 0 auto;
  max-width: 360px;
  background: #fff;
  border-top: 1px solid #e4e9f0;
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -4px 20px rgba(31,45,61,.12);
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  z-index: 20;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.panel-title { font-size: 14px; font-weight: 500; color: #2f6f8f; }
.panel-close { font-size: 20px; color: #b4bfcc; cursor: pointer; line-height: 1; padding: 2px; }
.panel-preview {
  background: #f5f7fa;
  border: 1px dashed #d5dde6;
  border-radius: 8px;
  padding: 12px;
  max-height: 45vh;
  overflow-y: auto;
}
.pv-text { font-size: 13px; line-height: 1.7; color: #1f2d3d; white-space: pre-wrap; word-break: break-all; }
.pv-media { width: 100%; max-height: 200px; object-fit: contain; border-radius: 6px; background: #eef3f7; }
.pv-media.video { position: relative; }
.pv-file { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #5c6b7a; }
.pv-link { display: flex; gap: 10px; }
.pv-link-img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.pv-link-info { min-width: 0; }
.pv-link-title { font-size: 13px; font-weight: 500; color: #2f6f8f; margin-bottom: 2px; }
.pv-link-desc { font-size: 12px; color: #5c6b7a; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pv-link-url { font-size: 11px; color: #b4bfcc; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-actions { display: flex; gap: 10px; margin-top: 12px; }
.btn {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 11px 0;
  font-size: 14px;
  cursor: pointer;
  transition: opacity .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-copy { background: #f0f4f8; color: #2f6f8f; }
.btn-send { background: #2f6f8f; color: #fff; }
.btn-send:active { opacity: .85; }

/* ---------- 动画 ---------- */
.slide-enter-active, .slide-leave-active { transition: transform .25s ease; }
.slide-enter-from, .slide-leave-to { transform: translateY(100%); }
.fade-enter-active, .fade-leave-active { transition: opacity .25s; }
.fade-enter-from, .fade-leave-to { opacity: 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(31,45,61,.85);
  color: #fff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 8px;
  z-index: 99;
  max-width: 260px;
  text-align: center;
  pointer-events: none;
}
