/**********************************
 * FeedbackWidget 样式 — 用户反馈私信浮窗
 * v1.0
 * 颜色对齐 web/shared/css/tokens.css 设计令牌（TF 靛蓝主题），
 * 未引入 tokens.css 的页面通过 fallback 值兜底。
 **********************************/

#tf-feedback-root {
  --fb-primary: var(--tf-brand-primary, #6366f1);
  --fb-primary-hover: var(--tf-brand-primary-hover, #4f46e5);
  --fb-bg: var(--tf-surface, #ffffff);
  --fb-text: var(--tf-gray-900, #171717);
  --fb-text-secondary: var(--tf-gray-500, #737373);
  --fb-border: var(--tf-gray-200, #e5e5e5);
  --fb-danger: var(--tf-danger, #ef4444);
  --fb-font: var(--tf-font-sans, 'Inter', -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif);
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9000;
  font-family: var(--fb-font);
}

/* ---- 浮窗按钮 ---- */
#tf-fb-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--fb-primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
  position: relative;
  transition: background 0.15s, transform 0.15s;
}
#tf-fb-btn:hover { background: var(--fb-primary-hover); transform: translateY(-2px); }
#tf-fb-btn:active { transform: translateY(0); }
#tf-fb-btn svg { width: 22px; height: 22px; }

.tf-fb-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--fb-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  box-sizing: border-box;
}

/* ---- 面板 ---- */
.tf-fb-panel {
  position: absolute;
  right: 0;
  bottom: 60px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 60vh;
  min-height: 420px;
  background: var(--fb-bg);
  border: 1px solid var(--fb-border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: tfFbSlideUp 0.18s ease-out;
}
@keyframes tfFbSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- 头部 ---- */
.tf-fb-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--fb-border);
  flex-shrink: 0;
}
.tf-fb-title { font-size: 15px; font-weight: 600; color: var(--fb-text); flex: 1; }
.tf-fb-close, .tf-fb-back {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--fb-text-secondary);
  font-size: 18px;
  line-height: 1;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tf-fb-close:hover, .tf-fb-back:hover { background: rgba(0, 0, 0, 0.05); color: var(--fb-text); }

/* ---- 主体 ---- */
.tf-fb-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 类型 pill 单选 */
.tf-fb-types { display: flex; gap: 8px; }
.tf-fb-type {
  flex: 1;
  padding: 7px 0;
  border-radius: 9999px;
  border: 1px solid var(--fb-border);
  background: transparent;
  color: var(--fb-text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.tf-fb-type.active {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--fb-primary);
  color: var(--fb-primary);
  font-weight: 500;
}

.tf-fb-textarea {
  width: 100%;
  min-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--fb-border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--fb-text);
  resize: vertical;
  box-sizing: border-box;
}
.tf-fb-textarea:focus { outline: none; border-color: var(--fb-primary); }

/* 图片行 */
.tf-fb-imgrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tf-fb-imgbtn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px dashed var(--fb-border);
  border-radius: 8px;
  background: transparent;
  color: var(--fb-text-secondary);
  font-size: 12px;
  cursor: pointer;
}
.tf-fb-imgbtn:hover { border-color: var(--fb-primary); color: var(--fb-primary); }
.tf-fb-imgbtn svg { width: 14px; height: 14px; }
.tf-fb-thumbs { display: flex; gap: 6px; }
.tf-fb-thumb { position: relative; width: 44px; height: 44px; }
.tf-fb-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--fb-border);
}
.tf-fb-thumb-del {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--fb-danger);
  color: #fff;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  cursor: pointer;
}

.tf-fb-source { font-size: 12px; color: var(--fb-text-secondary); word-break: break-all; }
.tf-fb-error { font-size: 12px; color: var(--fb-danger); min-height: 16px; }

.tf-fb-submit {
  padding: 10px 0;
  border: none;
  border-radius: 8px;
  background: var(--fb-primary);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.tf-fb-submit:hover { background: var(--fb-primary-hover); }
.tf-fb-submit:disabled { opacity: 0.6; cursor: default; }

.tf-fb-switch { text-align: center; font-size: 12px; }
.tf-fb-switch a { color: var(--fb-text-secondary); text-decoration: none; }
.tf-fb-switch a:hover { color: var(--fb-primary); }

/* ---- 会话列表 ---- */
.tf-fb-listbody { padding: 8px; gap: 4px; }
.tf-fb-empty { text-align: center; color: var(--fb-text-secondary); font-size: 13px; padding: 40px 0; }
.tf-fb-threaditem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.tf-fb-threaditem:hover { background: rgba(0, 0, 0, 0.04); }
.tf-fb-threaditem.closed { opacity: 0.55; }
.tf-fb-threadtype {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 500;
}
.tf-fb-threadtype.bug { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.tf-fb-threadtype.suggestion { background: rgba(34, 197, 94, 0.12); color: #22c55e; }
.tf-fb-threadtype.other { background: rgba(115, 115, 115, 0.12); color: #737373; }
.tf-fb-threadmain { flex: 1; min-width: 0; }
.tf-fb-threadsubject {
  font-size: 13px;
  color: var(--fb-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tf-fb-threadmeta { font-size: 11px; color: var(--fb-text-secondary); margin-top: 2px; }
.tf-fb-dot {
  flex-shrink: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--fb-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  box-sizing: border-box;
}

/* ---- 会话详情（气泡） ---- */
.tf-fb-msgbody { gap: 14px; }
.tf-fb-msg { display: flex; flex-direction: column; align-items: flex-start; }
.tf-fb-msg.mine { align-items: flex-end; }
.tf-fb-bubble {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.05);
  font-size: 13px;
  color: var(--fb-text);
  line-height: 1.6;
  word-break: break-word;
}
.tf-fb-msg.mine .tf-fb-bubble { background: var(--fb-primary); color: #fff; }
.tf-fb-msgtime { font-size: 11px; color: var(--fb-text-secondary); margin-top: 3px; }
.tf-fb-msgimgs { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.tf-fb-msgimg {
  max-width: 180px;
  max-height: 180px;
  border-radius: 8px;
  cursor: zoom-in;
  object-fit: contain;
  border: 1px solid rgba(0, 0, 0, 0.08);
}
.tf-fb-msgimg.zoom { position: fixed; inset: 0; max-width: 92vw; max-height: 92vh; margin: auto; z-index: 9999; cursor: zoom-out; background: rgba(0, 0, 0, 0.85); object-fit: contain; }

/* ---- 底部输入 ---- */
.tf-fb-inputrow {
  display: flex;
  gap: 8px;
  padding: 10px 12px 4px;
  border-top: 1px solid var(--fb-border);
  flex-shrink: 0;
}
.tf-fb-input {
  flex: 1;
  min-height: 38px;
  max-height: 100px;
  padding: 8px 10px;
  border: 1px solid var(--fb-border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--fb-text);
  resize: none;
  box-sizing: border-box;
}
.tf-fb-input:focus { outline: none; border-color: var(--fb-primary); }
.tf-fb-send {
  align-self: flex-end;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: var(--fb-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.tf-fb-send:hover { background: var(--fb-primary-hover); }
.tf-fb-send:disabled { opacity: 0.6; cursor: default; }
.tf-fb-replyerr { padding: 0 12px 8px; }

/* ---- 移动端适配 ---- */
@media (max-width: 640px) {
  #tf-feedback-root { right: 16px; bottom: 16px; }
  .tf-fb-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    min-height: 0;
    border-radius: 0;
    border: none;
  }
}
