/* PilaBot - Chat inclusivo Honda Baterías */

:root {
  --bot-primary: #cc0000;
  --bot-primary-dark: #990000;
  --bot-bg: #ffffff;
  --bot-user-bg: #e8f4fd;
  --bot-bot-bg: #f8f9fa;
  --bot-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  --bot-radius: 16px;
  --bot-touch: 44px;
}

/* Botón flotante */
.pilabot-launcher {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 1050;
  width: var(--bot-touch);
  height: var(--bot-touch);
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--bot-primary), var(--bot-primary-dark));
  color: white;
  font-size: 1.4rem;
  box-shadow: var(--bot-shadow);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pilabot-launcher:hover,
.pilabot-launcher:focus {
  transform: scale(1.08);
  box-shadow: 0 10px 40px rgba(204, 0, 0, 0.35);
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.pilabot-launcher[aria-expanded="true"] {
  transform: rotate(0deg) scale(0.95);
}

.pilabot-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ffc107;
  color: #1a1a1a;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  border: 2px solid white;
}

/* Ventana del chat */
.pilabot-window {
  position: fixed;
  bottom: 5.5rem;
  right: 1.25rem;
  z-index: 1049;
  width: min(380px, calc(100vw - 2rem));
  height: min(520px, calc(100vh - 8rem));
  background: var(--bot-bg);
  border-radius: var(--bot-radius);
  box-shadow: var(--bot-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.pilabot-window--open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Cabecera */
.pilabot-header {
  background: linear-gradient(135deg, var(--bot-primary), var(--bot-primary-dark));
  color: white;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.pilabot-header__avatar {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.pilabot-header__info h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
}

.pilabot-header__info p {
  font-size: 0.7rem;
  margin: 0;
  opacity: 0.85;
}

.pilabot-header__close {
  margin-left: auto;
  background: none;
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 6px;
  min-width: var(--bot-touch);
  min-height: var(--bot-touch);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pilabot-header__close:hover,
.pilabot-header__close:focus {
  background: rgba(255, 255, 255, 0.2);
  outline: 2px solid white;
}

/* Mensajes */
.pilabot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-behavior: smooth;
}

.pilabot-msg {
  max-width: 88%;
  padding: 0.65rem 0.85rem;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.45;
  word-wrap: break-word;
}

.pilabot-msg--bot {
  align-self: flex-start;
  background: var(--bot-bot-bg);
  border-bottom-left-radius: 4px;
  border: 1px solid #e9ecef;
}

.pilabot-msg--user {
  align-self: flex-end;
  background: var(--bot-user-bg);
  border-bottom-right-radius: 4px;
  color: #003366;
}

.pilabot-msg--sistema {
  align-self: center;
  background: #fff3cd;
  border: 1px solid #ffc107;
  font-size: 0.8rem;
  text-align: center;
  max-width: 95%;
}

.pilabot-msg a {
  color: var(--bot-primary);
  font-weight: 600;
}

.pilabot-msg strong {
  color: var(--bot-primary-dark);
}

/* Botones rápidos */
.pilabot-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1rem 0.5rem;
}

.pilabot-quick__btn {
  font-size: 0.75rem;
  padding: 0.4rem 0.7rem;
  border-radius: 20px;
  border: 1px solid var(--bot-primary);
  background: white;
  color: var(--bot-primary);
  cursor: pointer;
  min-height: 36px;
  transition: background 0.15s;
}

.pilabot-quick__btn:hover,
.pilabot-quick__btn:focus {
  background: var(--bot-primary);
  color: white;
  outline: none;
}

/* Atajos */
.pilabot-atajos {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0 1rem 0.5rem;
  border-top: 1px solid #eee;
  padding-top: 0.5rem;
}

.pilabot-atajo {
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  background: #e9ecef;
  border: none;
  border-radius: 4px;
  color: #495057;
  cursor: pointer;
}

.pilabot-atajo:hover {
  background: #dee2e6;
}

/* Input */
.pilabot-input-area {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid #e9ecef;
  background: #fafafa;
  flex-shrink: 0;
}

.pilabot-input {
  flex: 1;
  border: 1px solid #ced4da;
  border-radius: 24px;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  min-height: var(--bot-touch);
}

.pilabot-input:focus {
  outline: 2px solid var(--bot-primary);
  border-color: var(--bot-primary);
}

.pilabot-send {
  width: var(--bot-touch);
  height: var(--bot-touch);
  border-radius: 50%;
  border: none;
  background: var(--bot-primary);
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pilabot-send:hover,
.pilabot-send:focus {
  background: var(--bot-primary-dark);
  outline: 2px solid #333;
  outline-offset: 2px;
}

.pilabot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Resumen descuentos en chat */
.pilabot-resumen {
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  margin-top: 0.35rem;
  font-size: 0.8rem;
}

.pilabot-resumen__linea {
  display: flex;
  justify-content: space-between;
  padding: 0.15rem 0;
}

.pilabot-resumen__linea--descuento {
  color: #198754;
}

.pilabot-resumen__total {
  border-top: 2px solid var(--bot-primary);
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  font-weight: 700;
  color: var(--bot-primary);
}

/* Typing indicator */
.pilabot-typing {
  display: flex;
  gap: 4px;
  padding: 0.5rem 0.85rem;
  align-self: flex-start;
}

.pilabot-typing span {
  width: 8px;
  height: 8px;
  background: #adb5bd;
  border-radius: 50%;
  animation: pilabot-bounce 1.2s infinite;
}

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

@keyframes pilabot-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Accesibilidad: movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  .pilabot-window,
  .pilabot-launcher,
  .pilabot-typing span {
    transition: none;
    animation: none;
  }
}

@media (max-width: 480px) {
  .pilabot-window {
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
    bottom: 5rem;
  }

  .pilabot-launcher {
    right: 0.75rem;
    bottom: 0.75rem;
  }
}
