:root {
  /* Paleta de marca RIES (ver assets/css/site.css --azul-500 / --indigo-900) */
  --pixel-primary: #2D6FB3;
  --pixel-primary-2: #282758;
  --pixel-accent: #b6c3f2;
  --pixel-accent-2: #eef0fb;
  --pixel-surface: #ffffff;
  --pixel-surface-soft: #f4f7fb;
  --pixel-text: #1d2a39;
  --pixel-muted: #5c6a7c;
  --pixel-line: #dfeaf4;
  --pixel-success: #2dbb6a;
  --pixel-shadow: 0 24px 60px rgba(13, 59, 102, 0.18);
  --pixel-radius: 18px;
  --pixel-font: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

* {
  box-sizing: border-box;
}

.pixel-chat-widget {
  position: fixed;
  right: 24px;
  bottom: 18px;
  z-index: 99999;
  font-family: var(--pixel-font);
}

.pixel-chat-trigger {
  position: relative;
  width: 150px;
  height: 190px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: pixel-float 4s ease-in-out infinite;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.pixel-chat-trigger:hover {
  transform: scale(1.04);
}

.pixel-chat-trigger img {
  width: 150px;
  height: 190px;
  object-fit: contain;
  object-position: bottom;
  display: block;
  filter: drop-shadow(0 16px 24px rgba(13, 59, 102, 0.28));
}

.pixel-chat-trigger.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.7);
}

/* Siempre visible (no solo al pasar el mouse) — así se nota de entrada que
   Pixel está para ayudar, sobre todo en celular donde no existe el hover. */
.pixel-chat-tooltip {
  position: absolute;
  bottom: calc(100% + 4px);
  right: -6px;
  background: var(--pixel-primary);
  color: white;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 14px 14px 4px 14px;
  white-space: nowrap;
  box-shadow: 0 10px 20px rgba(13, 59, 102, 0.22);
  pointer-events: none;
}

.pixel-chat-container {
  position: fixed;
  right: 24px;
  bottom: 0;
  width: min(820px, calc(100vw - 24px));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.pixel-chat-container.visible {
  opacity: 1;
  pointer-events: auto;
}

.pixel-chat-window {
  display: flex;
  width: 100%;
  height: 620px;
  max-height: calc(100vh - 20px);
  background: var(--pixel-surface);
  border-radius: 26px 26px 0 0;
  box-shadow: var(--pixel-shadow);
  overflow: hidden;
  transform: translateY(20px) scale(0.96);
  transition: transform 0.22s ease;
}

.pixel-chat-container.visible .pixel-chat-window {
  transform: translateY(0) scale(1);
}

.pixel-chat-sidebar {
  width: 260px;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 26px 20px 18px;
  background: linear-gradient(180deg, var(--pixel-primary) 0%, var(--pixel-primary-2) 100%);
  position: relative;
  overflow: hidden;
}

.pixel-chat-sidebar::before,
.pixel-chat-sidebar::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.pixel-chat-sidebar::before {
  width: 220px;
  height: 220px;
  top: -90px;
  left: -50px;
}

.pixel-chat-sidebar::after {
  width: 220px;
  height: 220px;
  bottom: -100px;
  right: -60px;
}

/* Pixel completo (pixel.png) parado sobre un "piso" de luz con los
   acentos del brandbook de RIES (--pixel-accent = lavanda-200). */
.pixel-chat-avatar-wrap {
  position: relative;
  z-index: 1;
  width: 170px;
  height: 210px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin-bottom: 6px;
}

.pixel-chat-avatar-wrap::before {
  content: "";
  position: absolute;
  bottom: 4px;
  width: 128px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--pixel-accent) 0%, rgba(126, 200, 227, 0) 75%);
  opacity: 0.65;
}

.pixel-chat-avatar-wrap img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom;
  display: block;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.28));
}

.pixel-chat-name {
  position: relative;
  z-index: 1;
  margin-top: 4px;
  font-size: 1.25rem;
  font-weight: 800;
  color: white;
}

.pixel-chat-status {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.78rem;
}

.pixel-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pixel-success);
  box-shadow: 0 0 0 5px rgba(45, 187, 106, 0.2);
  animation: pixel-pulse 2s ease-in-out infinite;
}

.pixel-chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--pixel-surface);
}

.pixel-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--pixel-line);
}

.pixel-header-copy h2 {
  font-size: 1.12rem;
  color: var(--pixel-text);
  margin: 0;
}

.pixel-header-copy p {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: var(--pixel-muted);
}

.pixel-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pixel-header-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--pixel-line);
  border-radius: 10px;
  background: var(--pixel-surface-soft);
  color: var(--pixel-primary);
  font-size: 1rem;
  cursor: pointer;
}

.pixel-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 10px;
  background: linear-gradient(180deg, #f9fbff 0%, #f5f8ff 100%);
}

.pixel-message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 14px;
}

.pixel-message.user {
  justify-content: flex-end;
}

.pixel-message.bot {
  justify-content: flex-start;
}

.pixel-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--pixel-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pixel-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pixel-msg-content {
  max-width: 78%;
  display: flex;
  flex-direction: column;
}

.pixel-message.user .pixel-msg-content {
  align-items: flex-end;
}

.pixel-msg-bubble {
  padding: 12px 14px;
  border-radius: 16px 16px 16px 6px;
  background: white;
  border: 1px solid var(--pixel-line);
  color: var(--pixel-text);
  line-height: 1.45;
  box-shadow: 0 10px 18px rgba(13, 59, 102, 0.04);
}

.pixel-message.bot .pixel-msg-bubble {
  background: white;
  border-bottom-left-radius: 6px;
}

.pixel-message.user .pixel-msg-bubble {
  background: linear-gradient(135deg, var(--pixel-primary) 0%, #174f8f 100%);
  color: white;
  border: none;
  border-radius: 16px 16px 6px 16px;
}

.pixel-msg-time {
  margin-top: 6px;
  font-size: 0.68rem;
  color: var(--pixel-muted);
}

.pixel-message.user .pixel-msg-time {
  color: #6c7a8c;
}

.pixel-quick-actions {
  display: none;
  padding: 0 16px 14px;
  border-top: 1px solid var(--pixel-line);
  background: white;
}

.pixel-actions-label {
  display: block;
  margin: 12px 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--pixel-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pixel-actions-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pixel-action-chip {
  appearance: none;
  border: 1px solid var(--pixel-line);
  background: var(--pixel-surface-soft);
  color: var(--pixel-text);
  border-radius: 999px;
  padding: 9px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.pixel-action-chip:hover {
  border-color: var(--pixel-accent);
  transform: translateY(-1px);
}

.pixel-action-chip.primary {
  background: var(--pixel-primary);
  border-color: var(--pixel-primary);
  color: white;
}

.pixel-action-chip.whatsapp {
  background: #eafaf0;
  border-color: #cfeedd;
  color: #0e7d3f;
}

.pixel-action-chip.back-btn {
  background: white;
}

.pixel-chat-input-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--pixel-line);
  background: white;
}

.pixel-chat-input-bar input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--pixel-line);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 0.95rem;
  color: var(--pixel-text);
  background: var(--pixel-surface-soft);
}

.pixel-chat-input-bar input:focus {
  outline: 2px solid rgba(126, 200, 227, 0.4);
  border-color: var(--pixel-accent);
}

.pixel-send-btn {
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--pixel-primary) 0%, var(--pixel-primary-2) 100%);
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
}

.pixel-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 12px 14px;
  border-radius: 16px;
  background: white;
  border: 1px solid var(--pixel-line);
}

.pixel-typing span {
  width: 7px;
  height: 7px;
  background: var(--pixel-primary);
  border-radius: 50%;
  display: inline-block;
  animation: pixel-bounce 1.2s ease-in-out infinite;
}

.pixel-typing span:nth-child(2) { animation-delay: 0.15s; }
.pixel-typing span:nth-child(3) { animation-delay: 0.3s; }

.pixel-lead-form {
  background: white;
  border: 1px solid var(--pixel-line);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 8px 18px rgba(13, 59, 102, 0.04);
}

.pixel-lead-form h4 {
  margin: 0 0 8px;
  color: var(--pixel-text);
}

.pixel-lead-form p {
  margin: 0 0 10px;
  color: var(--pixel-muted);
  font-size: 0.82rem;
}

.pixel-lead-form input {
  width: 100%;
  border: 1px solid var(--pixel-line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: var(--pixel-surface-soft);
}

.pixel-lead-form button {
  border: none;
  background: var(--pixel-primary);
  color: white;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 700;
  cursor: pointer;
}

.pixel-lead-form input.error {
  border-color: #d32f2f;
  box-shadow: 0 0 0 2px rgba(211, 47, 47, 0.08);
}

@keyframes pixel-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes pixel-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.1); }
}

@keyframes pixel-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-3px); opacity: 1; }
}

@media (max-width: 640px) {
  .pixel-chat-widget {
    right: 8px;
    bottom: 8px;
  }

  .pixel-chat-trigger {
    width: 110px;
    height: 140px;
  }

  .pixel-chat-trigger img {
    width: 110px;
    height: 140px;
  }

  .pixel-chat-tooltip {
    right: 0;
    font-size: 0.75rem;
    padding: 8px 12px;
  }

  .pixel-chat-container {
    right: 6px;
    width: calc(100vw - 12px);
  }

  /* Antes 72vh se sentía recortado — casi no quedaba lugar para los
     mensajes debajo del header y encima del input. Ahora ocupa casi
     toda la pantalla; dvh evita el salto cuando la barra del navegador
     del celular aparece/desaparece (con fallback a vh si no lo soporta). */
  .pixel-chat-window {
    height: 90vh;
    height: 90dvh;
    max-height: calc(100vh - 14px);
    max-height: calc(100dvh - 14px);
    border-radius: 18px 18px 0 0;
  }

  .pixel-chat-sidebar {
    display: none;
  }

  .pixel-chat-header {
    padding: 14px 14px 10px;
  }

  .pixel-chat-messages {
    padding: 14px 12px 8px;
  }
}
