/* ===========================================================================
   NEXT: panel lateral de conversación (explorar.html)
   Reemplaza el cuadro de NEXT que estaba debajo del título del hero.
   Prefijo .nd-*. Los estilos del chat replican los que tenía el hero.
   =========================================================================== */

/* --- Hero sin el cuadro de NEXT ------------------------------------------ */
/* Sin el chat debajo, el hero ya no necesita ocupar toda la pantalla. */
@media (max-width: 1080px) {
  .hero {
    min-height: 0;
    padding-bottom: 72px;
  }
}

/* --- Llamado en el hero ------------------------------------------------- */
.nd-hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 30px;
  min-height: 48px;
  padding: 0 22px 0 14px;
  color: #f1f1ef;
  font: inherit;
  font-size: 0.98rem;
  font-weight: 500;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.nd-hero-cta img {
  display: block;
  width: 22px;
  height: 22px;
}

.nd-hero-cta span {
  color: var(--green);
  transition: transform 0.2s ease;
}

.nd-hero-cta:hover,
.nd-hero-cta:focus-visible {
  border-color: transparent;
  background:
    linear-gradient(#000, #000) padding-box,
    linear-gradient(90deg, var(--green), var(--blue)) border-box;
  box-shadow: 0 0 28px rgba(70, 177, 225, 0.16);
  outline: none;
}

.nd-hero-cta:hover span {
  transform: translateX(3px);
}

/* --- Píldora del header con conversación en curso ----------------------- */
.nm-pill--active {
  position: relative;
}

.nm-pill--active::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 9px;
  height: 9px;
  background: var(--green);
  border: 2px solid #000;
  border-radius: 50%;
}

/* --- Contenedor, fondo y panel ----------------------------------------- */
.nd {
  position: fixed;
  inset: 0;
  z-index: 120;
  visibility: hidden;
  pointer-events: none;
}

.nd.is-open {
  visibility: visible;
  pointer-events: auto;
}

.nd-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.nd.is-open .nd-backdrop {
  opacity: 1;
}

.nd-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(480px, 100vw);
  height: 100%;
  background: #08090a;
  box-shadow: -24px 0 80px rgba(0, 0, 0, 0.6);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Borde izquierdo con el degradado CICLIC */
.nd-panel::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 1.5px;
  background: linear-gradient(180deg, var(--green), var(--blue));
}

.nd.is-open .nd-panel {
  transform: none;
}

body.nd-lock {
  overflow: hidden;
}

/* --- Encabezado del panel ---------------------------------------------- */
.nd-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 16px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.nd-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nd-identity img {
  display: block;
  width: 36px;
  height: 36px;
}

.nd-identity strong {
  display: block;
  color: #f1f1ef;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.nd-identity span {
  display: block;
  margin-top: 2px;
  color: #98989d;
  font-size: 0.78rem;
}

.nd-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: #c7c7cc;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.nd-close:hover,
.nd-close:focus-visible {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.32);
  outline: none;
}

/* --- Cuerpo: saludo + conversación (con scroll) ------------------------- */
.nd-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  padding: 28px 24px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.nd-hello {
  order: 0;
}

/* Con conversación en curso, la pregunta de NEXT va al final (junto al campo) */
.nd-body:has(.result-panel:not(.is-empty)) .nd-hello {
  order: 2;
  margin-top: 18px;
}

.nd-body:has(.result-panel:not(.is-empty)) .nd-hello-title {
  display: none;
}

.nd-hello-title {
  margin: 0 0 10px;
  color: #ffffff;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.15;
}

.nd-panel .assistant-row {
  display: flex;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
}

.nd-panel .assistant-row[hidden] {
  display: none;
}

.nd-panel .assistant-dot {
  display: none;
}

.nd-panel .assistant-row p {
  margin: 0;
  color: #c7c7cc;
  font-size: 1.02rem;
  line-height: 1.5;
}

/* El panel de resultados deja de ser tarjeta: fluye dentro del cuerpo */
.nd-panel .result-panel {
  order: 1;
  min-height: 0;
  max-height: none;
  padding: 0;
  overflow: visible;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.nd-panel .result-panel.is-empty {
  display: none;
}

.nd-panel .chat-thread {
  gap: 14px;
}

.nd-panel .chat-message {
  max-width: 88%;
  gap: 0;
  padding: 13px 16px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.55;
}

.nd-panel .message-label {
  display: none;
}

.nd-panel .assistant-message .message-label {
  display: block;
  margin-bottom: 6px;
  color: var(--green);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.nd-panel .user-message {
  background: #1d2b16;
  border: 1px solid rgba(89, 231, 33, 0.22);
}

.nd-panel .user-message p,
.nd-panel .assistant-message p {
  color: #f1f1ef;
}

.nd-panel .assistant-message {
  background: #141516;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.nd-panel .consultative-response {
  gap: 10px;
}

.nd-panel .consultative-response .response-context {
  color: #98989d;
}

.nd-panel .follow-up-question {
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
}

.nd-panel .follow-up-question h3 {
  display: none;
}

.nd-panel .follow-up-question p {
  color: #f1f1ef;
  font-weight: 600;
}

.nd-panel .final-diagnosis {
  max-width: 100%;
  border-radius: 16px;
}

/* El diagnóstico es largo: en el panel angosto, las tarjetas van en una columna */
.nd-panel .opportunity-grid,
.nd-panel .recommended-learning-grid {
  grid-template-columns: minmax(0, 1fr);
}

/* --- Campo de respuesta (fijo abajo) ------------------------------------ */
.nd-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 0 16px 16px;
  padding: 8px 8px 8px 18px;
  background: #141516;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.nd-form:focus-within {
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 0 0 3px rgba(89, 231, 33, 0.22);
}

.nd-form textarea,
.nd-form textarea:focus {
  flex: 1;
  min-width: 0;
  min-height: 76px;
  max-height: 160px;
  padding: 10px 0;
  color: #f1f1ef;
  font: inherit;
  font-size: 16px;
  line-height: 1.45;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  resize: none;
}

.nd-form textarea::placeholder {
  color: #6b6b72;
  font-size: 15px;
}

.nd-form .prompt-actions {
  flex-direction: row;
  margin: 0;
}

.nd-form #prompt-hint {
  display: none;
}

.nd-form .prompt-actions button {
  width: auto;
  min-height: 40px;
  padding: 0 18px;
  color: #0a0a0b;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--green);
  border: 0;
  border-radius: 999px;
  box-shadow: none;
  cursor: pointer;
}

.nd-form .prompt-actions button:hover {
  background: #7ef04a;
}

.nd-form .prompt-actions button:disabled {
  opacity: 0.5;
}

/* --- Celular: pantalla completa ---------------------------------------- */
@media (max-width: 600px) {
  .nd-panel {
    width: 100vw;
    height: 100dvh;
  }

  .nd-panel::before {
    display: none;
  }

  .nd-head {
    padding: 14px 14px 12px 18px;
  }

  .nd-body {
    padding: 22px 18px 16px;
  }

  .nd-panel .chat-message {
    max-width: 100%;
  }

  .nd-form {
    margin: 0 12px calc(12px + env(safe-area-inset-bottom));
  }

  .nd-form textarea,
  .nd-form textarea:focus {
    min-height: 88px;
  }

  .nd-form textarea::placeholder {
    font-size: 14px;
  }

  .nd-hero-cta {
    margin-top: 24px;
    font-size: 0.92rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nd-panel,
  .nd-backdrop {
    transition: none;
  }
}
