/* Chatbot Drawer (lado direito) - Suporte IA */

/* Floating Button (pill style) */
.chatbot-button {
  position: fixed;
  bottom: 24px;
  right: 0;
  z-index: 1100;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 6px 0 0 6px;
  background: var(--md-primary-fg, linear-gradient(135deg, #2196F3, #1976D2));
  color: var(--md-primary-contrast, #fff);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  box-shadow: -2px 4px 8px rgba(0, 0, 0, 0.1);
  transition: bottom 0.32s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.18s ease;
  white-space: nowrap;
}

.chatbot-button:hover {
  box-shadow: -4px 6px 16px rgba(0, 0, 0, 0.15);
}

.chatbot-button .chatbot-icon {
  font-size: 16px;
  line-height: 1;
}

/* O botão permanece na posição inferior quando o painel abre (sem gap).
   Posicionamento controlado por `.chatbot-button` (bottom/right). */

/* Overlay semicircular leve */
.chatbot-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.12);
  z-index: 1090;
  transition: opacity 0.18s ease;
}

.chatbot-overlay.active {
  display: block;
}

/* Drawer (painel lateral direito) */
.chatbot-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 85vh;
  max-height: 90vh;
  width: 800px;
  max-width: 95vw;
  transform: translateX(100%);
  background: var(--md-surface, #fff);
  box-shadow: -12px 0 30px rgba(22, 27, 29, 0.12);
  z-index: 1101;
  display: flex;
  flex-direction: column;
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform;
  overflow: hidden;
}

.chatbot-overlay.active .chatbot-drawer {
  transform: translateX(0);
}

/* Ensure the aside element for the drawer fills vertical space when requested */
aside#chatbot-drawer {
  height: 100%;
}

/* Header fixo */
.chatbot-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
  background: inherit;
}

.chatbot-drawer-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--md-primary-text, #222);
}

.chatbot-drawer-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: rgba(0, 0, 0, 0.7);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.2s ease;
}

.chatbot-drawer-close:hover {
  background: rgba(0, 0, 0, 0.04);
}

/* Body contendo iframe */
.chatbot-drawer-body {
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  background: var(--md-surface, #fff);
  overflow: hidden;
}

.chatbot-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* Loading */
.chatbot-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  color: rgba(0, 0, 0, 0.6);
  width: 100%;
  height: 100%;
}

.chatbot-loading .spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(0, 0, 0, 0.08);
  border-top-color: var(--md-primary-fg-color, #1976D2);
  border-radius: 50%;
  animation: chatspin 0.8s linear infinite;
}

@keyframes chatspin {
  to {
    transform: rotate(360deg);
  }
}

/* Fallback */
.chatbot-fallback {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  height: 100%;
}

.chatbot-fallback-link {
  background: var(--md-primary-fg, #1976D2);
  color: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  display: inline-block;
}

.chatbot-fallback-link:hover {
  opacity: 0.9;
  text-decoration: none;
}

/* Body scroll lock */
body.chatbot-drawer-open {
  overflow: hidden;
}

/* Responsivo */
@media (max-width: 1024px) {
  .chatbot-drawer {
    width: 90vw;
    max-width: 90vw;
  }
}

@media (max-width: 768px) {
  .chatbot-button {
    right: 0;
    bottom: 16px;
    padding: 10px 12px;
    font-size: 12px;
    border-radius: 0;
  }

  .chatbot-button .chatbot-icon {
    font-size: 14px;
  }

  .chatbot-button .chatbot-text {
    display: none;
  }

  .chatbot-drawer {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
  }

  .chatbot-drawer-header {
    padding: 14px 16px;
  }

  .chatbot-drawer-title {
    font-size: 15px;
  }

  .chatbot-overlay.active ~ .chatbot-button,
  .chatbot-overlay.active + .chatbot-button {
    bottom: 100vh;
  }
}

@media (max-width: 480px) {
  .chatbot-button {
    padding: 8px 10px;
    font-size: 12px;
  }

  .chatbot-button .chatbot-icon {
    font-size: 14px;
  }

  .chatbot-button .chatbot-text {
    display: none;
  }
}
