/* Chatbot público Esponda Abogados — reemplaza el botón flotante de WhatsApp cuando está activo */

.site-chat {
  position: fixed;
  right: 1.25rem;
  bottom: calc(1.25rem + 15px);
  /* Por encima del navbar (header ~1000) para que el panel/form no queden debajo. */
  z-index: 1200;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
  max-height: calc(100vh - var(--header-height, 80px) - 1.25rem);
  font-family: var(--font-heading, "Segoe UI", sans-serif);
}

.site-chat__fab {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  min-height: 56px;
  padding: 0.55rem 1.15rem 0.55rem 0.55rem;
  border: 1px solid rgba(200, 169, 110, 0.22);
  border-radius: 999px;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.14), transparent 42%),
    linear-gradient(135deg, #0F1A2E 0%, #1D2D44 42%, #1D2D44 120%);
  background-size: 200% 200%, 100% 100%;
  color: #fff;
  box-shadow:
    0 14px 34px rgba(29, 45, 68, 0.28),
    0 10px 24px rgba(8, 17, 31, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  overflow: visible;
  animation: site-chat-fab-float 3.6s ease-in-out infinite;
  transition:
    transform 0.28s ease,
    box-shadow 0.28s ease,
    border-color 0.28s ease,
    filter 0.28s ease;
}

.site-chat__fab::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    110deg,
    transparent 20%,
    rgba(255, 255, 255, 0.22) 45%,
    transparent 70%
  );
  transform: translateX(-120%);
  animation: site-chat-fab-shine 4.8s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

.site-chat__fab > * {
  position: relative;
  z-index: 1;
}

.site-chat__fab:hover {
  transform: translateY(-5px) scale(1.03);
  border-color: rgba(200, 169, 110, 0.45);
  filter: saturate(1.08);
  box-shadow:
    0 20px 42px rgba(29, 45, 68, 0.36),
    0 12px 28px rgba(8, 17, 31, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  animation-play-state: paused;
}

.site-chat__fab:active {
  transform: translateY(-1px) scale(0.99);
}

.site-chat__fab:focus-visible {
  outline: 2px solid #E8D5A8;
  outline-offset: 3px;
}

.site-chat.is-open .site-chat__fab {
  animation: none;
  background: linear-gradient(135deg, #0F1A2E, #1D2D44 70%);
}

.site-chat.is-open .site-chat__fab-pulse,
.site-chat.is-open .site-chat__fab-sub {
  display: none;
}

.site-chat__fab-pulse {
  position: absolute;
  left: 10px;
  top: 50%;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  border-radius: 50%;
  border: 2px solid rgba(29, 45, 68, 0.45);
  pointer-events: none;
  animation: site-chat-fab-pulse 2.4s ease-out infinite;
  z-index: 0;
}

.site-chat__fab-pulse--delay {
  animation-delay: 1.1s;
}

.site-chat__fab-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #C8A96E, #1D2D44 55%, #8f7640 100%);
  box-shadow:
    0 8px 18px rgba(29, 45, 68, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}

.site-chat__fab-icon svg {
  width: 20px;
  height: 20px;
  display: block;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
}

.site-chat__fab-dot {
  position: absolute;
  right: 2px;
  top: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #32d583;
  border: 2px solid #0F1A2E;
  box-shadow: 0 0 0 0 rgba(50, 213, 131, 0.55);
  animation: site-chat-fab-dot 1.8s ease-out infinite;
}

.site-chat__fab-copy {
  display: grid;
  gap: 0.12rem;
  text-align: left;
  padding-right: 0.2rem;
}

.site-chat__fab-label {
  line-height: 1.1;
  color: rgba(255, 255, 255, 0.98);
}

.site-chat__fab-sub {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(200, 169, 110, 0.92);
  line-height: 1;
}

@keyframes site-chat-fab-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@keyframes site-chat-fab-pulse {
  0% {
    transform: scale(0.85);
    opacity: 0.7;
  }
  70% {
    transform: scale(1.55);
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}

@keyframes site-chat-fab-shine {
  0%,
  55% {
    transform: translateX(-120%);
  }
  75%,
  100% {
    transform: translateX(120%);
  }
}

@keyframes site-chat-fab-dot {
  0% {
    box-shadow: 0 0 0 0 rgba(50, 213, 131, 0.55);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(50, 213, 131, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(50, 213, 131, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-chat__fab,
  .site-chat__fab::before,
  .site-chat__fab-pulse,
  .site-chat__fab-dot {
    animation: none !important;
  }
}

.site-chat__panel {
  width: min(420px, calc(100vw - 1.4rem));
  height: min(620px, calc(100vh - var(--header-height, 80px) - 5.5rem));
  max-height: calc(100vh - var(--header-height, 80px) - 5.5rem);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid rgba(8, 17, 31, 0.12);
  background: #fff;
  box-shadow: 0 24px 60px rgba(8, 17, 31, 0.28);
  color: #132033;
}

.site-chat__panel[hidden] {
  display: none !important;
}

.site-chat__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1rem 0.85rem;
  background: linear-gradient(160deg, #0F1A2E, #1D2D44 70%);
  color: #fff;
}

.site-chat__head strong {
  display: block;
  font-size: 0.98rem;
  font-weight: 800;
}

.site-chat__head p {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 500;
}

.site-chat__close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.site-chat__messages {
  padding: 0.9rem;
  overflow-y: auto;
  background:
    radial-gradient(circle at top right, rgba(29, 45, 68, 0.06), transparent 40%),
    #f5f8fc;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.site-chat__bubble {
  max-width: 88%;
  padding: 0.72rem 0.85rem;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: normal;
  word-break: break-word;
}

.site-chat__bubble br {
  display: block;
  content: "";
  margin-top: 0.35em;
}

.site-chat__bubble--bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid rgba(8, 17, 31, 0.08);
  color: #1a2b40;
  border-bottom-left-radius: 6px;
}

.site-chat__bubble--lead {
  align-self: flex-start;
  background: #f7f1e6;
  border: 1px solid rgba(200, 169, 110, 0.35);
  color: #1a2b40;
  border-bottom-left-radius: 6px;
}

.site-chat__bubble--user {
  align-self: flex-end;
  background: #1D2D44;
  color: #fff;
  border-bottom-right-radius: 6px;
}

.site-chat__bubble--meta {
  align-self: center;
  max-width: 95%;
  background: transparent;
  color: #5b6b7c;
  font-size: 0.78rem;
  text-align: center;
  padding: 0.2rem 0.4rem;
}

.site-chat__bubble--typing {
  padding: 0.65rem 0.9rem;
}

.site-chat__typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 1em;
}

.site-chat__typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #1D2D44;
  opacity: 0.35;
  animation: site-chat-typing 1.2s ease-in-out infinite;
}

.site-chat__typing span:nth-child(2) {
  animation-delay: 0.18s;
}

.site-chat__typing span:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes site-chat-typing {
  0%,
  80%,
  100% {
    opacity: 0.28;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.site-chat__quick,
.site-chat__cta {
  align-self: stretch;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.site-chat__chip,
.site-chat__cta-btn {
  border: 1px solid rgba(29, 45, 68, 0.28);
  background: #fff;
  color: #2A4060;
  border-radius: 999px;
  min-height: 36px;
  padding: 0 0.9rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.site-chat__chip:hover,
.site-chat__cta-btn:hover {
  background: #eef6fc;
  border-color: rgba(29, 45, 68, 0.45);
}

.site-chat__chip--accent {
  background: #1D2D44;
  border-color: #1D2D44;
  color: #fff;
}

.site-chat__chip--accent:hover {
  background: #2A4060;
  border-color: #2A4060;
  color: #fff;
}

.site-chat__cta-btn {
  width: 100%;
  background: #1D2D44;
  border-color: #1D2D44;
  color: #fff;
  border-radius: 12px;
  min-height: 42px;
  font-size: 0.88rem;
}

.site-chat__cta-btn:hover {
  background: #2A4060;
  border-color: #2A4060;
  color: #fff;
}

.site-chat__cta-hint {
  margin: 0;
  width: 100%;
  font-size: 0.72rem;
  color: #5b6b7c;
  text-align: center;
}

.site-chat__lead-dock {
  min-height: 0;
  overflow: auto;
  border-top: 1px solid rgba(8, 17, 31, 0.08);
  background: #f7fafc;
  -webkit-overflow-scrolling: touch;
}

.site-chat__lead-dock[hidden] {
  display: none !important;
}

.site-chat__gate {
  border-top: 1px solid rgba(8, 17, 31, 0.08);
  background: linear-gradient(180deg, #f4f8fc, #eef5fb);
  padding: 0.75rem 0.85rem 0.85rem;
}

.site-chat__gate[hidden],
.site-chat__gate.is-done {
  display: none !important;
}

.site-chat__gate-card {
  display: grid;
  gap: 0.45rem;
  justify-items: center;
  text-align: center;
}

.site-chat__gate-card strong {
  font-size: 0.9rem;
  color: #10233a;
}

.site-chat__gate-card > p {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: #5b6b7c;
  max-width: 32ch;
}

.site-chat__gate-status {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 650;
  color: #1D2D44;
}

.site-chat__captcha-box--gate {
  width: 100%;
  padding: 0.15rem 0;
}

.site-chat__inline-link {
  color: #1D2D44;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-chat__bubble--bot .site-chat__inline-link {
  color: #2A4060;
}

.site-chat__composer.is-locked {
  opacity: 0.72;
}

.site-chat__composer.is-locked input[type="text"] {
  cursor: not-allowed;
  background: #eef2f6;
}

.site-chat__lead-card {
  background: #fff;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

.site-chat__lead-head {
  position: relative;
  padding: 0.85rem 2.4rem 0.7rem 0.95rem;
  background: linear-gradient(160deg, #f3f8fc, #eef5fb);
  border-bottom: 1px solid rgba(8, 17, 31, 0.06);
}

.site-chat__lead-head strong {
  display: block;
  font-size: 0.92rem;
  color: #10233a;
}

.site-chat__lead-head p {
  margin: 0.25rem 0 0;
  font-size: 0.76rem;
  line-height: 1.35;
  color: #5b6b7c;
}

.site-chat__lead-close {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: rgba(8, 17, 31, 0.06);
  color: #334155;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.site-chat__lead-form {
  display: grid;
  gap: 0.55rem;
  padding: 0.75rem 0.9rem 0.9rem;
}

.site-chat__lead-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

@media (max-width: 420px) {
  .site-chat__lead-grid {
    grid-template-columns: 1fr;
  }
}

.site-chat__lead-form label {
  display: grid;
  gap: 0.28rem;
}

.site-chat__lead-form label span {
  font-size: 0.74rem;
  font-weight: 700;
  color: #3b4d63;
}

.site-chat__lead-form label em {
  font-style: normal;
  font-weight: 500;
  color: #7a8898;
}

.site-chat__lead-form input,
.site-chat__lead-form textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(8, 17, 31, 0.14);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.88rem;
  color: #132033;
  background: #f8fafc;
}

.site-chat__lead-form input:focus,
.site-chat__lead-form textarea:focus {
  outline: 2px solid rgba(29, 45, 68, 0.28);
  outline-offset: 1px;
  background: #fff;
}

.site-chat__lead-form textarea {
  resize: vertical;
  min-height: 58px;
}

.site-chat__captcha-box {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 78px;
  padding: 0.25rem 0;
  overflow-x: auto;
}

.site-chat__captcha {
  transform: scale(1);
  transform-origin: center center;
  width: 304px;
  min-width: 304px;
  min-height: 78px;
  flex: 0 0 auto;
}

.site-chat__lead-error {
  margin: 0;
  font-size: 0.78rem;
  color: #b42318;
  line-height: 1.35;
}

.site-chat__lead-submit {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: #1D2D44;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.site-chat__lead-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.site-chat__wa {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

.site-chat__wa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 1rem;
  border-radius: 12px;
  background: #25d366;
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(37, 211, 102, 0.28);
}

.site-chat__wa-btn:hover {
  filter: brightness(1.05);
}

.site-chat__wa-hint {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.35;
  color: #5b6b7c;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .site-chat__typing span {
    animation: none !important;
    opacity: 0.7;
  }
}

.site-chat__composer {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid rgba(8, 17, 31, 0.08);
  background: #fff;
}

.site-chat__composer input#site-chat-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  border: 1px solid rgba(8, 17, 31, 0.12);
  border-radius: 12px;
  padding: 0 0.85rem;
  font: inherit;
  font-size: 0.9rem;
  color: #132033;
  background: #f7fafc;
  pointer-events: auto !important;
  -webkit-user-select: text;
  user-select: text;
}

.site-chat__composer input#site-chat-input:focus {
  outline: 2px solid rgba(29, 45, 68, 0.35);
  outline-offset: 1px;
  background: #fff;
}

.site-chat__send {
  height: 44px;
  padding: 0 1rem;
  border: 0;
  border-radius: 12px;
  background: #1D2D44;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.site-chat__send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.site-chat__hp {
  position: absolute !important;
  left: -9999px !important;
  top: auto !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  display: block !important;
  flex: 0 0 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
}

@media (max-width: 768px) {
  .site-chat {
    right: max(0.75rem, env(safe-area-inset-right, 0px));
    left: auto;
    bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
    max-height: none;
    width: auto;
    align-items: stretch;
  }

  /* FAB compacto tipo WhatsApp */
  .site-chat__fab {
    align-self: flex-end;
    min-height: 56px;
    min-width: 56px;
    width: 56px;
    height: 56px;
    padding: 0;
    gap: 0;
    border-radius: 50%;
    justify-content: center;
  }

  .site-chat__fab-copy,
  .site-chat__fab-sub {
    display: none !important;
  }

  .site-chat__fab-icon {
    width: 42px;
    height: 42px;
  }

  .site-chat__fab-icon svg {
    width: 22px;
    height: 22px;
  }

  .site-chat__fab-pulse {
    left: 50%;
    top: 50%;
    width: 52px;
    height: 52px;
    margin: -26px 0 0 -26px;
  }

  /* Panel casi a pantalla completa */
  .site-chat__panel {
    position: fixed;
    inset: max(0.5rem, env(safe-area-inset-top, 0px))
      max(0.5rem, env(safe-area-inset-right, 0px))
      max(0.5rem, env(safe-area-inset-bottom, 0px))
      max(0.5rem, env(safe-area-inset-left, 0px));
    width: auto;
    height: auto;
    max-height: none;
    border-radius: 18px;
    z-index: 1201;
  }

  .site-chat.is-open .site-chat__fab {
    display: none;
  }

  .site-chat__head {
    padding: 0.85rem 0.9rem;
  }

  .site-chat__head strong {
    font-size: 0.92rem;
  }

  .site-chat__head p {
    font-size: 0.72rem;
  }

  .site-chat__messages {
    padding: 0.75rem;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .site-chat__bubble {
    max-width: 92%;
    font-size: 0.88rem;
  }

  .site-chat__composer {
    padding: 0.65rem;
    padding-bottom: max(0.65rem, env(safe-area-inset-bottom, 0px));
  }

  .site-chat__composer input#site-chat-input,
  .site-chat__send {
    height: 46px;
    font-size: 16px; /* evita zoom automático en iOS */
  }
}

@media (max-width: 380px) {
  .site-chat__panel {
    inset: 0;
    border-radius: 0;
  }
}

body.nav-open .site-chat {
  z-index: 900;
}

body.nav-open .site-chat {
  visibility: hidden;
  pointer-events: none;
}
