/* FrameForgeX Chat Widget — "Alex" Product Specialist */

.chat-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Toggle button */
.chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 14px rgb(99 102 241 / 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgb(99 102 241 / 0.5);
}

.chat-toggle svg {
  width: 26px;
  height: 26px;
  transition: transform 0.2s ease;
}

.chat-widget.open .chat-toggle svg.icon-chat { display: none; }
.chat-widget:not(.open) .chat-toggle svg.icon-close { display: none; }

/* Chat window */
.chat-window {
  display: none;
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 380px;
  max-height: 520px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.15);
  overflow: hidden;
  flex-direction: column;
  animation: chatSlideUp 0.25s ease;
}

.chat-widget.open .chat-window {
  display: flex;
}

@keyframes chatSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Header */
.chat-header {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chat-header__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  flex-shrink: 0;
}

.chat-header__info h4 {
  font-size: 0.9375rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}

.chat-header__info span {
  font-size: 0.75rem;
  opacity: 0.8;
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 340px;
  min-height: 200px;
  scroll-behavior: smooth;
}

.chat-msg {
  max-width: 85%;
  padding: 0.625rem 0.875rem;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-msg--bot {
  background: #f1f5f9;
  color: #1e293b;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-msg--user {
  background: #6366f1;
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-msg--bot strong {
  color: #4f46e5;
}

.chat-msg--bot ul, .chat-msg--bot ol {
  margin: 0.25rem 0;
  padding-left: 1.25rem;
}

.chat-msg--bot li {
  margin-bottom: 0.125rem;
}

/* Typing indicator */
.chat-typing {
  display: none;
  align-self: flex-start;
  padding: 0.5rem 0.875rem;
  background: #f1f5f9;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  font-size: 0.8125rem;
  color: #94a3b8;
}

.chat-typing.visible {
  display: block;
}

.chat-typing span {
  animation: typingDot 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; }
  30% { opacity: 1; }
}

/* Input area */
.chat-input {
  display: flex;
  border-top: 1px solid #e2e8f0;
  padding: 0.75rem;
  gap: 0.5rem;
}

.chat-input input {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgb(99 102 241 / 0.1);
}

.chat-input button {
  width: 36px;
  height: 36px;
  border: none;
  background: #6366f1;
  color: white;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.chat-input button:hover {
  background: #4f46e5;
}

.chat-input button:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

/* Responsive */
@media (max-width: 480px) {
  .chat-window {
    width: calc(100vw - 2rem);
    right: -0.5rem;
    max-height: 70vh;
  }
}
