/**
 * EFOP Chatbot - Estilos do Widget
 * Standalone - sem dependencia de tema ou framework CSS
 */

/* Reset scoped */
.efop-chatbot-widget,
.efop-chatbot-widget *,
.efop-chatbot-widget *::before,
.efop-chatbot-widget *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Container */
.efop-chatbot-widget {
  position: fixed;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.efop-chatbot-right {
  bottom: 24px;
  right: 24px;
}

.efop-chatbot-left {
  bottom: 24px;
  left: 24px;
}

/* Botao Flutuante */
.efop-chatbot-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transition: all 0.3s ease;
  outline: none;
}

.efop-chatbot-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.efop-chatbot-btn-active {
  background-color: #4b5563 !important;
}

.efop-chatbot-btn-active:hover {
  background-color: #374151 !important;
}

/* Pulse */
.efop-chatbot-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  opacity: 0.2;
  animation: efop-pulse 2s infinite;
}

.efop-chatbot-btn-active .efop-chatbot-pulse {
  display: none;
}

@keyframes efop-pulse {
  0% { transform: scale(1); opacity: 0.2; }
  50% { transform: scale(1.15); opacity: 0; }
  100% { transform: scale(1); opacity: 0; }
}

/* Badge */
.efop-chatbot-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: efop-badge-pulse 2s infinite;
}

@keyframes efop-badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* Janela do Chat */
.efop-chatbot-window {
  position: absolute;
  bottom: 70px;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 100px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
  border: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: efop-slide-up 0.3s ease;
}

.efop-chatbot-right .efop-chatbot-window {
  right: 0;
}

.efop-chatbot-left .efop-chatbot-window {
  left: 0;
}

@keyframes efop-slide-up {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.efop-chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  color: #fff;
  flex-shrink: 0;
}

.efop-chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.efop-chatbot-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.3);
}

.efop-chatbot-avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.efop-chatbot-header-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}

.efop-chatbot-header-status {
  font-size: 11px;
  opacity: 0.7;
}

.efop-chatbot-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.efop-chatbot-header-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.efop-chatbot-header-btn:hover {
  background: rgba(255,255,255,0.2);
}

/* Area de Mensagens */
.efop-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: #d1d5db transparent;
}

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

.efop-chatbot-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 9999px;
}

/* Mensagens */
.efop-chatbot-msg-wrapper {
  display: flex;
}

.efop-chatbot-msg-wrapper-user {
  justify-content: flex-end;
}

.efop-chatbot-msg-wrapper-bot {
  justify-content: flex-start;
}

.efop-chatbot-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
}

.efop-chatbot-msg-user {
  color: #fff;
  border-bottom-right-radius: 4px;
}

.efop-chatbot-msg-bot {
  background: #fff;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.efop-chatbot-msg-error {
  background: #fef2f2 !important;
  color: #991b1b !important;
  border-color: #fecaca !important;
}

.efop-chatbot-msg-text {
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* Links clicaveis nas mensagens do bot */
.efop-chatbot-link {
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
  transition: opacity 0.15s;
}

.efop-chatbot-link:hover {
  opacity: 0.8;
}

/* Link no balao do bot (fundo branco) → cor azul */
.efop-chatbot-msg-bot .efop-chatbot-link {
  color: #2563eb;
}

/* Link no balao do usuario (fundo colorido) → cor branca */
.efop-chatbot-msg-user .efop-chatbot-link {
  color: #ffffff;
}

.efop-chatbot-msg-time {
  display: block;
  font-size: 10px;
  opacity: 0.5;
  margin-top: 4px;
}

/* Typing Indicator */
.efop-chatbot-typing {
  display: flex;
  gap: 5px;
  padding: 4px 0;
}

.efop-chatbot-typing span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
  animation: efop-bounce 1.4s infinite ease-in-out both;
}

.efop-chatbot-typing span:nth-child(1) { animation-delay: -0.32s; }
.efop-chatbot-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes efop-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Footer / Input */
.efop-chatbot-footer {
  flex-shrink: 0;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid #f3f4f6;
}

.efop-chatbot-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.efop-chatbot-input {
  flex: 1;
  resize: none;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.4;
  color: #1f2937;
  background: #fff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  max-height: 80px;
}

.efop-chatbot-input::placeholder {
  color: #9ca3af;
}

.efop-chatbot-send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.efop-chatbot-send:disabled {
  background: #d1d5db !important;
  cursor: not-allowed;
}

/* Disclaimer */
.efop-chatbot-disclaimer {
  font-size: 10px;
  color: #9ca3af;
  text-align: center;
  margin-top: 6px;
}

/* Mobile */
@media (max-width: 480px) {
  .efop-chatbot-window {
    width: calc(100vw - 16px);
    height: calc(100vh - 90px);
    bottom: 66px;
    border-radius: 12px;
  }

  .efop-chatbot-right .efop-chatbot-window {
    right: -16px;
  }

  .efop-chatbot-left .efop-chatbot-window {
    left: -16px;
  }

  .efop-chatbot-right,
  .efop-chatbot-left {
    bottom: 16px;
  }
}
