/**
 * NPS Digital — cartão de inquérito não-bloqueante (RF003 / Task 8515).
 * Dock fixo; página por baixo continua utilizável (sem overlay).
 */
.nps-dock {
  --nps-primary: #002a60;
  --nps-muted: #4e4e4e;
  --nps-border: #cfd8e3;
  --nps-card: rgba(255, 255, 255, 0.78);
  --nps-card-solid: #ffffff;
  --nps-shadow: 0 12px 36px rgba(0, 42, 96, 0.22), 0 2px 10px rgba(0, 42, 96, 0.12);
  --nps-radius: 16px;
  --nps-font: "Ubuntu", "Inter", system-ui, sans-serif;

  position: fixed;
  right: 18px;
  bottom: 18px;
  width: min(360px, calc(100vw - 36px));
  z-index: 1040;
  font-family: var(--nps-font);
  color: #232323;
  line-height: 1.45;
  pointer-events: none;
  display: block; /* evita conflito com .is-visible { display:flex } do site */
}

/* Acima do launcher Visor (chatwidget) enquanto o inquérito está aberto */
.nps-dock.nps-dock--open {
  pointer-events: auto;
  z-index: 10050;
}

/* Largura por escala — só um pouco mais largo quando precisa; sem crescer em excesso */
.nps-dock.nps-dock--sm {
  width: min(340px, calc(100vw - 36px));
}

.nps-dock.nps-dock--md {
  width: min(440px, calc(100vw - 36px));
}

.nps-dock.nps-dock--lg {
  width: min(440px, calc(100vw - 36px));
}

.nps-dock[hidden] {
  display: none !important;
}

/* Região só para leitores de ecrã (RNF003) */
.nps-live {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Acima do botão do chatbot quando ambos estão presentes */
body:has(.chatbot) .nps-dock {
  bottom: 110px;
}

.nps-card {
  position: relative;
  background: var(--nps-card);
  border: 0;
  border-radius: var(--nps-radius);
  box-shadow: var(--nps-shadow);
  padding: 18px 20px 16px;
  /* Vidro fosco: blur + transparência, texto continua em navy escuro */
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  animation: nps-dock-in 0.28s ease-out;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .nps-card {
    background: var(--nps-card-solid);
  }
}

@keyframes nps-dock-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.nps-top {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  margin-bottom: 14px;
  text-align: center;
  padding-left: 28px;
  padding-right: 28px; /* simétrico com o × para a pergunta ficar centrada */
}

.nps-top-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  text-align: center;
}

.nps-kicker {
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--nps-muted);
  margin: 0;
}

.nps-question {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--nps-primary);
  line-height: 1.3;
  text-align: center;
  width: 100%;
  text-wrap: balance;
}

.nps-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--nps-primary);
  font-size: 1.35rem;
  line-height: 1;
  border-radius: 8px;
  padding: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.nps-close:hover,
.nps-close:focus-visible {
  background: #e8eef5;
  outline: 2px solid var(--nps-primary);
  outline-offset: 2px;
}

.nps-anchors {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--nps-muted);
  margin: 4px 0 10px;
  text-align: center;
}

.nps-anchors span {
  display: inline-flex;
  align-items: center;
  max-width: 42%;
}

.nps-scale {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 0 auto;
}

.nps-scale.nps-0-10 {
  flex-wrap: nowrap;
  gap: 4px;
  width: auto;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  justify-content: center;
}

.nps-scale.csat-5,
.nps-scale.ces-7 {
  flex-wrap: nowrap;
}

.nps-scale button {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(0, 42, 96, 0.28);
  background: rgba(255, 255, 255, 0.92);
  color: #002a60;
  font-family: inherit;
  font-weight: 500;
  font-size: 0.9rem;
  display: grid;
  place-items: center;
  cursor: pointer;
}

/* 0–10: flex para caber ≥44px de alvo sem partir o cartão */
.nps-scale.nps-0-10 button {
  width: auto;
  height: 44px;
  min-width: 0;
  min-height: 44px;
  flex: 1 1 0;
  max-width: 44px;
  font-size: 0.82rem;
}

.nps-scale button:hover,
.nps-scale button:focus-visible {
  border-color: var(--nps-primary);
  outline: 2px solid var(--nps-primary);
  outline-offset: 2px;
}

.nps-scale button.is-selected {
  background: var(--nps-primary);
  border-color: var(--nps-primary);
  color: #fff;
}

.nps-scale.choice {
  display: flex;
  width: 100%;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: stretch;
  align-items: stretch;
}

.nps-scale.choice button {
  width: 0; /* força larguras iguais com flex */
  flex: 1 1 0;
  min-width: 0;
  max-width: none;
  height: auto;
  min-height: 44px;
  padding: 10px 8px;
  font-size: 0.78rem;
  white-space: normal;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}

.nps-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.nps-dock .nps-actions .nps-btn {
  border-radius: 50px;
  padding: 10px 22px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  border: 0;
  min-width: 120px;
  min-height: 44px;
  cursor: pointer;
  background-color: #002a60;
  background-image: none;
  color: #ffffff;
  box-shadow: none;
  opacity: 1;
}

/* Inativo: cinza neutro (não azul desbotado) */
.nps-dock .nps-actions .nps-btn:disabled {
  background-color: #d1d5db;
  color: var(--nps-muted);
  opacity: 1;
  cursor: not-allowed;
  filter: none;
}

/* Ativo: azul SABSEG */
.nps-dock .nps-actions .nps-btn:not(:disabled) {
  background-color: #002a60;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 42, 96, 0.2);
  transition: box-shadow 0.15s ease;
}

.nps-dock .nps-actions .nps-btn:not(:disabled):hover,
.nps-dock .nps-actions .nps-btn:not(:disabled):focus-visible {
  background-color: #002a60;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 42, 96, 0.35);
  outline: 2px solid var(--nps-primary);
  outline-offset: 2px;
}

.nps-thanks {
  text-align: center;
  padding: 28px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 100%;
  box-sizing: border-box;
}

.nps-thanks .nps-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #e8eef5;
  color: var(--nps-primary);
  display: grid;
  place-items: center;
}

.nps-thanks .nps-icon svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

.nps-thanks p {
  margin: 0;
  color: var(--nps-primary);
  font-weight: 500;
  font-size: 1.05rem;
}

.nps-card.is-thanks {
  background: rgba(238, 246, 241, 0.88);
  border: 0;
  display: flex;
  align-items: stretch;
  width: 100%;
  box-sizing: border-box;
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
}

.nps-card.is-thanks .nps-thanks {
  width: 100%;
  flex: 1;
}

.nps-error {
  margin: 10px 0 0;
  font-size: 0.78rem;
  color: #b42318;
  text-align: center;
}

.nps-comment {
  margin-top: 4px;
  text-align: center;
}

.nps-comment textarea {
  width: 100%;
  min-height: 72px;
  border: 1px solid rgba(0, 42, 96, 0.28);
  border-radius: 10px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 0.85rem;
  resize: none;
  background: rgba(255, 255, 255, 0.92);
  color: #232323;
  box-sizing: border-box;
}

.nps-comment textarea:focus {
  outline: 2px solid rgba(0, 42, 96, 0.35);
  outline-offset: 1px;
}

.nps-help {
  margin: 6px 0 0;
  font-size: 0.72rem;
  color: var(--nps-muted);
  text-align: center;
}

.nps-privacy {
  margin: 8px 0 0;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--nps-muted);
  text-align: center;
}

.nps-privacy-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.nps-privacy-link:hover,
.nps-privacy-link:focus-visible {
  color: var(--nps-ink, #1a2b3c);
}

@media (max-width: 420px) {
  .nps-dock {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 12px;
  }

  body:has(.chatbot) .nps-dock {
    bottom: 100px;
  }

  .nps-scale.nps-0-10 button {
    width: auto;
    height: 44px;
    min-width: 0;
    min-height: 44px;
    flex: 1 1 0;
    max-width: 44px;
    font-size: 0.75rem;
    border-radius: 8px;
  }

  .nps-scale.nps-0-10 {
    gap: 3px;
  }
}

/* —— Modal (só relationship_v1): mesmo cartão, centrado com fundo escuro —— */
html.nps-modal-open,
body.nps-modal-open {
  overflow: hidden;
}

.nps-dock.nps-dock--modal,
body:has(.chatbot) .nps-dock.nps-dock--modal {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  margin: 0 !important;
  z-index: 10050;
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  background: rgba(0, 26, 61, 0.55);
  pointer-events: auto;
  animation: nps-modal-backdrop-in 0.2s ease-out;
}

.nps-dock.nps-dock--modal[hidden] {
  display: none !important;
}

.nps-dock.nps-dock--modal .nps-card {
  width: min(480px, 100%);
  max-width: 100%;
  margin: 0;
  flex: 0 0 auto;
  background: var(--nps-card-solid);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  animation: nps-modal-card-in 0.28s ease-out;
}

@keyframes nps-modal-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes nps-modal-card-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.nps-dock.nps-dock--modal .nps-actions--modal {
  flex-wrap: wrap;
  gap: 10px;
}

.nps-dock.nps-dock--modal .nps-actions .nps-btn--secondary,
.nps-dock.nps-dock--modal .nps-actions .nps-btn--secondary:not(:disabled) {
  background-color: transparent;
  color: var(--nps-primary);
  border: 1px solid rgba(0, 42, 96, 0.35);
  box-shadow: none;
}

.nps-dock.nps-dock--modal .nps-actions .nps-btn--secondary:hover,
.nps-dock.nps-dock--modal .nps-actions .nps-btn--secondary:focus-visible,
.nps-dock.nps-dock--modal .nps-actions .nps-btn--secondary:not(:disabled):hover,
.nps-dock.nps-dock--modal .nps-actions .nps-btn--secondary:not(:disabled):focus-visible {
  background-color: #e8eef5;
  color: var(--nps-primary);
  box-shadow: none;
  outline: none;
}

@media (max-width: 480px) {
  .nps-dock.nps-dock--modal,
  body:has(.chatbot) .nps-dock.nps-dock--modal {
    padding: 16px;
    align-items: center;
  }

  .nps-dock.nps-dock--modal .nps-actions--modal {
    flex-direction: column-reverse;
  }

  .nps-dock.nps-dock--modal .nps-actions .nps-btn {
    width: 100%;
    min-width: 0;
  }
}
