.chat-widget {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.chat-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--text-primary);
  color: var(--bg);
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
}

.chat-btn:hover {
  transform: scale(1.05);
  background: #fff;
}

.chat-btn svg {
  width: 28px;
  height: 28px;
  stroke: currentColor;
}

.chat-window {
  pointer-events: auto;
  position: absolute;
  bottom: 74px;
  right: 0;
  width: 350px;
  height: 480px;
  max-height: calc(100dvh - 110px);
  background: rgba(18, 18, 18, 0.92);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-out);
}

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

.chat-header {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 400;
}

.chat-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color var(--duration-fast), background var(--duration-fast);
}

.chat-close:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.1);
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-message {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: var(--text-xs);
  line-height: 1.6;
  word-wrap: break-word;
  white-space: normal;
}

.chat-message--user {
  align-self: flex-end;
  background: var(--text-primary);
  color: var(--bg);
  border-bottom-right-radius: 4px;
}

.chat-message--bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

/* Suggestion Chips */
.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
  margin-bottom: 4px;
  transition: opacity 0.3s ease, max-height 0.3s ease;
}

.chat-suggestions.is-hidden {
  display: none !important;
}

.chat-suggestion-chip {
  align-self: flex-start;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 0.72rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  text-align: left;
}

.chat-suggestion-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-highlight);
  color: var(--text-primary);
  transform: translateX(2px);
}

.chat-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
}

.chat-form {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 8px;
}

.chat-input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 9px 14px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  outline: none;
  transition: border-color var(--duration-fast);
}

.chat-input:focus {
  border-color: rgba(255, 255, 255, 0.3);
}

.chat-send {
  background: var(--text-primary);
  color: var(--bg);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--duration-fast), background var(--duration-fast);
}

.chat-send:hover {
  transform: scale(1.05);
  background: #fff;
}

.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Typing indicator */
.typing-indicator {
  display: none;
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border-bottom-left-radius: 4px;
  gap: 4px;
  align-items: center;
}

.typing-indicator.is-visible {
  display: flex;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

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

@media (max-width: 580px) {
  .chat-widget {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
    right: 16px;
    z-index: 1000;
  }
  
  .chat-btn {
    width: 52px;
    height: 52px;
  }

  .chat-window {
    position: fixed;
    top: auto;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 78px);
    right: 14px;
    left: 14px;
    width: auto;
    max-width: 420px;
    margin: 0 auto;
    height: min(60dvh, 460px);
    max-height: calc(100dvh - 130px);
    background: rgba(18, 18, 18, 0.88);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 20px;
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.65);
  }
}
.chat-link,
.chat-message--bot a {
  color: #38bdf8 !important;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
  transition: color 0.2s ease;
  word-break: break-all;
}

.chat-link:hover,
.chat-message--bot a:hover {
  color: #7dd3fc !important;
}
