/* ==========================================
   Malema Tawas, Lda - AI Assistant Widget
   ========================================== */

/* Floating Chat Button */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(37, 99, 235, 0.4);
  z-index: 9999;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: chat-fab-appear 0.5s ease-out;
}

.chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 32px rgba(37, 99, 235, 0.5);
}

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

.chat-fab .fab-icon {
  transition: transform 0.3s ease;
}

.chat-fab.active .fab-icon {
  transform: rotate(45deg);
}

.chat-fab .fab-notification {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  background: #ef4444;
  border-radius: 50%;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border: 2px solid #fff;
  animation: chat-pulse 2s infinite;
}

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

@keyframes chat-fab-appear {
  from { opacity: 0; transform: scale(0); }
  to { opacity: 1; transform: scale(1); }
}

/* Chat Window */
.chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 140px);
  background: var(--card-bg, #ffffff);
  border-radius: 20px;
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.2);
  z-index: 9998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: chat-window-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid var(--border, #e5e7eb);
  transform-origin: bottom right;
}

.chat-window.open {
  display: flex;
}

@keyframes chat-window-in {
  from { opacity: 0; transform: scale(0.85) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  flex-shrink: 0;
}

.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

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

.chat-header-info h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  color: #fff;
  line-height: 1.3;
}

.chat-header-info p {
  font-size: 12px;
  margin: 0;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-header-info .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
  animation: chat-status-blink 2s infinite;
}

@keyframes chat-status-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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

.chat-header-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Chat Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg, #f8fafc);
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border, #d1d5db);
  border-radius: 4px;
}

/* Message Bubbles */
.chat-msg {
  max-width: 85%;
  padding: 10px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  animation: chat-msg-in 0.3s ease-out;
  position: relative;
}

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

.chat-msg.bot {
  align-self: flex-start;
  background: var(--card-bg, #ffffff);
  color: var(--text, #1f2937);
  border: 1px solid var(--border, #e5e7eb);
  border-bottom-left-radius: 4px;
}

.chat-msg.bot .msg-sender {
  font-size: 11px;
  font-weight: 600;
  color: #2563eb;
  margin-bottom: 4px;
  display: block;
}

.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg .msg-time {
  font-size: 10px;
  opacity: 0.7;
  margin-top: 4px;
  display: block;
  text-align: right;
}

/* Typing Indicator */
.chat-typing {
  align-self: flex-start;
  display: none;
  align-items: center;
  gap: 4px;
  padding: 12px 20px;
  background: var(--card-bg, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.chat-typing.active {
  display: flex;
}

.chat-typing span {
  width: 8px;
  height: 8px;
  background: var(--text-muted, #9ca3af);
  border-radius: 50%;
  animation: chat-typing-bounce 1.4s infinite;
}

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

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

/* Quick Reply Buttons */
.chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 20px 8px;
  background: var(--bg, #f8fafc);
  flex-shrink: 0;
}

.chat-quick-reply {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border, #e5e7eb);
  background: var(--card-bg, #ffffff);
  color: var(--text, #1f2937);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}

.chat-quick-reply:hover {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  border-color: transparent;
  transform: translateY(-1px);
}

/* Chat Input */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 16px;
  background: var(--card-bg, #ffffff);
  border-top: 1px solid var(--border, #e5e7eb);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  padding: 10px 16px;
  border-radius: 24px;
  border: 1px solid var(--border, #e5e7eb);
  background: var(--bg, #f8fafc);
  color: var(--text, #1f2937);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}

.chat-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.chat-input::placeholder {
  color: var(--text-muted, #9ca3af);
}

.chat-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

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

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

/* WhatsApp Float Button (inside chat) */
.chat-whatsapp-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: #25d366;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  margin-top: 12px;
  font-family: inherit;
}

.chat-whatsapp-btn:hover {
  background: #1ebe5d;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.chat-whatsapp-btn svg {
  flex-shrink: 0;
}

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

  .chat-fab {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
    font-size: 24px;
  }

  .chat-messages {
    padding: 12px 16px;
  }

  .chat-input-area {
    padding: 8px 12px 12px;
  }
}

/* Dark Mode Support */
[data-theme="dark"] .chat-window {
  border-color: var(--border, #374151);
}

[data-theme="dark"] .chat-messages {
  background: var(--bg, #111827);
}

[data-theme="dark"] .chat-msg.bot {
  background: var(--card-bg, #1f2937);
  color: var(--text, #f3f4f6);
  border-color: var(--border, #374151);
}

[data-theme="dark"] .chat-quick-replies {
  background: var(--bg, #111827);
}

[data-theme="dark"] .chat-quick-reply {
  background: var(--card-bg, #1f2937);
  color: var(--text, #f3f4f6);
  border-color: var(--border, #374151);
}

[data-theme="dark"] .chat-input-area {
  background: var(--card-bg, #1f2937);
  border-top-color: var(--border, #374151);
}

[data-theme="dark"] .chat-input {
  background: var(--bg, #111827);
  color: var(--text, #f3f4f6);
  border-color: var(--border, #374151);
}

[data-theme="dark"] .chat-typing {
  background: var(--card-bg, #1f2937);
  border-color: var(--border, #374151);
}
