/**
 * Chatbot guía — estilo grunge, mismo lenguaje visual que el portfolio.
 */

.chatbot-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9990;
  font-family: 'Syne', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* Burbuja emergente que nace del botón */
.chatbot-emergent {
  position: absolute;
  bottom: 64px;
  right: 0;
  padding: 10px 14px;
  background: var(--primary-bg, #f8f6f1);
  border: 1.5px solid var(--ink, #141210);
  border-radius: 12px 12px 12px 4px;
  box-shadow: 3px 3px 0 var(--ink-2, #3a3530);
  opacity: 0;
  transform: scale(0.85) translateY(8px);
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  pointer-events: none;
  white-space: normal;
  min-width: 100px;
  max-width: 180px;
}

.chatbot-emergent::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 14px;
  width: 12px;
  height: 12px;
  background: var(--primary-bg, #f8f6f1);
  border-right: 1.5px solid var(--ink, #141210);
  border-bottom: 1.5px solid var(--ink, #141210);
  transform: rotate(45deg);
}

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

.chatbot-emergent-text {
  font-family: 'Instrument Serif', serif;
  font-size: 15px;
  font-style: italic;
  color: var(--ink, #141210);
}

.chatbot-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--ink, #141210);
  background: var(--primary-bg, #f8f6f1);
  color: var(--ink, #141210);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 4px 4px 0 var(--ink-2, #3a3530);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-toggle:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--ink-2, #3a3530);
}

.chatbot-toggle:active {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 var(--ink-2, #3a3530);
}

.chatbot-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 320px;
  max-width: calc(100vw - 48px);
  max-height: 420px;
  background: var(--primary-bg, #f8f6f1);
  border: 2px solid var(--ink, #141210);
  border-radius: 16px;
  box-shadow: 8px 8px 0 var(--ink-2, #3a3530);
  overflow: hidden;
  display: none;
  flex-direction: column;
}

.chatbot-panel.is-open {
  display: flex;
  animation: chatbotPop 0.25s ease;
}

@keyframes chatbotPop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Textura sutil tipo papel */
.chatbot-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  border-radius: 14px;
}

.chatbot-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border, rgba(20, 18, 16, 0.12));
  background: rgba(20, 18, 16, 0.02);
  position: relative;
}

.chatbot-title {
  font-family: 'Syne Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-3, #7a736a);
}

.chatbot-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--ink-2, #3a3530);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 0.2s, color 0.2s;
}

.chatbot-close:hover {
  background: rgba(20, 18, 16, 0.08);
  color: var(--ink, #141210);
}

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chatbot-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.chatbot-msg.bot .chatbot-msg-bubble {
  background: rgba(20, 18, 16, 0.06);
  border: 1px solid var(--border, rgba(20, 18, 16, 0.1));
  border-radius: 12px 12px 12px 4px;
  padding: 12px 14px;
  max-width: 100%;
}

.chatbot-msg-bubble {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink, #141210);
}

.chatbot-msg.bot .chatbot-msg-bubble .chatbot-greeting {
  font-family: 'Instrument Serif', serif;
  font-size: 20px;
  font-style: italic;
  margin-bottom: 4px;
}

.chatbot-msg.bot .chatbot-msg-bubble .chatbot-sub {
  font-family: 'Syne', sans-serif;
  font-size: 12px;
  color: var(--ink-3, #7a736a);
}

.chatbot-funfact {
  font-family: 'Syne', sans-serif;
  font-size: 12px;
  color: var(--ink-2, #3a3530);
  line-height: 1.45;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border, rgba(20, 18, 16, 0.12));
}

.chatbot-funfact-label {
  font-family: 'Syne Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-3, #7a736a);
  margin-right: 4px;
}

.chatbot-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chatbot-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--ink, #141210);
  background: transparent;
  color: var(--ink, #141210);
  font-family: 'Syne Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.chatbot-chip:hover {
  background: var(--ink, #141210);
  color: var(--primary-bg, #f8f6f1);
  transform: translateY(-1px);
  box-shadow: 2px 2px 0 var(--ink-2, #3a3530);
}

.chatbot-chip i {
  font-size: 10px;
  opacity: 0.8;
}

@media (max-width: 480px) {
  .chatbot-wrap {
    bottom: 16px;
    right: 16px;
  }

  .chatbot-panel {
    width: 288px;
    bottom: 64px;
  }
}
