/* ========================
   CHATBOT WIDGET
   ======================== */

/* Toggle button */
.chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #0a1628;
  color: #3b82f6;
  border: 1px solid rgba(59,130,246,0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  transition: all 0.3s ease;
}

.chat-toggle:hover {
  transform: scale(1.15) rotate(-8deg);
  border-color: rgba(59,130,246,0.7);
  box-shadow: 0 8px 32px rgba(59,130,246,0.35), 0 0 16px rgba(59,130,246,0.15);
  color: #93bbfc;
  animation: none;
}

/* Radiating rings */
.chat-toggle:not(.is-open)::before,
.chat-toggle:not(.is-open)::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid rgba(59,130,246,0.3);
  animation: chatRadiate 3s ease-out infinite;
}

.chat-toggle:not(.is-open)::after {
  animation-delay: 1.5s;
}

@keyframes chatRadiate {
  0% { inset: -4px; opacity: 0.6; border-color: rgba(59,130,246,0.4); }
  100% { inset: -18px; opacity: 0; border-color: rgba(59,130,246,0); }
}

/* Subtle bounce */
.chat-toggle:not(.is-open) {
  animation: chatBounce 4s ease-in-out infinite;
}

@keyframes chatBounce {
  0%, 100% { transform: translateY(0); }
  15% { transform: translateY(-4px); }
  30% { transform: translateY(0); }
  45% { transform: translateY(-2px); }
  60% { transform: translateY(0); }
}

/* Border pulse glow */
.chat-toggle:not(.is-open) {
  animation: chatBounce 4s ease-in-out infinite, chatBorderPulse 3s ease-in-out infinite;
}

@keyframes chatBorderPulse {
  0%, 100% { border-color: rgba(59,130,246,0.2); }
  50% { border-color: rgba(59,130,246,0.5); box-shadow: 0 0 16px rgba(59,130,246,0.15), 0 4px 20px rgba(0,0,0,0.3); }
}

/* Chat bubble hover message */
.chat-toggle__bubble {
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(6px);
  background: #ffffff;
  color: #0f172a;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 12px 12px 4px 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.12);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  line-height: 1.3;
}

.chat-toggle__bubble::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-left-color: #ffffff;
}

.chat-toggle:not(.is-open):hover .chat-toggle__bubble {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.chat-toggle.is-open {
  background: #0a1628;
  border-color: rgba(255,255,255,0.15);
  color: #94a3b8;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.chat-toggle.is-open:hover {
  border-color: rgba(255,255,255,0.3);
  color: #ffffff;
}

/* Chat window */
.chat-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: 998;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 520px;
  max-height: calc(100vh - 140px);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Header */
.chat-window__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, #0a1628, #1a3a5c);
  color: #ffffff;
  flex-shrink: 0;
}

.chat-window__header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-window__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #60a5fa;
}

.chat-window__name {
  font-size: 15px;
  font-weight: 700;
}

.chat-window__status {
  font-size: 12px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chat-window__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  display: inline-block;
  animation: onlinePulse 2s ease-in-out infinite;
}

@keyframes onlinePulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  50% { opacity: 0.7; box-shadow: 0 0 6px 2px rgba(16, 185, 129, 0.3); }
}

.chat-window__minimize {
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}

.chat-window__minimize:hover {
  color: #ffffff;
}

/* Pre-chat form */
/* Messages */
.chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px;
  overflow-y: auto;
  scrollbar-width: none;
  background: #f8fafc;
}

.chat-messages::-webkit-scrollbar {
  display: none;
}

/* Message bubbles */
.chat-msg {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: chatMsgIn 0.3s ease;
}

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

.chat-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg--bot {
  align-self: flex-start;
}

.chat-msg__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  color: #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.chat-msg__bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg--user .chat-msg__bubble {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.chat-msg--bot .chat-msg__bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}

/* Typing dots */
.chat-typing-dots {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.chat-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: chatDotBounce 1.4s ease-in-out infinite;
}

.chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatDotBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input area */
.chat-input {
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
  flex-shrink: 0;
}

.chat-input form {
  display: flex;
  gap: 8px;
}

.chat-input input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  color: #1e293b;
  background: #f8fafc;
  transition: all 0.2s;
}

.chat-input input:focus {
  outline: none;
  border-color: #3b82f6;
  background: #ffffff;
}

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

.chat-input__send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.chat-input__send:hover {
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .chat-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: calc(100vh - 60px);
    max-height: none;
    border-radius: 16px 16px 0 0;
  }

  .chat-toggle {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
  }
}
