/* 聊天悬浮按钮 */
.chat-fab {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #ff4757 0%, #ff6b81 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(255, 71, 87, 0.5);
  z-index: 999;
  transition: all 0.3s ease;
  animation: fabPulse 2s infinite;
}

.chat-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(255, 71, 87, 0.6);
}

.chat-fab:active {
  transform: scale(0.95);
}

.chat-fab-icon {
  font-size: 28px;
}

.chat-fab-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #2ed573;
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #0a0a0f;
}

.chat-fab-badge.hidden {
  display: none;
}

@keyframes fabPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(255, 71, 87, 0.5); }
  50% { box-shadow: 0 4px 30px rgba(255, 71, 87, 0.8); }
}

/* 聊天窗口 */
.chat-window {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 340px;
  height: 480px;
  background: #12121a;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: chatWindowIn 0.3s ease;
}

.chat-window.hidden {
  display: none;
}

@keyframes chatWindowIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 聊天头部 */
.chat-header {
  background: linear-gradient(135deg, #ff4757 0%, #ff6b81 100%);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.chat-header-text h3 {
  font-size: 16px;
  font-weight: 600;
  color: white;
}

.chat-header-text p {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  gap: 4px;
}

.online-dot {
  width: 8px;
  height: 8px;
  background: #2ed573;
  border-radius: 50%;
  animation: blink 1.5s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.chat-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* 消息列表 */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;  /* 確保輸入框始終可見 */
}

.chat-message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  animation: messageIn 0.2s ease;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message.admin {
  background: #1e1e2e;
  color: #cdd6f4;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-message.visitor {
  background: linear-gradient(135deg, #ff4757 0%, #ff6b81 100%);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.message-time {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 4px;
  text-align: right;
}

.chat-message.admin .message-time {
  color: rgba(205, 214, 244, 0.5);
  text-align: left;
}

/* 输入区域 */
.chat-input-area {
  padding: 16px;
  background: #1a1a25;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #12121a;
  border-radius: 24px;
  padding: 4px 4px 4px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: border-color 0.3s ease;
}

.chat-input-wrapper:focus-within {
  border-color: #ff4757;
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #cdd6f4;
  font-size: 14px;
  outline: none;
  padding: 8px 0;
}

.chat-input::placeholder {
  color: rgba(205, 214, 244, 0.4);
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #ff4757 0%, #ff6b81 100%);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-send-btn:hover {
  transform: scale(1.05);
}

.chat-send-btn:active {
  transform: scale(0.95);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 聊天頭部操作按鈕 */
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-call-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-call-btn:hover {
  background: rgba(46, 213, 115, 0.8);
  transform: scale(1.1);
}

.chat-call-btn:active {
  transform: scale(0.95);
}

/* 通話界面 */
.call-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, #1a1a2e 0%, #0f0f1a 100%);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: callOverlayIn 0.3s ease;
}

.call-overlay.hidden {
  display: none;
}

@keyframes callOverlayIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.call-content {
  text-align: center;
  z-index: 10;
}

.call-avatar {
  width: 100px;
  height: 100px;
  background: linear-gradient(135deg, #ff4757 0%, #ff6b81 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 50px;
  margin: 0 auto 24px;
  animation: callAvatarPulse 2s infinite;
  box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7);
}

@keyframes callAvatarPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 20px rgba(255, 71, 87, 0);
    transform: scale(1.05);
  }
}

.call-status {
  font-size: 18px;
  color: #cdd6f4;
  margin-bottom: 12px;
  font-weight: 500;
}

.call-timer {
  font-size: 32px;
  color: #2ed573;
  font-weight: 700;
  margin-bottom: 40px;
  font-family: 'Courier New', monospace;
}

.call-timer.hidden {
  display: none;
}

.call-actions {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.call-end-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: #ef4444;
  border: none;
  color: white;
  padding: 16px 32px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.call-end-btn span:first-child {
  font-size: 24px;
}

.call-end-btn:hover {
  background: #dc2626;
  transform: scale(1.05);
}

.call-end-btn:active {
  transform: scale(0.95);
}

/* 通話波紋動畫 */
.call-wave {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid rgba(255, 71, 87, 0.3);
  animation: callWave 2s infinite;
}

.call-wave::before,
.call-wave::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid rgba(255, 71, 87, 0.2);
}

.call-wave::before {
  width: 250px;
  height: 250px;
  animation: callWave 2s infinite 0.5s;
}

.call-wave::after {
  width: 300px;
  height: 300px;
  animation: callWave 2s infinite 1s;
}

@keyframes callWave {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.5);
    opacity: 0;
  }
}

/* 用戶接收來電彈窗 */
.user-incoming-call-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(10px);
}

.user-incoming-call-modal.show {
  display: flex;
  animation: fadeIn 0.3s ease;
}

.user-call-modal-content {
  text-align: center;
  color: white;
}

.user-call-avatar {
  width: 120px;
  height: 120px;
  background: linear-gradient(135deg, #ff4757 0%, #ff6b81 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 60px;
  margin: 0 auto 24px;
  animation: callAvatarPulse 2s infinite;
}

.user-call-modal-content h3 {
  font-size: 24px;
  margin-bottom: 8px;
}

.user-call-modal-content p {
  font-size: 16px;
  color: rgba(255,255,255,0.7);
  margin-bottom: 40px;
}

.user-call-actions {
  display: flex;
  justify-content: center;
  gap: 30px;
}

.user-accept-btn,
.user-reject-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 30px;
  border-radius: 50px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-accept-btn {
  background: linear-gradient(135deg, #2ed573 0%, #26de81 100%);
  color: white;
}

.user-accept-btn:hover {
  transform: scale(1.1);
}

.user-reject-btn {
  background: linear-gradient(135deg, #ff4757 0%, #ff6b81 100%);
  color: white;
}

.user-reject-btn:hover {
  transform: scale(1.1);
}

.user-accept-btn span:first-child,
.user-reject-btn span:first-child {
  font-size: 28px;
}

/* 手机适配 */
@media (max-width: 400px) {
  .chat-window {
    width: calc(100vw - 40px);
    height: 70vh;
    bottom: 80px;
    right: 20px;
    left: 20px;
  }
}


