/**
 * Chat Widget Styles
 * 门户网站聊天浮窗样式
 */

/* Chat Button */
.chat-widget-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.3);
  transition: all 0.3s ease;
  z-index: 9999;
  border: none;
}

.chat-widget-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(37, 99, 235, 0.4);
}

.chat-widget-btn .chat-icon {
  font-size: 24px;
}

.chat-widget-btn .chat-label {
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.chat-widget-btn:hover .chat-label {
  opacity: 1;
}

.chat-widget-btn.active {
  background: #ef4444;
}

/* Chat Window */
.chat-widget-window {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 380px;
  height: 500px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  z-index: 9998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}

.chat-widget-window.open {
  display: flex;
}

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

/* Chat Header */
.chat-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: white;
}

.chat-widget-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-widget-header-title i {
  font-size: 20px;
}

.chat-widget-header-title span {
  font-size: 16px;
  font-weight: 600;
}

.chat-widget-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
}

.chat-widget-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Pre-chat Form */
.chat-widget-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.chat-widget-form-title {
  font-size: 14px;
  color: #6b7280;
  text-align: center;
}

.chat-widget-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-widget-form-group label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.chat-widget-form-group input {
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s ease;
}

.chat-widget-form-group input:focus {
  outline: none;
  border-color: #3b82f6;
}

.chat-widget-form-group input::placeholder {
  color: #9ca3af;
}

.chat-widget-start-btn {
  padding: 12px 20px;
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-widget-start-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.chat-widget-start-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Chat Messages */
.chat-widget-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-widget-message {
  display: flex;
  gap: 8px;
  max-width: 80%;
}

.chat-widget-message.visitor {
  flex-direction: row;
  align-self: flex-start;
}

.chat-widget-message.admin {
  flex-direction: row-reverse;
  align-self: flex-end;
}

.chat-widget-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.chat-widget-message.visitor .chat-widget-avatar {
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
}

.chat-widget-message.admin .chat-widget-avatar {
  background: rgba(34, 197, 94, 0.1);
  color: #16a34a;
}

.chat-widget-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-widget-message.admin .chat-widget-content {
  align-items: flex-end;
}

.chat-widget-sender {
  font-size: 12px;
  color: #6b7280;
}

.chat-widget-text {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-widget-message.visitor .chat-widget-text {
  background: white;
  color: #374151;
  border: 1px solid #e5e7eb;
}

.chat-widget-message.admin .chat-widget-text {
  background: rgba(34, 197, 94, 0.1);
  color: #15803d;
}

.chat-widget-time {
  font-size: 11px;
  color: #9ca3af;
}

/* Chat Input */
.chat-widget-input {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid #e5e7eb;
  background: white;
  align-items: flex-end;
}

.chat-widget-input textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  resize: none;
  min-height: 40px;
  max-height: 100px;
  font-family: inherit;
}

.chat-widget-input textarea:focus {
  outline: none;
  border-color: #3b82f6;
}

.chat-widget-input textarea::placeholder {
  color: #9ca3af;
}

.chat-widget-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.chat-widget-send-btn:hover {
  transform: scale(1.1);
}

.chat-widget-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Loading */
.chat-widget-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  color: #6b7280;
  font-size: 14px;
}

.chat-widget-loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Empty state */
.chat-widget-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 20px;
  color: #6b7280;
}

.chat-widget-empty i {
  font-size: 32px;
}

.chat-widget-empty span {
  font-size: 14px;
}

/* Closed session notice */
.chat-widget-closed {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  font-size: 14px;
}

/* Responsive */
@media (max-width: 480px) {
  .chat-widget-window {
    width: calc(100% - 40px);
    height: calc(100vh - 120px);
    bottom: 80px;
    right: 20px;
  }
}