.chat-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--bs-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  z-index: 9999;
  transition: transform 0.2s, background-color 0.2s;
}
.chat-toggle:hover {
  transform: scale(1.1);
}

@keyframes chat-pulse {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  }
  50% {
    box-shadow: 0 4px 20px 8px rgba(59, 130, 246, 0.4);
  }
}
.chat-toggle-pulse {
  animation: chat-pulse 2s ease-in-out infinite;
}

.chat-tooltip {
  position: fixed;
  bottom: 6rem;
  right: 1.5rem;
  background: #fff;
  color: #1a1a1a;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  font-size: 0.9rem;
  z-index: 9999;
  cursor: pointer;
  animation: chatFadeIn 0.3s ease-out;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}
.chat-tooltip::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 20px;
  width: 12px;
  height: 12px;
  background: #fff;
  transform: rotate(45deg);
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.08);
}
.chat-tooltip-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: #999;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.chat-tooltip-close:hover {
  color: #333;
}

.chat-window {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  width: 380px;
  max-width: calc(100vw - 2rem);
  height: 500px;
  max-height: calc(100vh - 7rem);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  z-index: 9998;
  overflow: hidden;
  border: none;
  background: var(--bs-primary);
}

.chat-header {
  background-color: var(--bs-primary);
  color: #fff;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.chat-header h6 {
  margin: 0;
  font-weight: 600;
  font-size: 0.95rem;
}
.chat-header-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.15s;
  padding: 0;
  line-height: 1;
}
.chat-header-close:hover {
  opacity: 1;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: #fff;
}

.chat-message {
  max-width: 85%;
  padding: 0.625rem 0.875rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.45;
  word-wrap: break-word;
}
.chat-message-user {
  align-self: flex-end;
  background-color: var(--bs-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-message-assistant {
  align-self: flex-start;
  background-color: #f0f2f5;
  color: #1a1a1a;
  border-bottom-left-radius: 4px;
}

.chat-message-assistant p {
  margin: 0 0 0.5rem 0;
}
.chat-message-assistant p:last-child {
  margin-bottom: 0;
}
.chat-message-assistant ul,
.chat-message-assistant ol {
  margin: 0.25rem 0;
  padding-left: 1.25rem;
}
.chat-message-assistant code {
  background: rgba(0, 0, 0, 0.06);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.85em;
}
.chat-message-assistant a {
  color: var(--bs-primary);
  text-decoration: underline;
}
.chat-link-icon {
  font-size: 0.65em;
  margin-left: 2px;
  opacity: 0.7;
}

.chat-typing {
  align-self: flex-start;
  padding: 0.625rem 0.875rem;
  font-size: 0.85rem;
  color: #888;
  font-style: italic;
}

.chat-input-area {
  display: flex;
  padding: 0.75rem;
  border-top: 1px solid #e9ecef;
  gap: 0.5rem;
  flex-shrink: 0;
  background: #fff;
}
.chat-input {
  flex: 1;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}
.chat-input:focus {
  border-color: var(--bs-primary);
}
.chat-input:disabled {
  background-color: #f8f9fa;
  cursor: not-allowed;
}
.chat-send {
  background-color: var(--bs-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.875rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.15s;
  flex-shrink: 0;
}
.chat-send:hover {
  background-color: #2563eb;
}
.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-blocked {
  padding: 1rem 1.25rem;
  text-align: center;
  color: #1a1a1a;
  font-size: 0.95rem;
  font-weight: 500;
  border-top: 1px solid #e9ecef;
  flex-shrink: 0;
  background: #fff;
  border-radius: 0 0 16px 16px;
}
.chat-blocked a {
  color: var(--bs-primary);
  font-weight: 600;
  text-decoration: underline;
}

/* Fade in animation */
.chat-fade-enter {
  animation: chatFadeIn 0.2s ease-out;
}
@keyframes chatFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body.chat-open-mobile {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

@media (max-width: 480px) {
  .chat-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    z-index: 10000;
  }
  .chat-toggle-hidden {
    display: none !important;
  }
  .chat-blocked {
    border-radius: 0;
  }
}
