/*
  Graato Exports Website
  Chatbot widget styles — "Graato Assistant"
*/

/* ===== Floating Chat Button ===== */
.chatbot-toggle {
  align-items: center;
  background: var(--color-text);
  border: none;
  border-radius: var(--radius-full);
  bottom: 94px;
  box-shadow: 0 4px 16px rgba(28, 43, 58, 0.2);
  color: #ffffff;
  display: flex;
  font-size: 1.5rem;
  height: 54px;
  justify-content: center;
  padding: 0;
  position: fixed;
  right: 24px;
  transition: background 0.3s var(--ease), transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  width: 54px;
  z-index: 998;
  cursor: pointer;
}

.chatbot-toggle:hover {
  background: var(--color-accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(28, 43, 58, 0.3);
}

.chatbot-toggle.is-open {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

/* ===== Welcome Teaser ===== */
.chatbot-teaser {
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  bottom: 156px;
  box-shadow: var(--shadow-md);
  color: var(--color-text);
  font-size: 0.875rem;
  max-width: 220px;
  opacity: 0;
  padding: var(--space-sm) var(--space-md);
  position: fixed;
  right: 24px;
  transform: translateY(8px);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  z-index: 997;
  pointer-events: none;
}

.chatbot-teaser.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  cursor: pointer;
}

.chatbot-teaser::after {
  border: 8px solid transparent;
  border-top-color: #ffffff;
  bottom: -16px;
  content: '';
  position: absolute;
  right: 15px;
}

/* ===== Chat Panel ===== */
.chatbot-panel {
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  bottom: 24px;
  box-shadow: 0 20px 60px rgba(28, 43, 58, 0.2);
  display: flex;
  flex-direction: column;
  max-height: 600px;
  opacity: 0;
  position: fixed;
  right: 24px;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  width: 380px;
  z-index: 999;
  pointer-events: none;
  overflow: hidden;
}

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

/* ===== Panel Header ===== */
.chatbot-header {
  align-items: center;
  background: var(--color-text);
  color: #ffffff;
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  flex-shrink: 0;
}

.chatbot-header__avatar {
  border-radius: var(--radius-full);
  flex-shrink: 0;
  filter: brightness(0) invert(1);
  height: 36px;
  width: 36px;
  object-fit: contain;
}

.chatbot-header__info {
  flex: 1;
  min-width: 0;
}

.chatbot-header__title {
  color: #ffffff;
  font-family: var(--font-sub);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
}

.chatbot-header__status {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.75rem;
  line-height: 1.35;
  margin: 0;
}

.chatbot-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-size: 1.25rem;
  padding: 4px;
  flex-shrink: 0;
  transition: color 0.2s ease;
}

/* ===== Multilingual Greeting ===== */
.chatbot-greeting {
  background: linear-gradient(135deg, rgba(30, 95, 142, 0.08), rgba(85, 96, 107, 0.08));
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  flex-shrink: 0;
  font-family: var(--font-sub);
  font-size: 0.86rem;
  font-weight: 700;
  min-height: 46px;
  overflow: hidden;
  padding: var(--space-sm) var(--space-lg);
}

.chatbot-greeting span {
  animation: chatbotGreetingIn 0.45s var(--ease);
  display: block;
  line-height: 1.45;
}

.chatbot-greeting span.is-changing {
  animation: chatbotGreetingIn 0.45s var(--ease);
}

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

.chatbot-close:hover {
  color: #ffffff;
}

/* ===== Messages Area ===== */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-height: 280px;
  max-height: 400px;
}

.chatbot-messages::-webkit-scrollbar {
  width: 5px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

.chatbot-message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
}

.chatbot-message--bot {
  align-self: flex-start;
}

.chatbot-message--user {
  align-self: flex-end;
}

.chatbot-message__bubble {
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  line-height: 1.5;
  padding: var(--space-sm) var(--space-md);
  word-wrap: break-word;
}

.chatbot-message--bot .chatbot-message__bubble {
  background: var(--color-section-alt);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: var(--radius-sm);
  color: var(--color-text);
}

.chatbot-message--user .chatbot-message__bubble {
  background: var(--color-cta);
  border-bottom-right-radius: var(--radius-sm);
  color: #ffffff;
}

.chatbot-message__time {
  color: var(--color-muted);
  font-size: 0.7rem;
  margin-top: 4px;
  padding: 0 4px;
}

.chatbot-message--user .chatbot-message__time {
  text-align: right;
}

/* Typing indicator */
.chatbot-typing {
  align-self: flex-start;
  background: var(--color-section-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-sm);
  display: flex;
  gap: 4px;
  padding: var(--space-sm) var(--space-md);
}

.chatbot-typing span {
  animation: chatbotTyping 1.4s infinite;
  background: var(--color-muted);
  border-radius: var(--radius-full);
  display: block;
  height: 7px;
  width: 7px;
}

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

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

@keyframes chatbotTyping {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-5px); }
}

/* ===== Input Area ===== */
.chatbot-actions {
  align-items: center;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
  padding: var(--space-sm) var(--space-lg) 0;
}

.chatbot-end {
  background: transparent;
  border: none;
  color: var(--color-muted);
  cursor: pointer;
  font-family: var(--font-sub);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0;
  text-transform: uppercase;
  transition: color 0.2s ease;
}

.chatbot-end:hover,
.chatbot-end:focus {
  color: var(--color-accent);
  outline: none;
}

.chatbot-end:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.chatbot-input-area {
  align-items: flex-end;
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  flex-shrink: 0;
}

.chatbot-input {
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  flex: 1;
  font-family: var(--font-body);
  font-size: 0.9rem;
  max-height: 100px;
  min-height: 44px;
  padding: 10px var(--space-md);
  resize: none;
  width: 100%;
}

.chatbot-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(30, 95, 142, 0.15);
  outline: none;
}

.chatbot-send {
  align-items: center;
  background: var(--color-cta);
  border: none;
  border-radius: var(--radius-md);
  color: #ffffff;
  display: flex;
  font-size: 1.1rem;
  height: 44px;
  justify-content: center;
  transition: background 0.2s ease;
  width: 44px;
  flex-shrink: 0;
  cursor: pointer;
}

.chatbot-send:hover {
  background: var(--color-cta-hover);
}

.chatbot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* WhatsApp handoff */
.chatbot-whatsapp-handoff {
  background: transparent;
  border: none;
  color: var(--color-whatsapp);
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sub);
  font-size: 0.76rem;
  font-weight: 700;
  justify-content: center;
  padding: 0;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color 0.2s ease;
}

.chatbot-whatsapp-handoff:hover {
  color: var(--color-whatsapp-hover);
}

/* Error message */
.chatbot-error {
  background: rgba(192, 57, 43, 0.08);
  border: 1px solid rgba(192, 57, 43, 0.2);
  border-radius: var(--radius-lg);
  color: var(--color-error);
  font-size: 0.85rem;
  padding: var(--space-md);
  text-align: center;
}

.chatbot-error a {
  color: var(--color-accent);
  font-weight: 700;
}

/* Honeypot (hidden spam trap) */
.chatbot-honeypot {
  position: absolute;
  left: -9999px;
  opacity: 0;
}

/* ===== Mobile ===== */
@media (max-width: 767px) {
  .chatbot-toggle {
    bottom: 84px;
    right: 18px;
    height: 50px;
    width: 50px;
    font-size: 1.3rem;
  }

  .chatbot-teaser {
    bottom: 142px;
    right: 18px;
    max-width: 180px;
    font-size: 0.8rem;
  }

  .chatbot-panel {
    border-radius: 0;
    bottom: 0;
    height: 100vh;
    left: 0;
    max-height: 100vh;
    right: 0;
    width: 100%;
    transform: translateY(100%);
    transform-origin: bottom;
  }

  .chatbot-panel.is-open {
    transform: translateY(0);
  }

  .chatbot-header {
    padding: var(--space-sm) var(--space-md);
    gap: var(--space-sm);
  }

  .chatbot-header__avatar {
    height: 30px;
    width: 30px;
  }

  .chatbot-header__title {
    font-size: 0.85rem;
  }

  .chatbot-header__status {
    font-size: 0.68rem;
    line-height: 1.3;
  }

  .chatbot-close {
    font-size: 1.1rem;
  }

  .chatbot-greeting {
    padding: var(--space-sm) var(--space-md);
  }

  .chatbot-messages {
    max-height: none;
    flex: 1;
    padding: var(--space-md);
  }

  .chatbot-actions {
    padding: var(--space-sm) var(--space-md) 0;
  }

  .chatbot-input-area {
    padding: var(--space-sm) var(--space-md);
  }

  .chatbot-message__bubble {
    font-size: 0.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chatbot-toggle,
  .chatbot-panel,
  .chatbot-teaser,
  .chatbot-greeting span,
  .chatbot-typing span {
    transition: none !important;
    animation: none !important;
  }
}
