/* ============================================
   Dify 浮动聊天 widget — 站点公共
   ============================================ */

.chat-fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 9998;
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--ink, #1a1a2e); color: var(--gold, #c9a84c);
  border: 2px solid var(--gold, #c9a84c);
  box-shadow: 0 8px 28px rgba(26,26,46,0.35), 0 0 0 6px rgba(201,168,76,0.12);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
  padding: 0;
}
.chat-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 32px rgba(26,26,46,0.4), 0 0 0 8px rgba(201,168,76,0.15); }
.chat-fab svg { width: 26px; height: 26px; }
.chat-fab .fab-icon-close { display: none; }
.chat-fab.open .fab-icon-chat { display: none; }
.chat-fab.open .fab-icon-close { display: block; }
.chat-fab-pulse {
  position: absolute; top: -2px; right: -2px;
  width: 14px; height: 14px; background: var(--red, #b5253a); border-radius: 50%;
  border: 2px solid var(--cream, #faf8f4);
  animation: chatfab-pulse 2s infinite;
}
.chat-fab.open .chat-fab-pulse { display: none; }
@keyframes chatfab-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.75; }
}
.chat-fab-label {
  position: absolute; right: 72px; top: 50%; transform: translateY(-50%);
  background: var(--ink, #1a1a2e); color: var(--cream, #faf8f4);
  padding: 8px 14px; border-radius: 8px; font-size: 13px; white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15); pointer-events: none;
  opacity: 0; transition: opacity 0.2s;
}
.chat-fab-label::after {
  content: ''; position: absolute; right: -5px; top: 50%; transform: translateY(-50%);
  border-style: solid; border-width: 5px 0 5px 6px;
  border-color: transparent transparent transparent var(--ink, #1a1a2e);
}
.chat-fab:hover .chat-fab-label { opacity: 1; }
.chat-fab.open .chat-fab-label { display: none; }

.chat-panel {
  position: fixed; bottom: 100px; right: 24px; z-index: 9997;
  width: 400px; max-width: calc(100vw - 32px);
  height: 620px; max-height: calc(100vh - 130px);
  background: white; border-radius: 16px;
  box-shadow: 0 24px 60px rgba(26,26,46,0.28), 0 0 0 1px rgba(26,26,46,0.06);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: translateY(16px) scale(0.96); pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.chat-panel.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.chat-panel-header {
  background: var(--ink, #1a1a2e); color: white;
  padding: 14px 18px; display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.chat-panel-avatar {
  width: 36px; height: 36px; background: var(--gold, #c9a84c); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: var(--ink, #1a1a2e); flex-shrink: 0;
}
.chat-panel-title { flex: 1; }
.chat-panel-title p { margin: 0; }
.chat-panel-title p:first-child { font-size: 14px; font-weight: 500; }
.chat-panel-title p:last-child { font-size: 11px; color: rgba(255,255,255,0.55); margin-top: 2px; }
.chat-panel-title .online-dot {
  width: 6px; height: 6px; background: #4ade80; border-radius: 50%;
  display: inline-block; margin-right: 4px; vertical-align: middle;
}
.chat-panel-close {
  background: transparent; border: none; color: rgba(255,255,255,0.7); cursor: pointer;
  padding: 6px; border-radius: 6px; transition: background 0.2s, color 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.chat-panel-close:hover { background: rgba(255,255,255,0.1); color: white; }
.chat-panel-body {
  flex: 1; position: relative; background: var(--cream, #faf8f4); overflow: hidden;
}
.chat-panel-body iframe { width: 100%; height: 100%; border: none; display: block; }
.chat-panel-loading {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1rem;
  color: var(--ink-soft, #5c5c7a); font-size: 13px; pointer-events: none;
  transition: opacity 0.3s;
}
.chat-panel-loading.hidden { opacity: 0; }
.chat-panel-loading .spinner {
  width: 32px; height: 32px; border: 3px solid var(--border, rgba(26,26,46,0.1));
  border-top-color: var(--gold, #c9a84c); border-radius: 50%;
  animation: chatfab-spin 0.8s linear infinite;
}
@keyframes chatfab-spin { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
  .chat-panel {
    bottom: 0; right: 0; left: 0;
    width: 100%; max-width: 100%;
    height: 100vh; max-height: 100vh;
    border-radius: 0;
  }
  .chat-fab { bottom: 16px; right: 16px; }
}
