/* ══════════════════════════════════════════════
   CHATBOT WIDGET
   ══════════════════════════════════════════════ */

.chat-fab {
  position: fixed;
  bottom: 28px; right: 28px;
  z-index: 200;
}
.chat-btn {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--negro);
  border: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 40px -8px rgba(0,0,0,0.4), 0 0 0 1px rgba(201,168,76,0.1);
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s;
  position: relative;
}
.chat-btn:hover {
  transform: scale(1.06) translateY(-2px);
  box-shadow: 0 18px 50px -8px rgba(26,86,219,0.5), 0 0 0 1px var(--oro);
}
.chat-btn svg { width: 24px; height: 24px; stroke: #fff; fill: none; stroke-width: 2; }
.chat-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid rgba(201,168,76,0.35);
  animation: chatPulse 2.5s ease-out infinite;
}
@keyframes chatPulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.45); opacity: 0; }
}
.chat-badge {
  position: absolute;
  top: -2px; right: -2px;
  width: 16px; height: 16px;
  background: var(--oro);
  border-radius: 50%;
  border: 2px solid var(--negro);
  font-family: var(--f-mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--negro);
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-window {
  position: fixed;
  bottom: 104px; right: 28px;
  width: 400px;
  background: var(--blanco);
  border-radius: var(--r-lg);
  box-shadow: 0 24px 80px rgba(0,0,0,0.22);
  z-index: 199;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.9) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s;
  max-height: min(620px, calc(100vh - 140px));
  border: 1px solid var(--borde);
}
.chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

.chat-header {
  background: var(--negro);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
}
.chat-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--oro) 50%, transparent);
  opacity: 0.4;
}
.chat-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--azul), var(--azul-suave));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--f-sans);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}
.chat-avatar::after {
  content: '';
  position: absolute;
  bottom: -2px; right: -2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--verde);
  border: 2px solid var(--negro);
}
.chat-header-info h4 {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 2px;
  letter-spacing: -0.01em;
}
.chat-header-info p {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
}
.chat-close {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  transition: color 0.2s, transform 0.2s;
  padding: 4px;
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.chat-close:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
  transform: rotate(90deg);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--fondo);
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--borde); border-radius: 3px; }

.msg {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  animation: msgIn 0.35s var(--ease-out);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg.user { flex-direction: row-reverse; }
.msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--azul), var(--azul-suave));
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
}
.msg-bubble {
  max-width: 270px;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
}
.msg.bot .msg-bubble {
  background: #fff;
  color: var(--ink);
  border-radius: 4px 16px 16px 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  border: 1px solid var(--borde);
}
.msg.user .msg-bubble {
  background: var(--negro);
  color: #fff;
  border-radius: 16px 4px 16px 16px;
}

.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 13px 16px;
  background: #fff;
  border-radius: 4px 16px 16px 16px;
  border: 1px solid var(--borde);
  width: fit-content;
}
.typing-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gris-soft);
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 20px 12px;
  background: var(--fondo);
}
.chat-option-btn {
  background: #fff;
  border: 1px solid var(--borde);
  border-radius: 100px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.chat-option-btn:hover {
  background: var(--negro);
  color: #fff;
  border-color: var(--negro);
  transform: translateY(-1px);
}

.chat-input-area {
  padding: 14px;
  background: #fff;
  border-top: 1px solid var(--borde);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  border: 1px solid var(--borde);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--f-sans);
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  max-height: 100px;
  line-height: 1.5;
  color: var(--ink);
}
.chat-input:focus { border-color: var(--azul); }
.chat-send {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--negro);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.2s;
}
.chat-send:hover { background: var(--azul); transform: scale(1.05); }
.chat-send svg { width: 16px; height: 16px; fill: #fff; }

.chat-success {
  text-align: center;
  padding: 40px 24px;
  background: var(--fondo);
  flex: 1;
}
.chat-success-icon {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: rgba(16,185,129,0.1);
  border: 1px solid rgba(16,185,129,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  color: var(--verde);
}
.chat-success-icon svg { width: 28px; height: 28px; }
.chat-success h4 {
  font-family: var(--f-serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--negro);
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}
.chat-success p {
  font-size: 14px;
  color: var(--gris);
  line-height: 1.6;
}

@media (max-width: 640px) {
  .chat-window { width: calc(100vw - 24px); right: 12px; }
  .chat-fab { right: 16px; bottom: 20px; }
}
