/* ============================================================================
   CHAT BUBBLE
   ============================================================================ */

/* Floating trigger button */
.chat-bubble-trigger {
  position: fixed;
  inset-block-end: 1.5rem;
  inset-inline-end: 1.5rem;
  z-index: 100;
  inline-size: 3.5rem;
  block-size: 3.5rem;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: light-dark(#fff, #1a1a1a);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px light-dark(rgba(184, 134, 11, 0.3), rgba(232, 197, 95, 0.3));
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.3s;
}

.chat-bubble-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px light-dark(rgba(184, 134, 11, 0.4), rgba(232, 197, 95, 0.4));
}

.chat-bubble-trigger:active {
  transform: scale(0.95);
}

.chat-bubble-trigger svg {
  inline-size: 1.5rem;
  block-size: 1.5rem;
  transition: transform 0.3s;
}

/* Chat window */
.chat-window {
  position: fixed;
  inset-block-end: 6rem;
  inset-inline-end: 1.5rem;
  z-index: 100;
  inline-size: min(24rem, calc(100vw - 3rem));
  block-size: 32rem;
  max-block-size: calc(100vh - 8rem);
  border-radius: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px light-dark(rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.4));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(1rem) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  background: var(--accent);
  color: light-dark(#fff, #1a1a1a);
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.chat-avatar {
  inline-size: 2rem;
  block-size: 2rem;
  border-radius: 50%;
  background: light-dark(rgba(255, 255, 255, 0.25), rgba(0, 0, 0, 0.2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8125rem;
}

.chat-header-name {
  font-weight: 600;
  font-size: 0.9375rem;
}

.chat-header-status {
  font-size: 0.75rem;
  opacity: 0.8;
}

.chat-close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.chat-close:hover {
  background: light-dark(rgba(255, 255, 255, 0.2), rgba(0, 0, 0, 0.2));
}

.chat-close svg {
  inline-size: 1.125rem;
  block-size: 1.125rem;
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-messages::-webkit-scrollbar {
  inline-size: 0.375rem;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 0.25rem;
}

/* Message bubbles */
.chat-msg {
  max-inline-size: 80%;
  padding: 0.625rem 0.875rem;
  border-radius: 0.875rem;
  font-size: 0.875rem;
  line-height: 1.5;
  animation: chatMsgIn 0.3s ease-out;
}

@keyframes chatMsgIn {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-msg.bot {
  align-self: flex-start;
  background: var(--background-color);
  color: var(--primary);
  border: 1px solid var(--border);
  border-start-start-radius: 0.25rem;
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: light-dark(#fff, #1a1a1a);
  border-start-end-radius: 0.25rem;
}

.chat-time {
  font-size: 0.6875rem;
  color: var(--secondary);
  margin-block-start: 0.25rem;
  opacity: 0.7;
}

/* Typing indicator */
.chat-typing {
  display: flex;
  gap: 0.25rem;
  padding: 0.625rem 0.875rem;
  align-self: flex-start;
  background: var(--background-color);
  border: 1px solid var(--border);
  border-radius: 0.875rem;
  border-start-start-radius: 0.25rem;
}

.chat-typing span {
  inline-size: 0.375rem;
  block-size: 0.375rem;
  border-radius: 50%;
  background: var(--secondary);
  animation: chatBounce 1.2s infinite ease-in-out;
}

.chat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.chat-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes chatBounce {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  40% {
    transform: translateY(-0.375rem);
    opacity: 1;
  }
}

/* Input area */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.chat-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--background-color);
  color: var(--primary);
  outline: none;
  transition: border-color 0.2s;
}

.chat-input::placeholder {
  color: var(--secondary);
  opacity: 0.7;
}

.chat-input:focus {
  border-color: var(--accent);
}

.chat-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-send {
  inline-size: 2.25rem;
  block-size: 2.25rem;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: light-dark(#fff, #1a1a1a);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.2s;
}

.chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chat-send:hover {
  opacity: 0.85;
}

.chat-send:active {
  transform: scale(0.92);
}

.chat-send svg {
  inline-size: 1rem;
  block-size: 1rem;
}

/* Responsive */
@media (max-width: 480px) {
  .chat-window {
    inset-block-end: 0;
    inset-inline-end: 0;
    inset-block-start: 0;
    inset-inline-start: 0;
    inline-size: 100%;
    block-size: 100%;
    max-block-size: 100%;
    border-radius: 0;
  }
}
