/* AI安宝 浮动聊天组件 */
/* v1 - 2026-08-14 */

/* ========== 浮动气泡按钮 ========== */
.chat-bubble {
  position: fixed;
  cursor: grab;
  touch-action: none;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c9a96e 0%, #b8860b 100%);
  box-shadow: 0 4px 16px rgba(184, 134, 11, 0.4);
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  user-select: none;
  -webkit-user-select: none;
}

.chat-bubble:hover {
  box-shadow: 0 6px 24px rgba(184, 134, 11, 0.55);
}

.chat-bubble:active {
  transform: scale(1.05);
  cursor: grabbing;
}

.chat-bubble-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.chat-bubble-icon .icon-scales {
  font-size: 17px;
  margin-bottom: 2px;
}

.chat-bubble-icon .icon-text {
  font-size: 11px;
  letter-spacing: 0;
  white-space: nowrap;
}

/* 气泡上的小红点（可选提示） */
.chat-bubble .chat-bubble-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #c93d3e;
  color: #fff;
  font-size: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

.chat-bubble .chat-bubble-badge.show {
  display: flex;
}

/* ========== 对话面板 ========== */
.chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 420px;
  height: 620px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* 全屏模式 */
.chat-panel.fs { top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important; width: 100vw !important; height: 100vh !important; max-width: 100vw; max-height: 100vh; border-radius: 0; transform: none; }
.chat-panel.fs .chat-messages, .chat-panel.fs .chat-input-area { max-width: 860px; margin-left: auto; margin-right: auto; width: 100%; }

/* 多行输入框 */
.chat-textarea { resize: vertical; min-height: 52px; max-height: 160px; border-radius: 14px; padding: 10px 14px; line-height: 1.5; flex: 1; border: 1px solid #ddd; outline: none; background: #fafafa; font-family: inherit; font-size: 14px; }
.chat-textarea:focus { border-color: #836e48; background: #fff; }
.chat-panel-header .chat-header-fs { width: 28px; height: 28px; border: none; background: rgba(255,255,255,.2); color: #fff; border-radius: 50%; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.chat-panel-header .chat-header-fs:hover { background: rgba(255,255,255,.35); }

/* ========== 面板头部 ========== */
.chat-panel-header {
  background: linear-gradient(135deg, #c9a96e 0%, #b8860b 100%);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-panel-header .chat-header-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-panel-header .chat-header-title .header-icon {
  font-size: 18px;
}

.chat-panel-header .chat-header-close {
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  line-height: 1;
}

.chat-panel-header .chat-header-close:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* ========== 消息区域 ========== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: #fafafa;
}

.chat-messages::-webkit-scrollbar {
  width: 5px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #d9d9d9;
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

/* 欢迎消息 */
.chat-welcome {
  text-align: center;
  padding: 20px 12px;
  color: #6b6b6b;
  font-size: 13px;
}

.chat-welcome .welcome-icon {
  font-size: 36px;
  margin-bottom: 8px;
  display: block;
}

.chat-welcome .welcome-title {
  font-size: 15px;
  color: #8d6709;
  font-weight: 600;
  margin-bottom: 4px;
}

/* ========== 消息气泡 ========== */
.chat-message {
  margin-bottom: 12px;
  max-width: 80%;
  word-wrap: break-word;
  word-break: break-word;
  animation: chatFadeIn 0.3s ease;
}

@keyframes chatFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-message.user {
  margin-left: auto;
  background: #1668dc;
  color: #fff;
  border-radius: 12px 12px 2px 12px;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.5;
}

.chat-message.ai {
  background: #f5f5f5;
  color: #333;
  border-radius: 12px 12px 12px 2px;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.5;
}

.chat-message.loading {
  background: #f5f5f5;
  color: #6b6b6b;
  font-style: italic;
  border-radius: 12px 12px 12px 2px;
  padding: 8px 12px;
  font-size: 14px;
}

.chat-message.loading .loading-dots {
  display: inline-block;
}

.chat-message.loading .loading-dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b8860b;
  margin: 0 2px;
  animation: chatBounce 1.4s infinite ease-in-out both;
}

.chat-message.loading .loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.chat-message.loading .loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes chatBounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* ========== 法条卡片 ========== */
.law-card {
  border-left: 3px solid #c9a96e;
  background: #fffbf5;
  padding: 8px 10px;
  margin-top: 8px;
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 13px;
}

.law-card:hover {
  background: #fff5e0;
}

.law-card .law-card-title {
  font-weight: 600;
  color: #8d6709;
  font-size: 13px;
  margin-bottom: 2px;
}

.law-card .law-card-source {
  font-size: 12px;
  color: #6b6b6b;
}

.law-card .law-card-arrow {
  float: right;
  color: #836e48;
  font-size: 14px;
}

/* ========== 快捷问题 ========== */
.chat-quick-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid #f0f0f0;
  flex-shrink: 0;
  background: #fff;
}

.chat-quick-btn {
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid #c9a96e;
  border-radius: 14px;
  background: #fff;
  color: #8d6709;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  line-height: 1.4;
}

.chat-quick-btn:hover {
  background: #c9a96e;
  color: #1e3a5f;
}

.chat-quick-btn:active {
  background: #b8860b;
}

/* ========== 输入区域 ========== */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid #f0f0f0;
  flex-shrink: 0;
  background: #fff;
}

.chat-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  background: #fafafa;
  font-family: inherit;
}

.chat-input:focus {
  border-color: #836e48;
  background: #fff;
}

.chat-input::placeholder {
  color: #767676;
  font-size: 13px;
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #c9a96e 0%, #b8860b 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  box-shadow: 0 2px 8px rgba(184, 134, 11, 0.4);
}

.chat-send-btn:active {
  transform: scale(0.95);
}

.chat-send-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* ========== 错误消息 ========== */
.chat-message.error {
  background: #fff2f0;
  color: #c93d3e;
  border: 1px solid #ffccc7;
  border-radius: 12px 12px 12px 2px;
  padding: 8px 12px;
  font-size: 13px;
}

/* ========== 响应式：移动端 ========== */
@media screen and (max-width: 768px) {
  .chat-bubble {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
  }

  .chat-bubble-icon {
    width: 28px;
    height: 28px;
  }

  .chat-bubble-icon .icon-scales {
    font-size: 18px;
  }

  .chat-bubble-icon .icon-text {
    font-size: 12px;
  }

  .chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    height: calc(100vh - 68px);
    border-radius: 12px 12px 0 0;
    max-width: 100%;
  }

  .chat-input {
    font-size: 16px; /* 防止 iOS 自动放大 */
  }
}

/* 模拟仲裁庭浮动按钮（位于AI安宝上方） */
#arb-float-btn {
  position: fixed;
  cursor: grab;
  touch-action: none;
  bottom: 98px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e3a5f 0%, #2c5490 100%);
  box-shadow: 0 4px 16px rgba(30,58,95,.4);
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all 0.3s ease;
  user-select: none;
  -webkit-user-select: none;
}
#arb-float-btn:hover { box-shadow: 0 6px 20px rgba(30,58,95,.55); }
#arb-float-btn .chat-bubble-icon { color: #fff; }
#arb-float-btn .icon-scales { font-size: 17px; margin-bottom: 2px; }
#arb-float-btn .icon-text { font-size: 11px; color: #fff; white-space: nowrap; }
@media (max-width: 560px) {
  #arb-float-btn { bottom: 92px; right: 12px; width: 56px; height: 56px; }
}

#arb-float-btn .fa-scale-balanced { font-size: 17px; color: #fff; margin-bottom: 3px; }
