/* ═══════════════════════════════════════════════════════════
   Punto D' Partida — Asistente conversacional v4
   Fondo sólido · flujo chat · cero transparencias conflictivas
   ═══════════════════════════════════════════════════════════ */

.pdp-assistant-root {
  --asst-neon: #60ff01;
  --asst-neon-soft: #9dff5c;
  --asst-bg: #0a0d0a;
  --asst-bg-elevated: #111611;
  --asst-surface: #161b16;
  --asst-border: rgba(96, 255, 1, 0.22);
  --asst-text: #f2f4f2;
  --asst-muted: #9aa39a;
  --asst-user-bg: #1a2e12;
  --asst-user-border: rgba(96, 255, 1, 0.35);
  --asst-offset: var(--pdp-cookie-offset, 0px);
  --asst-lift: calc(88px + var(--asst-offset));
  font-family: Inter, system-ui, sans-serif;
}

/* ─── Backdrop sólido (oscurece página, no el panel) ─── */
.pdp-assistant-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99996;
  background: #000000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}

.pdp-assistant-backdrop.is-visible {
  opacity: 0.62;
  visibility: visible;
  pointer-events: auto;
}

/* ─── Launcher FAB ─── */
.pdp-assistant-launcher {
  position: fixed;
  right: clamp(16px, 3vw, 24px);
  bottom: var(--asst-lift);
  z-index: 99998;
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  transition: bottom 0.3s ease, transform 0.25s ease, opacity 0.25s ease;
}

.pdp-assistant-launcher.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.85);
}

.pdp-assistant-launcher__btn {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 2px solid var(--asst-border);
  background: #0f120f;
  box-shadow:
    0 10px 36px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  display: grid;
  place-items: center;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.pdp-assistant-launcher__btn img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.pdp-assistant-launcher__pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(96, 255, 1, 0.45);
  animation: asstPulse 2.4s ease-out infinite;
  pointer-events: none;
}

.pdp-assistant-launcher__badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--asst-neon);
  border: 2px solid #0f120f;
  box-shadow: 0 0 10px rgba(96, 255, 1, 0.7);
}

.pdp-assistant-launcher__label {
  padding: 10px 16px;
  border-radius: 999px;
  background: #0f120f;
  border: 1px solid var(--asst-border);
  color: var(--asst-text);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}

.pdp-assistant-launcher:hover .pdp-assistant-launcher__btn {
  transform: translateY(-3px) scale(1.04);
  border-color: rgba(96, 255, 1, 0.55);
  box-shadow:
    0 16px 44px rgba(0, 0, 0, 0.7),
    0 0 28px rgba(96, 255, 1, 0.12);
}

/* ─── Panel principal — 100% opaco ─── */
.pdp-assistant-panel {
  position: fixed;
  right: clamp(12px, 2.5vw, 24px);
  bottom: var(--asst-lift);
  width: min(400px, calc(100vw - 24px));
  height: min(640px, calc(100dvh - var(--asst-lift) - 24px));
  z-index: 99999;
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  overflow: hidden;
  background: #0a0d0a;
  background-color: #0a0d0a;
  border: 1px solid var(--asst-border);
  box-shadow:
    0 28px 90px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(0, 0, 0, 0.6);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transition:
    opacity 0.32s cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0.32s,
    transform 0.32s cubic-bezier(0.16, 1, 0.3, 1),
    bottom 0.3s ease;
  isolation: isolate;
}

.pdp-assistant-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: none;
}

/* ─── Header ─── */
.pdp-assistant-panel__head {
  flex-shrink: 0;
  padding: 16px 16px 14px;
  background: #0f130f;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  position: relative;
}

.pdp-assistant-panel__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-right: 72px;
}

.pdp-assistant-avatar {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: #141a14;
  border: 1px solid var(--asst-border);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}

.pdp-assistant-avatar img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.pdp-assistant-panel__title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--asst-text);
  letter-spacing: -0.01em;
}

.pdp-assistant-panel__subtitle {
  margin: 4px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--asst-muted);
}

.pdp-assistant-panel__status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--asst-neon);
  box-shadow: 0 0 8px rgba(96, 255, 1, 0.65);
  flex-shrink: 0;
}

.pdp-assistant-panel__status-dot.is-busy {
  background: #fbbf24;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.55);
  animation: asstBusy 1s ease infinite;
}

.pdp-assistant-panel__actions {
  position: absolute;
  top: 14px;
  right: 12px;
  display: flex;
  gap: 6px;
}

.pdp-assistant-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #141814;
  color: #b4bdb4;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.pdp-assistant-icon-btn:hover {
  color: var(--asst-neon);
  border-color: var(--asst-border);
  background: #1a221a;
}

/* ─── Thread (mensajes + quick replies) ─── */
.pdp-assistant-thread {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--asst-bg);
  overflow: hidden;
}

.pdp-assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  background: var(--asst-bg);
}

.pdp-assistant-messages::-webkit-scrollbar {
  width: 5px;
}

.pdp-assistant-messages::-webkit-scrollbar-thumb {
  background: rgba(96, 255, 1, 0.25);
  border-radius: 999px;
}

/* ─── Mensajes ─── */
.pdp-assistant-msg {
  display: flex;
  gap: 8px;
  max-width: 100%;
  animation: asstMsgIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.pdp-assistant-msg--user {
  flex-direction: row-reverse;
  align-self: flex-end;
  max-width: 88%;
}

.pdp-assistant-msg--bot {
  align-self: flex-start;
  max-width: 92%;
}

.pdp-assistant-msg__avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin-top: 2px;
  border-radius: 9px;
  background: #141a14;
  border: 1px solid rgba(96, 255, 1, 0.18);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.pdp-assistant-msg__avatar img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.pdp-assistant-msg--user .pdp-assistant-msg__avatar {
  display: none;
}

.pdp-assistant-msg__content {
  min-width: 0;
  flex: 1;
}

.pdp-assistant-msg__body {
  padding: 12px 14px;
  border-radius: 18px;
  font-size: 0.86rem;
  line-height: 1.55;
  word-break: break-word;
}

.pdp-assistant-msg--bot .pdp-assistant-msg__body {
  background: var(--asst-surface);
  color: var(--asst-text);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-bottom-left-radius: 6px;
}

.pdp-assistant-msg--user .pdp-assistant-msg__body {
  background: var(--asst-user-bg);
  color: #ecfccb;
  border: 1px solid var(--asst-user-border);
  border-bottom-right-radius: 6px;
}

.pdp-assistant-msg__body a {
  color: var(--asst-neon-soft);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.pdp-assistant-msg__body strong {
  color: #fff;
  font-weight: 700;
}

.pdp-assistant-msg__body--typing {
  padding: 14px 18px;
  min-width: 64px;
}

.pdp-assistant-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 10px;
}

.pdp-assistant-typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--asst-neon);
  animation: asstDot 1.2s ease-in-out infinite;
}

.pdp-assistant-typing i:nth-child(2) { animation-delay: 0.15s; }
.pdp-assistant-typing i:nth-child(3) { animation-delay: 0.3s; }

.pdp-assistant-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.pdp-assistant-action {
  border: 1px solid rgba(96, 255, 1, 0.35);
  background: #142014;
  color: var(--asst-neon);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.pdp-assistant-action:hover {
  background: #1c2e1c;
  transform: translateY(-1px);
}

/* ─── Quick replies (flujo conversacional) ─── */
.pdp-assistant-welcome {
  flex-shrink: 0;
  padding: 0 14px 12px;
  background: var(--asst-bg);
}

.pdp-assistant-welcome[hidden] {
  display: none !important;
}

.pdp-assistant-welcome__label {
  margin: 0 0 8px 36px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--asst-muted);
}

.pdp-assistant-welcome__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding-left: 36px;
}

.pdp-assistant-welcome__card {
  border: 1px solid rgba(96, 255, 1, 0.28);
  background: #121812;
  color: var(--asst-text);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.pdp-assistant-welcome__card:hover {
  background: #182418;
  border-color: rgba(96, 255, 1, 0.5);
  transform: translateY(-1px);
}

/* ─── Sugerencias post-respuesta ─── */
.pdp-assistant-suggestions {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  padding: 0 14px 10px;
  overflow-x: auto;
  background: var(--asst-bg);
  scrollbar-width: none;
}

.pdp-assistant-suggestions[hidden] {
  display: none !important;
}

.pdp-assistant-suggestions button {
  flex: 0 0 auto;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  background: #111511;
  color: #d4d8d4;
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.2s, color 0.2s;
}

.pdp-assistant-suggestions button:hover {
  border-color: rgba(96, 255, 1, 0.4);
  color: var(--asst-neon);
}

/* ─── Composer ─── */
.pdp-assistant-compose {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: #0f130f;
}

.pdp-assistant-compose textarea {
  flex: 1;
  min-height: 46px;
  max-height: 120px;
  resize: none;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0a0e0a;
  color: #fff;
  padding: 12px 14px;
  font: inherit;
  font-size: 0.86rem;
  line-height: 1.45;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.pdp-assistant-compose textarea::placeholder {
  color: #6b756b;
}

.pdp-assistant-compose textarea:focus {
  border-color: rgba(96, 255, 1, 0.45);
  box-shadow: 0 0 0 3px rgba(96, 255, 1, 0.1);
}

.pdp-assistant-send {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border: none;
  border-radius: 14px;
  background: linear-gradient(145deg, #7aff1a, var(--asst-neon));
  color: #0a0d0a;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.2s, opacity 0.2s;
  box-shadow: 0 6px 20px rgba(96, 255, 1, 0.25);
}

.pdp-assistant-send:hover:not(:disabled) {
  transform: scale(1.05);
}

.pdp-assistant-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pdp-assistant-foot {
  flex-shrink: 0;
  margin: 0;
  padding: 0 14px 12px;
  font-size: 0.64rem;
  color: #6b756b;
  text-align: center;
  background: #0f130f;
}

/* ─── Lead form ─── */
.pdp-assistant-lead .pdp-assistant-msg__body {
  margin-bottom: 4px;
}

.pdp-assistant-lead__form {
  display: grid;
  gap: 10px;
  margin-top: 8px;
  padding: 14px;
  border-radius: 14px;
  background: #0f130f;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.pdp-assistant-lead__form label {
  display: grid;
  gap: 5px;
  font-size: 0.68rem;
  color: var(--asst-muted);
  font-weight: 700;
}

.pdp-assistant-lead__form input,
.pdp-assistant-lead__form select,
.pdp-assistant-lead__form textarea {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0a0e0a;
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.pdp-assistant-lead__submit {
  border: none;
  border-radius: 12px;
  padding: 12px;
  background: var(--asst-neon);
  color: #0a0d0a;
  font-weight: 800;
  cursor: pointer;
}

.pdp-assistant-lead__ok {
  margin: 0;
  padding: 12px;
  color: var(--asst-neon);
  font-weight: 600;
}

/* ─── Animations ─── */
@keyframes asstMsgIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes asstDot {
  0%, 80%, 100% { opacity: 0.35; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

@keyframes asstPulse {
  0% { transform: scale(1); opacity: 0.55; }
  100% { transform: scale(1.35); opacity: 0; }
}

@keyframes asstBusy {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ─── Mobile: pantalla completa sólida ─── */
@media (max-width: 640px) {
  .pdp-assistant-launcher__label {
    display: none;
  }

  .pdp-assistant-backdrop.is-visible {
    opacity: 0.75;
  }

  .pdp-assistant-panel {
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: 100dvh;
    bottom: 0 !important;
    right: 0;
    border-radius: 0;
    border: none;
  }

  .pdp-assistant-welcome__grid {
    padding-left: 0;
  }

  .pdp-assistant-welcome__label {
    margin-left: 0;
  }

  .pdp-assistant-compose {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .pdp-assistant-foot {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}
