/* ============================================================
   Repuestico — Asistente virtual flotante
   ============================================================ */

/* ---------- Botón flotante ---------- */
.repuestico-fab {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 1055;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-size: 1.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(102, 126, 234, .5);
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease;
  animation: repuestico-fab-entrance 0.6s cubic-bezier(.34,1.56,.64,1) both,
             repuestico-glow 2.5s ease-in-out infinite;
  animation-delay: 1s, 2s;
}
.repuestico-fab:hover {
  transform: scale(1.1) rotate(-3deg);
  box-shadow: 0 10px 35px rgba(102, 126, 234, .65);
  animation-play-state: paused;
}
.repuestico-fab:active {
  transform: scale(0.95);
}

/* Entrada del FAB con bounce */
@keyframes repuestico-fab-entrance {
  0%   { opacity: 0; transform: scale(0) translateY(40px); }
  60%  { transform: scale(1.15) translateY(-6px); }
  80%  { transform: scale(0.95) translateY(2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Resplandor pulsante */
@keyframes repuestico-glow {
  0%, 100% { box-shadow: 0 6px 24px rgba(102, 126, 234, .5); }
  50%      { box-shadow: 0 6px 40px rgba(118, 75, 162, .75), 0 0 20px rgba(102, 126, 234, .3); }
}

/* Badge notificación */
.repuestico-fab .repuestico-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f59e0b;
  border: 2px solid #fff;
  animation: repuestico-pulse 2s infinite;
}

@keyframes repuestico-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.4); opacity: .5; }
}

/* ---------- Tooltip / Burbuja "¡Hola!" ---------- */
.repuestico-fab::after {
  content: '¡Hola! ¿Necesitas una pieza? 🚗';
  position: absolute;
  left: calc(100% + 12px);
  bottom: 8px;
  white-space: nowrap;
  background: #fff;
  color: #333;
  font-size: .82rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  pointer-events: none;
  opacity: 0;
  transform: translateX(-8px);
  animation: repuestico-tooltip-show 0.4s ease forwards;
  animation-delay: 3s;
}
.repuestico-fab::before {
  content: '';
  position: absolute;
  left: calc(100% + 4px);
  bottom: 18px;
  width: 0;
  height: 0;
  border: 6px solid transparent;
  border-right-color: #fff;
  pointer-events: none;
  opacity: 0;
  animation: repuestico-tooltip-show 0.4s ease forwards;
  animation-delay: 3s;
}

@keyframes repuestico-tooltip-show {
  0%   { opacity: 0; transform: translateX(-8px); }
  100% { opacity: 1; transform: translateX(0); }
}

/* Ocultar tooltip cuando el chat está abierto */
.repuestico-fab.repuestico-fab--active::after,
.repuestico-fab.repuestico-fab--active::before {
  display: none;
}

/* ---------- Ventana de chat ---------- */
.repuestico-window {
  position: fixed;
  left: 18px;
  bottom: 96px;
  z-index: 1056;
  width: min(380px, calc(100vw - 36px));
  max-height: min(540px, calc(100vh - 120px));
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0,0,0,.25), 0 0 0 1px rgba(0,0,0,.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(30px) scale(.9);
  pointer-events: none;
  transition: none;
}
.repuestico-window.repuestico-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  animation: repuestico-window-in .45s cubic-bezier(.34,1.56,.64,1) both;
}
.repuestico-window.repuestico-closing {
  animation: repuestico-window-out .25s ease forwards;
}

@keyframes repuestico-window-in {
  0%   { opacity: 0; transform: translateY(30px) scale(.85); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes repuestico-window-out {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(20px) scale(.9); pointer-events: none; }
}

/* ---------- Header del chat ---------- */
.repuestico-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
/* Efecto shimmer decorativo en el header */
.repuestico-header::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -60%;
  width: 50%;
  height: 200%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent);
  transform: skewX(-20deg);
  animation: repuestico-shimmer 4s ease-in-out infinite;
}
@keyframes repuestico-shimmer {
  0%, 100% { left: -60%; }
  50%      { left: 120%; }
}
.repuestico-header .repuestico-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.4);
  position: relative;
}
/* Indicador "en línea" */
.repuestico-header .repuestico-avatar::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #34d399;
  border: 2px solid #764ba2;
  animation: repuestico-online-pulse 2s ease infinite;
}
@keyframes repuestico-online-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52,211,153,.5); }
  50%      { box-shadow: 0 0 0 4px rgba(52,211,153,0); }
}
.repuestico-header .repuestico-title {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.2;
}
.repuestico-header .repuestico-subtitle {
  font-size: .8rem;
  opacity: .85;
}
.repuestico-header .repuestico-close {
  margin-left: auto;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  opacity: .8;
  transition: opacity .2s;
}
.repuestico-header .repuestico-close:hover { opacity: 1; }

/* ---------- Área de mensajes ---------- */
.repuestico-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f4f4f8;
}

/* Burbujas */
.repuestico-msg {
  max-width: 88%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: .95rem;
  line-height: 1.5;
  word-break: break-word;
  animation: repuestico-msg-in .35s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes repuestico-msg-in {
  from { opacity: 0; transform: translateY(12px) scale(.92); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.repuestico-msg.bot {
  align-self: flex-start;
  background: #fff;
  color: #333;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.repuestico-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 10px rgba(102,126,234,.3);
}

/* ---------- Botones de opciones ---------- */
.repuestico-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.repuestico-opt-btn {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #667eea;
  border-radius: 14px;
  background: #fff;
  color: #444;
  font-size: .93rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all .25s cubic-bezier(.34,1.2,.64,1);
  animation: repuestico-opt-in .35s cubic-bezier(.34,1.56,.64,1) both;
}
.repuestico-opt-btn:nth-child(1) { animation-delay: .05s; }
.repuestico-opt-btn:nth-child(2) { animation-delay: .12s; }
.repuestico-opt-btn:nth-child(3) { animation-delay: .19s; }
.repuestico-opt-btn:nth-child(4) { animation-delay: .26s; }

@keyframes repuestico-opt-in {
  from { opacity: 0; transform: translateX(-16px) scale(.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

.repuestico-opt-btn:hover,
.repuestico-opt-btn:focus {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-color: #667eea;
  transform: translateX(4px);
  box-shadow: 0 4px 14px rgba(102,126,234,.3);
}
.repuestico-opt-btn .opt-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}

/* ---------- Botón WhatsApp inline ---------- */
.repuestico-wa-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 20px;
  background: #25D366;
  color: #fff !important;
  font-size: .92rem;
  font-weight: 700;
  border: none;
  border-radius: 24px;
  text-decoration: none;
  cursor: pointer;
  transition: all .25s ease;
  box-shadow: 0 3px 12px rgba(37,211,102,.35);
  animation: repuestico-wa-pulse 2s ease-in-out infinite;
}
.repuestico-wa-btn:hover,
.repuestico-wa-btn:focus {
  background: #128C7E;
  transform: scale(1.04);
  box-shadow: 0 5px 18px rgba(18,140,126,.45);
  text-decoration: none;
  color: #fff !important;
}
.repuestico-wa-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex-shrink: 0;
}
@keyframes repuestico-wa-pulse {
  0%, 100% { box-shadow: 0 3px 12px rgba(37,211,102,.35); }
  50%      { box-shadow: 0 3px 20px rgba(37,211,102,.55); }
}

/* ---------- Botón Vender pieza inline ---------- */
.repuestico-sell-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff !important;
  font-size: .92rem;
  font-weight: 700;
  border: none;
  border-radius: 24px;
  text-decoration: none;
  cursor: pointer;
  transition: all .25s ease;
  box-shadow: 0 3px 12px rgba(102,126,234,.35);
}
.repuestico-sell-btn:hover,
.repuestico-sell-btn:focus {
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
  transform: scale(1.04);
  box-shadow: 0 5px 18px rgba(118,75,162,.45);
  text-decoration: none;
  color: #fff !important;
}
.repuestico-sell-btn i {
  font-size: 1.1rem;
}

/* ---------- Botón Registro inline ---------- */
.repuestico-register-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  color: #fff !important;
  font-size: .92rem;
  font-weight: 700;
  border: none;
  border-radius: 24px;
  text-decoration: none;
  cursor: pointer;
  transition: all .25s ease;
  box-shadow: 0 3px 12px rgba(245,158,11,.35);
}
.repuestico-register-btn:hover,
.repuestico-register-btn:focus {
  background: linear-gradient(135deg, #ef4444 0%, #f59e0b 100%);
  transform: scale(1.04);
  box-shadow: 0 5px 18px rgba(239,68,68,.45);
  text-decoration: none;
  color: #fff !important;
}
.repuestico-register-btn i {
  font-size: 1.1rem;
}

/* ---------- Indicador "escribiendo…" ---------- */
.repuestico-typing {
  display: flex;
  gap: 5px;
  padding: 10px 14px;
  align-self: flex-start;
}
.repuestico-typing span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #aaa;
  animation: repuestico-dot 1.2s infinite;
}
.repuestico-typing span:nth-child(2) { animation-delay: .2s; }
.repuestico-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes repuestico-dot {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40%           { transform: scale(1); opacity: 1; }
}

/* ---------- Footer con input de texto ---------- */
.repuestico-footer {
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid #eee;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.repuestico-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.repuestico-input {
  flex: 1;
  padding: 11px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 24px;
  font-size: .93rem;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  background: #fafafa;
}
.repuestico-input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102,126,234,.15);
  background: #fff;
}
.repuestico-input::placeholder {
  color: #aaa;
}
.repuestico-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform .2s, box-shadow .2s;
}
.repuestico-send:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(102,126,234,.4);
}
.repuestico-send:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.repuestico-footer-actions {
  display: flex;
  justify-content: center;
}
.repuestico-restart {
  background: none;
  border: none;
  color: #667eea;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
}
.repuestico-restart:hover { text-decoration: underline; }

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .repuestico-window {
    left: 8px;
    right: 8px;
    bottom: 88px;
    width: auto;
    max-height: calc(100vh - 100px);
    border-radius: 16px;
  }
  .repuestico-fab {
    left: 12px;
    bottom: 12px;
    width: 58px;
    height: 58px;
    font-size: 1.5rem;
  }
  .repuestico-fab-avatar {
    width: 58px;
    height: 58px;
  }
  .repuestico-fab::after {
    font-size: .75rem;
    padding: 6px 10px;
  }
}

/* ---------- Avatar de Repuestico (FAB) ---------- */
.repuestico-fab-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
  transition: filter .2s;
}
.repuestico-fab {
  padding: 0;
  overflow: visible;
}
.repuestico-fab:hover .repuestico-fab-avatar {
  filter: brightness(1.1);
}

/* ---------- Etiqueta "IA" en el header ---------- */
.repuestico-ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(255,255,255,.2);
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 20px;
  padding: 2px 8px;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .5px;
  color: #fff;
  margin-left: 6px;
  backdrop-filter: blur(4px);
}

/* ---------- Powered by footer ---------- */
.repuestico-powered {
  text-align: center;
  font-size: .7rem;
  color: #aaa;
  padding: 2px 0 0;
  letter-spacing: .3px;
}
