#chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 320px;
  height: 480px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  transform: translateY(calc(100% - 48px));
  transition: transform 0.3s ease;
  z-index: 9999;
}
#chat-widget.open {
  transform: translateY(0);
}
#chat-header {
  background: #007bff;
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px 12px 0 0;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}
#chat-header button {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
#chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-preform {
  padding: 16px;
  overflow-y: auto;
  background: #f8f9fa;
}
.chat-preform h4 {
  margin: 0 0 6px;
  font-size: 16px;
  color: #1f2937;
}
.chat-preform p {
  margin: 0 0 14px;
  color: #4b5563;
  font-size: 13px;
}
#chat-preform-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#chat-preform-form label {
  font-size: 12px;
  color: #374151;
  font-weight: 600;
}
#chat-preform-form input {
  border: 1px solid #ced4da;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  background: #fff;
}
#chat-preform-form input:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}
.chat-preform-error {
  min-height: 16px;
  color: #b91c1c;
  font-size: 12px;
}
#chat-start-btn {
  margin-top: 4px;
  background: #007bff;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
#chat-start-btn:hover {
  background: #0056b3;
}
#chat-messages {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  background: #f8f9fa;
}
.chat-message {
  margin-bottom: 12px;
  display: flex;
}
.chat-message.visitor {
  justify-content: flex-end;
}
.chat-message.ai,
.chat-message.human {
  justify-content: flex-start;
}
.chat-bubble {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 16px;
  word-wrap: break-word;
}
.chat-message.visitor .chat-bubble {
  background: #007bff;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-message.ai .chat-bubble,
.chat-message.human .chat-bubble {
  background: #e9ecef;
  color: #212529;
  border-bottom-left-radius: 4px;
}
#chat-input-area {
  padding: 12px;
  border-top: 1px solid #dee2e6;
  display: flex;
  gap: 8px;
}
#chat-input {
  flex: 1;
  border: 1px solid #ced4da;
  border-radius: 20px;
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
}
#chat-input:focus {
  border-color: #007bff;
}
#chat-send {
  background: #007bff;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
}
#chat-send:hover {
  background: #0056b3;
}
#chat-send:disabled {
  background: #6c757d;
  cursor: not-allowed;
}
#chat-attach {
  background: #6c757d;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 10px;
  margin-right: 8px;
  cursor: pointer;
  font-size: 16px;
}
#chat-attach:hover {
  background: #5a6268;
}
#chat-upload-preview {
  padding: 8px 12px;
  background: #f8f9fa;
  border-top: 1px solid #dee2e6;
}
.file-preview-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.file-preview-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #e9ecef;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
}
.file-preview-item button {
  background: none;
  border: none;
  color: #dc3545;
  cursor: pointer;
  padding: 0 4px;
}
.file-bubble {
  white-space: pre-wrap;
  word-break: break-word;
}
.typing-indicator {
  padding: 8px 12px;
  font-style: italic;
  color: #6c757d;
  font-size: 12px;
}
.chat-open-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #007bff;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,123,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  transition: transform 0.2s, background 0.2s;
}
.chat-open-btn:hover {
  background: #0056b3;
  transform: scale(1.05);
}
.chat-open-btn:active {
  transform: scale(0.95);
}
.chat-notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #dc3545;
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  line-height: 1;
}
