/* =============================================================
   Portal 客服悬浮组件（联系 + 留言）
   依赖：页面已引入 fonts.css / app.js
   ============================================================= */

.pfw-fab {
  position: fixed; right: 28px; bottom: 28px; z-index: 9000;
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, #7C3AED, #5B21B6); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 26px rgba(124,58,237,.45), 0 3px 8px rgba(15,23,42,.18);
  transition: transform .2s;
}
.pfw-fab:hover { transform: translateY(-3px); }
.pfw-fab svg { width: 26px; height: 26px; }
.pfw-fab .pfw-badge {
  position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px;
  padding: 0 5px; border-radius: 999px; background: #EF4444; border: 2.5px solid #fff;
  color: #fff; font-size: 11px; font-weight: 700; font-family: "Alibaba PuHuiTi", sans-serif;
  display: flex; align-items: center; justify-content: center;
}
.pfw-fab .pfw-badge.hidden { display: none; }

/* 遮罩 */
.pfw-backdrop {
  position: fixed; inset: 0; z-index: 9500;
  background: rgba(15,23,42,.45);
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.pfw-backdrop.show { opacity: 1; pointer-events: auto; }

/* 抽屉 */
.pfw-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 9600;
  width: 440px; max-width: 92vw;
  background: #fff; border-left: 1px solid #E2E8F0;
  box-shadow: -18px 0 48px rgba(15,23,42,.14);
  display: flex; flex-direction: column;
  transform: translateX(105%); transition: transform .28s cubic-bezier(.4,0,.2,1);
  font-family: "Alibaba PuHuiTi", sans-serif; color: #1E293B;
}
.pfw-drawer.show { transform: translateX(0); }

.pfw-head {
  display: flex; align-items: center; gap: 10px; padding: 16px 20px;
  border-bottom: 1px solid #F1F5F9; flex-shrink: 0;
}
.pfw-head-icon {
  width: 36px; height: 36px; border-radius: 10px; color: #fff; flex-shrink: 0;
  background: linear-gradient(135deg, #7C3AED, #5B21B6);
  display: flex; align-items: center; justify-content: center;
}
.pfw-head-icon svg { width: 20px; height: 20px; }
.pfw-head-title { font-size: 16px; font-weight: 700; }
.pfw-head-sub { font-size: 11px; color: #94A3B8; margin-top: 1px; }
.pfw-x, .pfw-back {
  width: 30px; height: 30px; border: none; background: transparent; color: #94A3B8;
  cursor: pointer; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-family: inherit;
}
.pfw-x:hover, .pfw-back:hover { background: #F1F5F9; color: #475569; }
.pfw-x svg, .pfw-back svg { width: 16px; height: 16px; }
.pfw-head-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.pfw-btn-icon {
  width: 30px; height: 30px; border: 1px solid #E2E8F0; background: #fff; color: #64748B;
  border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-family: inherit;
}
.pfw-btn-icon:hover { background: #F8FAFC; color: #7C3AED; }
.pfw-btn-icon svg { width: 15px; height: 15px; }

.pfw-body { flex: 1; overflow: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 16px; }
.pfw-body.nopad { padding: 0; }

/* ===== 联系卡片 ===== */
.pfw-contact {
  border-radius: 16px; padding: 18px; position: relative; overflow: hidden;
  background: linear-gradient(140deg, #F5F3FF, #EDE9FE); border: 1px solid #DDD6FE;
}
.pfw-contact::after {
  content: ''; position: absolute; top: -40px; right: -30px; width: 140px; height: 140px;
  border-radius: 50%; background: radial-gradient(circle, rgba(124,58,237,.14), transparent 70%);
}
.pfw-contact-who { display: flex; align-items: center; gap: 12px; position: relative; }
.pfw-contact-avatar {
  width: 46px; height: 46px; border-radius: 12px; color: #fff; flex-shrink: 0;
  background: linear-gradient(135deg, #7C3AED, #5B21B6);
  display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700;
  box-shadow: 0 6px 14px rgba(124,58,237,.30);
}
.pfw-contact-name { font-size: 15px; font-weight: 700; }
.pfw-contact-role {
  font-size: 11px; color: #7C3AED; background: rgba(124,58,237,.10);
  padding: 2px 10px; border-radius: 999px; font-weight: 600; margin-top: 3px; display: inline-block;
}
.pfw-contact-rows { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; position: relative; }
.pfw-contact-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: rgba(255,255,255,.85); border: 1px solid #E9E4FA; border-radius: 12px;
}
.pfw-contact-row svg { width: 17px; height: 17px; color: #7C3AED; flex-shrink: 0; }
.pfw-contact-row .pfw-lab { font-size: 12px; color: #94A3B8; width: 44px; flex-shrink: 0; }
.pfw-contact-row .pfw-val {
  font-size: 15px; font-weight: 700; letter-spacing: .04em;
  font-variant-numeric: tabular-nums; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pfw-copy {
  border: none; background: #7C3AED; color: #fff; font-size: 11px; font-weight: 600;
  padding: 5px 12px; border-radius: 999px; cursor: pointer; font-family: inherit; flex-shrink: 0;
  text-decoration: none; display: inline-flex; align-items: center;
}
.pfw-contact-hint { font-size: 11px; color: #94A3B8; text-align: center; margin-top: 10px; }
.pfw-contact-empty {
  font-size: 12px; color: #94A3B8; text-align: center; padding: 8px 0 2px; position: relative;
}

/* ===== 留言表单 ===== */
.pfw-write { border: 1px solid #E2E8F0; border-radius: 16px; padding: 16px; background: #fff; }
.pfw-sec-title {
  font-size: 13px; font-weight: 700; color: #475569;
  display: flex; align-items: center; gap: 6px;
}
.pfw-sec-title::before { content: ''; width: 4px; height: 14px; border-radius: 2px; background: #F97316; }
.pfw-sec-title.purple::before { background: #7C3AED; }
.pfw-sec-title .pfw-cnt { font-size: 11px; color: #94A3B8; font-weight: 400; }
.pfw-write-area {
  width: 100%; min-height: 88px; border: 1px solid #E2E8F0; border-radius: 12px;
  padding: 12px; font-size: 13px; font-family: inherit; resize: vertical; margin-top: 10px;
  color: #1E293B; line-height: 1.7; outline: none; box-sizing: border-box;
}
.pfw-write-area:focus { border-color: #C4B5FD; box-shadow: 0 0 0 3px rgba(124,58,237,.10); }
.pfw-write-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.pfw-write-count { font-size: 11px; color: #94A3B8; }
.pfw-btn-send {
  border: none; color: #fff; font-size: 13px; font-weight: 700;
  padding: 9px 26px; border-radius: 10px; cursor: pointer; font-family: inherit;
  background: linear-gradient(135deg, #F97316, #EA580C); box-shadow: 0 6px 14px rgba(249,115,22,.30);
}
.pfw-btn-send:disabled { background: #CBD5E1; box-shadow: none; cursor: not-allowed; }
.pfw-btn-send.loading { opacity: .6; cursor: wait; }

/* ===== 列表 ===== */
.pfw-item {
  border: 1px solid #E2E8F0; border-radius: 14px; padding: 13px 15px; cursor: pointer;
  background: #fff; transition: box-shadow .15s, border-color .15s;
}
.pfw-item:hover { border-color: #DDD6FE; box-shadow: 0 4px 14px rgba(124,58,237,.10); }
.pfw-item.pending { border-left: 3px solid #F97316; }
.pfw-item-top { display: flex; align-items: center; gap: 8px; }
.pfw-st { font-size: 11px; font-weight: 600; padding: 2px 10px; border-radius: 999px; flex-shrink: 0; }
.pfw-st.pending { color: #B45309; background: #FEF3C7; }
.pfw-st.replied { color: #047857; background: #D1FAE5; }
.pfw-st.closed { color: #64748B; background: #F1F5F9; }
.pfw-who { font-size: 13px; font-weight: 700; }
.pfw-time { margin-left: auto; font-size: 11px; color: #94A3B8; flex-shrink: 0; }
.pfw-item-content {
  font-size: 13px; color: #334155; line-height: 1.7; margin-top: 7px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pfw-reply-peek {
  display: flex; gap: 8px; margin-top: 10px; padding: 9px 12px;
  background: #F5F3FF; border-radius: 10px; font-size: 12px; color: #6D28D9; line-height: 1.6;
}
.pfw-reply-peek svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 2px; }
.pfw-item-foot { display: flex; align-items: center; gap: 10px; margin-top: 9px; font-size: 11px; color: #94A3B8; }
.pfw-item-foot .pfw-reply-cnt { display: inline-flex; align-items: center; gap: 4px; color: #7C3AED; font-weight: 600; }
.pfw-item-foot .pfw-reply-cnt svg { width: 12px; height: 12px; }
.pfw-item-foot .pfw-img-cnt { display: inline-flex; align-items: center; gap: 4px; }
.pfw-item-foot .pfw-img-cnt svg { width: 12px; height: 12px; }
.pfw-item-foot .pfw-cat { margin-left: auto; background: #F1F5F9; border-radius: 6px; padding: 2px 8px; font-weight: 600; color: #64748B; }

.pfw-src { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 6px; flex-shrink: 0; }
.pfw-src.h5 { color: #0369A1; background: #E0F2FE; }
.pfw-src.portal { color: #6D28D9; background: #EDE9FE; }

.pfw-empty { text-align: center; padding: 34px 0; color: #94A3B8; font-size: 13px; }
.pfw-empty svg { width: 36px; height: 36px; color: #CBD5E1; display: block; margin: 0 auto 10px; }

.pfw-more {
  border: 1px solid #E2E8F0; background: #F8FAFC; color: #64748B;
  font-size: 12px; font-weight: 600; padding: 9px; border-radius: 12px; cursor: pointer;
  font-family: inherit; width: 100%;
}
.pfw-more:hover { background: #F1F5F9; }
.pfw-more:disabled { opacity: .5; cursor: wait; }

/* ===== 收件箱筛选 ===== */
.pfw-stats { display: flex; gap: 10px; }
.pfw-stat-chip { flex: 1; border-radius: 12px; padding: 10px 14px; border: 1px solid #E2E8F0; background: #fff; }
.pfw-stat-chip .num { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pfw-stat-chip .num.hot { color: #EA580C; }
.pfw-stat-chip .lab { font-size: 11px; color: #94A3B8; margin-top: 1px; }
.pfw-stat-chip.alert { border-color: #FED7AA; background: #FFF7ED; }

.pfw-filter { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pfw-f-chip {
  border: 1px solid #E2E8F0; background: #fff; color: #64748B;
  font-size: 12px; font-weight: 600; padding: 5px 14px; border-radius: 999px;
  cursor: pointer; font-family: inherit;
}
.pfw-f-chip.on { background: #7C3AED; border-color: #7C3AED; color: #fff; }
.pfw-f-chip.on.blue { background: #0EA5E9; border-color: #0EA5E9; }
.pfw-search {
  width: 100%; border: 1px solid #E2E8F0; border-radius: 10px; padding: 7px 12px;
  font-size: 12px; font-family: inherit; outline: none; color: #1E293B; box-sizing: border-box;
}
.pfw-search:focus { border-color: #C4B5FD; box-shadow: 0 0 0 3px rgba(124,58,237,.10); }

/* ===== 对话详情 ===== */
.pfw-chat-body { padding: 0; display: flex; flex-direction: column; }
.pfw-chat-meta { padding: 14px 20px; border-bottom: 1px solid #F1F5F9; background: #FAFBFD; }
.pfw-orig-quote {
  background: #fff; border: 1px dashed #C4B5FD; border-radius: 12px;
  padding: 10px 14px; font-size: 12px; color: #7C3AED; line-height: 1.7;
}
.pfw-chat-msgs {
  flex: 1; overflow: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px;
  background: #F8FAFC; min-height: 200px;
}
.pfw-bubble-row { display: flex; gap: 10px; }
.pfw-bubble-row.admin-side { flex-direction: row-reverse; }
.pfw-bubble-ava {
  width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
}
.pfw-bubble-ava.user { background: linear-gradient(135deg, #64748B, #475569); }
.pfw-bubble-ava.admin { background: linear-gradient(135deg, #7C3AED, #5B21B6); }
.pfw-bubble { max-width: 78%; border-radius: 14px; padding: 10px 14px; font-size: 13px; line-height: 1.75; word-break: break-word; }
.pfw-bubble.user { background: #fff; border: 1px solid #E2E8F0; color: #1E293B; border-top-left-radius: 4px; }
.pfw-bubble.admin {
  background: linear-gradient(135deg, #7C3AED, #6D28D9); color: #fff;
  border-top-right-radius: 4px; box-shadow: 0 4px 12px rgba(124,58,237,.25);
}
.pfw-bubble-time { font-size: 10px; color: #94A3B8; margin-top: 5px; }
.pfw-bubble.admin .pfw-bubble-time { color: rgba(255,255,255,.75); }
.pfw-bubble-imgs { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.pfw-bubble-imgs img { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; border: 1px solid rgba(0,0,0,.06); cursor: pointer; }

.pfw-chat-input {
  border-top: 1px solid #F1F5F9; padding: 12px 16px; display: flex; gap: 10px;
  background: #fff; flex-shrink: 0;
}
.pfw-chat-input input, .pfw-chat-input textarea {
  flex: 1; border: 1px solid #E2E8F0; border-radius: 10px; padding: 9px 14px;
  font-size: 13px; font-family: inherit; outline: none; resize: none;
}
.pfw-chat-input input:focus, .pfw-chat-input textarea:focus { border-color: #C4B5FD; box-shadow: 0 0 0 3px rgba(124,58,237,.10); }
.pfw-btn-reply {
  border: none; color: #fff; font-size: 13px; font-weight: 700;
  padding: 9px 20px; border-radius: 10px; cursor: pointer; font-family: inherit;
  background: linear-gradient(135deg, #7C3AED, #6D28D9); box-shadow: 0 6px 14px rgba(124,58,237,.30);
}
.pfw-btn-reply:disabled { background: #CBD5E1; box-shadow: none; cursor: not-allowed; }
.pfw-chat-ops { display: flex; gap: 6px; padding: 0 16px 12px; background: #fff; flex-shrink: 0; }
.pfw-btn-ghost {
  border: 1px solid #E2E8F0; background: #fff; color: #64748B;
  font-size: 11px; font-weight: 600; padding: 4px 12px; border-radius: 999px;
  cursor: pointer; font-family: inherit;
}
.pfw-btn-ghost:hover { background: #F8FAFC; }
.pfw-btn-ghost.danger { color: #DC2626; border-color: #FECACA; }
.pfw-btn-ghost.danger:hover { background: #FEF2F2; }

.pfw-closed-tip {
  border-top: 1px solid #F1F5F9; padding: 12px 16px; background: #fff;
  font-size: 12px; color: #94A3B8; text-align: center; flex-shrink: 0;
}

/* ===== 联系方式编辑 ===== */
.pfw-form { padding: 20px; display: flex; flex-direction: column; gap: 14px; overflow: auto; }
.pfw-field { display: flex; flex-direction: column; gap: 6px; }
.pfw-field label { font-size: 12px; font-weight: 600; color: #475569; }
.pfw-field input {
  border: 1px solid #E2E8F0; border-radius: 10px; padding: 9px 12px;
  font-size: 13px; font-family: inherit; outline: none;
}
.pfw-field input:focus { border-color: #C4B5FD; box-shadow: 0 0 0 3px rgba(124,58,237,.10); }
.pfw-field .pfw-field-hint { font-size: 11px; color: #94A3B8; }
.pfw-form-foot { display: flex; gap: 10px; margin-top: 6px; }
.pfw-btn-primary {
  flex: 1; border: none; color: #fff; font-size: 13px; font-weight: 700;
  padding: 10px; border-radius: 10px; cursor: pointer; font-family: inherit;
  background: linear-gradient(135deg, #7C3AED, #6D28D9);
}
.pfw-btn-primary:disabled { background: #CBD5E1; cursor: not-allowed; }
.pfw-btn-plain {
  flex: 1; border: 1px solid #E2E8F0; color: #64748B; font-size: 13px; font-weight: 600;
  padding: 10px; border-radius: 10px; cursor: pointer; font-family: inherit; background: #fff;
}

/* loading */
.pfw-loading { text-align: center; padding: 30px 0; color: #94A3B8; font-size: 12px; }
