/* ==========================================================================
   ÓPTICA DONNATELLA — ASISTENTE VIRTUAL Y CHATBOT DE PREGUNTAS FRECUENTES
   ========================================================================== */

:root {
  --bot-primary: #1B1816;
  --bot-accent: #C69255;
  --bot-red: #A61C1C;
  --bot-bg: #FFFFFF;
  --bot-bubble-user: #1B1816;
  --bot-bubble-bot: #F4EFEA;
  --bot-text: #1B1816;
  --bot-muted: #7A7269;
  --bot-border: #EBE5DF;
  --bot-radius: 18px;
  --bot-shadow: 0 16px 40px -10px rgba(27,24,22,0.22), 0 0 1px 1px rgba(27,24,22,0.06);
}

/* --- BOTÓN FLOTANTE DISPARADOR (LAUNCHER) --- */
.chatbot-launcher-container {
  position: fixed;
  right: 22px;
  bottom: 92px; /* Justo arriba del botón de WhatsApp */
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Jost', sans-serif;
}

.chatbot-tooltip {
  background: #1B1816;
  color: #FAF8F5;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateX(10px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(255,255,255,0.08);
}

.chatbot-tooltip.show {
  opacity: 1;
  transform: translateX(0);
}

.chatbot-launcher {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1B1816 0%, #2E2824 100%);
  color: #FAF8F5;
  border: 2px solid #C69255;
  box-shadow: 0 10px 25px -5px rgba(27,24,22,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s;
}

.chatbot-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 14px 30px -5px rgba(198,146,85,0.4);
}

.chatbot-launcher-icon,
.chatbot-launcher-close {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
}

.chatbot-launcher-close {
  opacity: 0;
  transform: scale(0.6) rotate(-90deg);
}

.chatbot-launcher.active .chatbot-launcher-icon {
  opacity: 0;
  transform: scale(0.6) rotate(90deg);
}

.chatbot-launcher.active .chatbot-launcher-close {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.chatbot-badge-dot {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 13px;
  height: 13px;
  background: #25D366;
  border: 2px solid #1B1816;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(37,211,102,0.3);
  animation: pulseDot 2.2s infinite;
}

@keyframes pulseDot {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

/* --- VENTANA PRINCIPAL DEL CHATBOT --- */
.chatbot-window {
  position: fixed;
  right: 22px;
  bottom: 160px;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 180px);
  background: var(--bot-bg);
  border-radius: var(--bot-radius);
  box-shadow: var(--bot-shadow);
  border: 1px solid var(--bot-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9995;
  font-family: 'Jost', sans-serif;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.chatbot-window.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* HEADER DEL CHAT */
.chatbot-header {
  background: #1B1816;
  color: #FAF8F5;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(198,146,85,0.25);
  position: relative;
}

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

.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #2A2420;
  border: 1.5px solid #C69255;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #C69255;
  position: relative;
  flex-shrink: 0;
}

.chatbot-status-indicator {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: #25D366;
  border: 2px solid #1B1816;
  border-radius: 50%;
}

.chatbot-header-text h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0;
  color: #FAF8F5;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chatbot-header-text h3 span.badge-ai {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: #C69255;
  color: #1B1816;
  padding: 2px 5px;
  border-radius: 4px;
  text-transform: uppercase;
}

.chatbot-header-text p {
  font-size: 11px;
  color: #A9A29A;
  margin: 2px 0 0;
}

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

.chatbot-btn-icon {
  background: transparent;
  border: none;
  color: #A9A29A;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.chatbot-btn-icon:hover {
  background: rgba(255,255,255,0.08);
  color: #FAF8F5;
}

/* BANNER DE AYUDA DIRECTA WHATSAPP */
.chatbot-wa-banner {
  background: #F0FAF3;
  border-bottom: 1px solid #D6EFE0;
  padding: 8px 14px;
  font-size: 11.5px;
  color: #155724;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chatbot-wa-banner a {
  color: #0E7036;
  font-weight: 600;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chatbot-wa-banner a:hover {
  text-decoration: underline;
}

/* CUERPO DE MENSAJES */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #FAF8F5;
  scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
  width: 5px;
}
.chatbot-messages::-webkit-scrollbar-thumb {
  background: #DDD5CD;
  border-radius: 10px;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: fadeInMsg 0.25s ease-out;
}

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

.chat-msg.bot {
  align-self: flex-start;
}

.chat-msg.user {
  align-self: flex-end;
}

.chat-bubble {
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
}

.chat-msg.bot .chat-bubble {
  background: #FFFFFF;
  color: #1B1816;
  border-bottom-left-radius: 3px;
  border: 1px solid var(--bot-border);
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.chat-msg.user .chat-bubble {
  background: #1B1816;
  color: #FAF8F5;
  border-bottom-right-radius: 3px;
}

.chat-time {
  font-size: 10px;
  color: var(--bot-muted);
  margin-top: 4px;
  align-self: flex-start;
  padding: 0 4px;
}

.chat-msg.user .chat-time {
  align-self: flex-end;
}

/* BOTONES DE ACCIÓN RÁPIDA DENTRO DE MENSAJES */
.chat-action-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.chat-btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #FAF8F5;
  color: #1B1816;
  border: 1px solid #D8D0C7;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.chat-btn-action:hover {
  background: #1B1816;
  color: #FAF8F5;
  border-color: #1B1816;
}

.chat-btn-action.wa {
  background: #25D366;
  color: #FFFFFF;
  border-color: #25D366;
  font-weight: 600;
}

.chat-btn-action.wa:hover {
  background: #1EBE5D;
  border-color: #1EBE5D;
  color: #FFFFFF;
}

/* INDICADOR DE ESCRIBIENDO (TYPING DOTS) */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #FFFFFF;
  border-radius: 14px;
  border-bottom-left-radius: 3px;
  width: fit-content;
  border: 1px solid var(--bot-border);
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.chat-typing span {
  width: 6px;
  height: 6px;
  background: #A9A29A;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}

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

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* BARRA DE SUGERENCIAS / CHIPS */
.chatbot-chips-bar {
  padding: 8px 12px;
  background: #FFFFFF;
  border-top: 1px solid var(--bot-border);
  display: flex;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.chatbot-chips-bar::-webkit-scrollbar {
  display: none;
}

.chat-chip {
  background: #F4EFEA;
  color: #2E2824;
  border: 1px solid #E2D9D0;
  padding: 5px 10px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.chat-chip:hover {
  background: #1B1816;
  color: #FAF8F5;
  border-color: #1B1816;
}

/* FORMULARIO DE ENTRADA */
.chatbot-footer {
  padding: 10px 14px;
  background: #FFFFFF;
  border-top: 1px solid var(--bot-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chatbot-input {
  flex: 1;
  border: 1px solid #DED8D0;
  background: #FAF8F5;
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 13px;
  font-family: inherit;
  color: #1B1816;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.chatbot-input:focus {
  border-color: #C69255;
  background: #FFFFFF;
}

.chatbot-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #1B1816;
  color: #FAF8F5;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}

.chatbot-send-btn:hover {
  background: #C69255;
  color: #1B1816;
  transform: scale(1.05);
}

.chatbot-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ADAPTACIÓN MÓVIL */
@media (max-width: 480px) {
  .chatbot-launcher-container {
    right: 16px;
    bottom: 84px;
  }
  .chatbot-window {
    right: 10px;
    left: 10px;
    width: auto;
    bottom: 82px;
    height: 520px;
    max-height: calc(100vh - 100px);
  }
}
