/* ==========================================
   Avelyx Studio — Chat Widget
   ========================================== */

/* ---- Chat Bubble (closed state) ---- */
.chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gradient, linear-gradient(135deg, #0078D4 0%, #2f9ee0 50%, #5dade2 100%));
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 120, 212, 0.35);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  opacity: 0;
  transform: scale(0) translateY(20px);
  animation: chat-bubble-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 3s forwards;
}

.chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0, 120, 212, 0.45);
}

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

.chat-bubble svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-bubble__pulse {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: #16a34a;
  border-radius: 50%;
  border: 2.5px solid #fff;
  animation: chat-pulse 2s ease-in-out infinite;
}

.chat-bubble--hidden {
  opacity: 0 !important;
  pointer-events: none;
  transform: scale(0) !important;
  animation: none;
}

@keyframes chat-bubble-in {
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes chat-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

/* ---- Chat Panel ---- */
.chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 380px;
  max-height: 520px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* ---- Header ---- */
.chat-panel__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--gradient, linear-gradient(135deg, #0078D4 0%, #2f9ee0 50%, #5dade2 100%));
  color: #fff;
  flex-shrink: 0;
}

.chat-panel__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.chat-panel__info {
  flex: 1;
  min-width: 0;
}

.chat-panel__name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
}

.chat-panel__status {
  font-size: 0.72rem;
  opacity: 0.85;
}

.chat-panel__close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.chat-panel__close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ---- Messages ---- */
.chat-panel__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.84rem;
  line-height: 1.55;
  word-wrap: break-word;
  animation: chat-msg-in 0.25s ease-out;
}

.chat-msg--bot {
  align-self: flex-start;
  background: #f0f4f9;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}

.chat-msg--user {
  align-self: flex-end;
  background: var(--primary, #0078D4);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg__text {
  white-space: pre-line;
}

@keyframes chat-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Action Buttons (inside messages) ---- */
.chat-msg__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.chat-msg__action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: #fff;
  color: var(--primary, #0078D4);
  border: 1.5px solid var(--primary, #0078D4);
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.chat-msg__action:hover {
  background: var(--primary, #0078D4);
  color: #fff;
}

/* ---- Quick Chips ---- */
.chat-panel__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 12px;
  flex-shrink: 0;
}

.chat-chip {
  padding: 6px 14px;
  background: #f0f4f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  font-size: 0.76rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.chat-chip:hover {
  background: var(--primary, #0078D4);
  color: #fff;
  border-color: var(--primary, #0078D4);
}

/* ---- Input ---- */
.chat-panel__input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e8ecf1;
  flex-shrink: 0;
}

.chat-panel__input input {
  flex: 1;
  border: 1.5px solid #e2e8f0;
  border-radius: 22px;
  padding: 9px 16px;
  font-size: 0.84rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.2s;
  color: #1e293b;
}

.chat-panel__input input::placeholder {
  color: #94a3b8;
}

.chat-panel__input input:focus {
  border-color: var(--primary, #0078D4);
}

.chat-panel__send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary, #0078D4);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
}

.chat-panel__send:hover {
  background: #005fa3;
}

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

.chat-panel__send svg {
  width: 18px;
  height: 18px;
}

/* ---- Typing indicator ---- */
.chat-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 10px 14px;
  background: #f0f4f9;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  animation: chat-msg-in 0.25s ease-out;
}

.chat-typing__dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: chat-typing-bounce 1.2s ease-in-out infinite;
}

.chat-typing__dot:nth-child(2) { animation-delay: 0.15s; }
.chat-typing__dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes chat-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* ---- Scrollbar ---- */
.chat-panel__messages::-webkit-scrollbar {
  width: 5px;
}

.chat-panel__messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-panel__messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 10px;
}

/* ---- Mobile ---- */
@media (max-width: 480px) {
  .chat-panel {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 120px);
    bottom: 8px;
    right: 8px;
  }

  .chat-bubble {
    bottom: 16px;
    right: 16px;
    width: 50px;
    height: 50px;
  }

  .chat-bubble svg {
    width: 22px;
    height: 22px;
  }
}
