/* === CHAT PERSONALIZADO DE ADEJE AMIGABLE === */

/* Botón flotante del chat */
#chat-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 160px;
  height: auto;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 2147483646;
  padding: 0;
  transition: transform 0.2s ease;
}
#chat-launcher:hover {
  transform: scale(1.05);
}
#chat-launcher:active {
  transform: scale(0.95);
}
#chat-launcher img {
  width: 100%;
  height: auto;
  display: block;
  background: transparent;
  border-radius: 0;
  filter: drop-shadow(0 0 10px rgba(255,255,255,0.95))
          drop-shadow(0 0 18px rgba(255,255,255,0.65));
  -webkit-filter: drop-shadow(0 0 10px rgba(255,255,255,0.95))
                  drop-shadow(0 0 18px rgba(255,255,255,0.65));
}

/* Tooltip del botón */
#chat-tooltip {
  position: fixed;
  right: 180px;
  bottom: 50px;
  background: #fff9f6;
  color: #1c1c1c;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 15px;
  white-space: nowrap;
  z-index: 2147483645;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
#chat-tooltip.show {
  opacity: 1;
}
#chat-tooltip::after {
  content: '';
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 8px solid #fff9f6;
}

/* Ventana del chat */
#chat-window {
  position: fixed;
  right: 20px;
  bottom: 150px;
  width: 400px;
  height: 600px;
  background: #ffffff;
  border-radius: 0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  z-index: 2147483647;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
#chat-window.open {
  display: flex;
}

/* Header del chat */
#chat-header {
  background: #f54729;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
}
#chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 27px;
  object-fit: cover;
}
#chat-header-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  flex: 1;
}
#chat-header-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}
.chat-header-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s ease;
  padding: 0;
}
.chat-header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}
.chat-header-btn:active {
  background: rgba(255, 255, 255, 0.3);
}
.chat-header-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* Área de mensajes */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#chat-messages::-webkit-scrollbar {
  width: 6px;
}
#chat-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
}
#chat-messages::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}
#chat-messages::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Mensaje del bot */
.message-bot {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  max-width: 100%;
  align-self: flex-start;
  width: 100%;
}
.message-bot-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.message-bot-content {
  background: #1350d3;
  color: #fafafa;
  padding: 12px 16px;
  border-radius: 0;
  font-size: 16px;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.message-bot-content p {
  margin: 0 0 12px 0;
}
.message-bot-content p:last-child {
  margin-bottom: 0;
}
.message-bot-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 12px 0;
  display: block;
}
.message-bot-content a {
  color: #fff;
  text-decoration: underline;
}
.message-bot-content a:hover {
  color: #e0e0e0;
}
.message-bot-content ul,
.message-bot-content ol {
  margin: 8px 0;
  padding-left: 20px;
}
.message-bot-content li {
  margin: 4px 0;
}

/* Mensaje del usuario */
.message-user {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  max-width: 85%;
  align-self: flex-end;
  flex-direction: row-reverse;
}
.message-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.message-user-content {
  background: #00c227;
  color: #fafafa;
  padding: 12px 16px;
  border-radius: 0;
  font-size: 16px;
  line-height: 1.5;
  word-wrap: break-word;
}

/* Mensaje de bienvenida */
.message-welcome {
  background: #f5f5f5;
  color: #1e1e1f;
  padding: 16px;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 8px;
}

/* Indicador de escritura */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  align-self: flex-start;
}
.typing-indicator span {
  width: 8px;
  height: 8px;
  background: #1350d3;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}
.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-10px); }
}

/* Input del chat */
#chat-input-container {
  padding: 16px;
  background: #ffffff;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 8px;
  align-items: center;
}
#chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 9px;
  font-size: 16px;
  background: #ffffff;
  color: #1e1e1f;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 120px;
}
#chat-input:focus {
  border-color: #00c227;
}
#chat-input::placeholder {
  color: #999;
}
#chat-send {
  width: 48px;
  height: 48px;
  border-radius: 38px;
  background: #00c227;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease;
}
#chat-send:hover {
  background: #00a020;
}
#chat-send:disabled {
  background: #ccc;
  cursor: not-allowed;
}
#chat-send svg {
  width: 24px;
  height: 24px;
}

/* Footer del chat */
#chat-footer {
  padding: 8px 16px;
  text-align: center;
  font-size: 12px;
  color: #666;
  background: #ffffff;
  border-top: 1px solid #e0e0e0;
}
#chat-footer a {
  color: #00c227;
  text-decoration: none;
}
#chat-footer a:hover {
  text-decoration: underline;
}

/* Mensaje de error */
.message-error {
  background: #fee;
  color: #c33;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin: 8px 0;
}

/* Flecha para cerrar chat */
#chat-arrow {
  position: fixed;
  right: 20px;
  bottom: 150px;
  width: 48px;
  height: 48px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  z-index: 2147483648;
  transition: transform 0.2s ease;
}
#chat-arrow:hover {
  background: rgba(0,0,0,0.7);
}
#chat-arrow svg { width: 26px; height: 26px; display: block; }
#chat-arrow:active { transform: translateY(1px); }

/* Responsive */
@media (max-width: 480px) {
  #chat-window {
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
  #chat-arrow {
    right: 10px;
    bottom: 10px;
  }
}
