:root {
  --brand-teal: #1f6563;
  --bg-dots: #f0f4f4;
  --dot-color: #9dbab8;
  --shadow: 0 14px 28px rgba(0, 0, 0, 0.12);
}

.chat-pill {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: #ffffff;
  border: none;
  border-radius: 999px;
  padding: 8px 14px 8px 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 200ms ease, box-shadow 200ms ease;
  z-index: 20;
  animation: slideUpFade 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.27) backwards;
  /* El delay ayuda a que la web cargue antes de que aparezca el botón */
  animation-delay: 0.3s;
}

@keyframes slideUpFade {
  0% {
    opacity: 0;
    transform: translateY(40px) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-pill:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.16);
}

/* Efecto de onda (ripple) embebido en un pseudo-elemento */
.chat-pill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  animation: none; /* Sin animación por defecto: todo se controla por clase JS */
}

/* Onda de carga inicial: disparada por clase JS .wave-load */
.chat-pill.wave-load::after {
  animation: outerWaveLoad 1.5s cubic-bezier(0.25, 1, 0.5, 1) 0.8s forwards;
}

.chat-pill:hover::after {
  animation: outerWaveHover 1.2s cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes outerWaveLoad {
  0% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(70, 178, 178, 0.6);
  }
  100% {
    opacity: 0;
    box-shadow: 0 0 0 24px rgba(70, 178, 178, 0);
  }
}

@keyframes outerWaveHover {
  0% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(70, 178, 178, 0.6);
  }
  100% {
    opacity: 0;
    box-shadow: 0 0 0 24px rgba(70, 178, 178, 0);
  }
}

.chat-pill__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: conic-gradient(from 180deg, #5fc39f, #3caea5, #5fc39f);
  position: relative;
}

.chat-pill__status {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 12px;
  height: 12px;
  background: #4ade80;
  border: 2px solid #ffffff;
  border-radius: 50%;
}

.chat-pill__typing {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-dots);
  padding: 8px 12px;
  border-radius: 999px;
}

.chat-pill__typing span {
  width: 6px;
  height: 6px;
  background: var(--dot-color);
  border-radius: 50%;
}

.chat-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.95);
  transform-origin: bottom right;
  transition: opacity 250ms ease, transform 250ms ease, visibility 250ms;
  z-index: 19;
}

.chat-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  z-index: 21;
}

.chat-fab.is-open {
  opacity: 0;
  pointer-events: none;
}

.chat-pill-expanded {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  /*background: #ffffff;*/
  background: #52213D;
  border: none;
  border-radius: 999px;
  padding: 8px 8px 8px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.chat-pill-expanded__icon-box {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.chat-pill-expanded__icon-box svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

.chat-pill-expanded__action {
  display: flex;
  align-items: center;
  gap: 10px;
  /*background: #e6f3eb;*/
  background: #3a172b;
  padding: 6px 16px 6px 6px;
  border-radius: 999px;
  position: relative;
}

.action-icon {
  width: 32px;
  height: 32px;
  /*background: #4ade80;*/
  background: #215454;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.action-icon svg {
  width: 16px;
  height: 16px;
}

.action-dots {
  display: flex;
  gap: 4px;
}

.action-dots span {
  width: 5px;
  height: 5px;
  background: #a9d4c2;
  border-radius: 50%;
}

.action-status {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  /*background: #4ade80;*/
  background: #215454;
  border: 2.5px solid #e6f3eb;
  border-radius: 50%;
}

@media (max-width: 768px) {
  .chat-pill, .chat-panel {
    right: 14px;
    bottom: 14px;
  }
}

.chat-pill__text {
  font-size: 15px;
  font-weight: 700;
  color: #1b5351;
  padding: 0 4px;
}

.chat-pill__text {
  font-size: 15px;
  font-weight: 700;
  color: #1b5351;
  padding: 0 4px;
}

/* Generamos 3 ondas rápidas en bucle al estar inactivos (3 x 0.6s = 1.8s) */
.chat-pill.attention {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.16);
}

.chat-pill.attention::after {
  animation-name: outerWaveAttention !important;
  animation-duration: 0.6s !important;
  animation-timing-function: ease-out !important;
  animation-iteration-count: 3 !important;
  animation-fill-mode: forwards !important;
  animation-delay: 0s !important;
}

@keyframes outerWaveAttention {
  0% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(70, 178, 178, 0.6);
  }
  100% {
    opacity: 0;
    box-shadow: 0 0 0 24px rgba(70, 178, 178, 0);
  }
}
.chat-pill {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  /*background: #ffffff;*/
  background: #52213D;
  border: none;
  border-radius: 999px;
  padding: 8px 18px 8px 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 200ms ease, box-shadow 200ms ease;
  z-index: 20;
  animation: slideUpFade 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.27) backwards;
  animation-delay: 0.3s;
}

.chat-pill__icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-pill__icon svg {
  width: 36px;
  height: 36px;
  fill: #ffffff;
}

.chat-pill__text {
  font-family: "Roboto Flex", sans-serif;
  font-size: 28px;
  font-weight: 600;
  color: #215454;
  padding: 0;
  line-height: 1;
  letter-spacing: -0.02em;
}

/* Limpiar clases antiguas como _avatar o _typing de chat-pill */
.chat-pill__avatar,
.chat-pill__status,
.chat-pill__typing {
  display: none !important;
}

/* Panel dimensions + iframe */
.chat-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: 600px;
  height: 80vh;
  max-height: 720px;
}

.chat-content {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid #52213D;
  box-shadow: 0 8px 32px rgba(82, 33, 61, 0.22), var(--shadow);
}

.chat-panel__header {
  width: 100%;
  background: #52213D;
  color: #fff;
  padding: 12px 16px;
  font-family: "Roboto Flex", sans-serif;
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
  box-sizing: border-box;
}

#delfos-chat {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}

.chat-panel .chat-pill-expanded {
  margin-top: 8px;
  flex-shrink: 0;
}

/* Responsive: panel ocupa casi toda la pantalla en móvil */
@media (max-width: 768px) {
  .chat-panel {
    width: calc(100vw - 28px);
    height: calc(100vh - 90px);
    max-height: none;
  }
}

@media (max-width: 480px) {
  .chat-pill, .chat-panel {
    right: 8px;
    bottom: 8px;
  }
  .chat-panel {
    width: calc(100vw - 16px);
    height: calc(100vh - 80px);
  }
}
