/*
 * NPS & feedback card styles (issue #114).
 *
 * Shared by the in-app report pop-up (rendered inside `.nps-overlay`) and the
 * standalone no-login web form (`.nps-standalone`). The `.nps-card` block is
 * identical in both; only the surrounding chrome differs. Palette mirrors the
 * NeuroClarity shell (deep teal text, terracotta accent, warm off-white).
 */

:root {
  --nps-ink: #264653;
  --nps-muted: #637a83;
  --nps-accent: #d06c52;
  --nps-accent-strong: #9e3b1b;
  --nps-border: #efe5d6;
  --nps-surface: #ffffff;
  --nps-soft: #fdf3ee;
}

/* -- In-app overlay -------------------------------------------------------- */
.nps-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  /* `safe center` + `overflow-y: auto`: centre the card when it fits, but
     top-anchor and scroll when the follow-up step (prompt + resizable comment
     textarea + consent + Submit) grows taller than a short viewport, so the
     Submit button is never stranded below the fold (issue #202). Plain
     `align-items: center` centres the overflow off both edges unreachably. */
  align-items: safe center;
  justify-content: center;
  overflow-y: auto;
  padding: 20px;
}
.nps-overlay .nps-scrim {
  /* `fixed`, not `absolute`: `.nps-overlay` scrolls (overflow-y:auto, #202), and
     an `absolute; inset:0` scrim is sized to the visible box and scrolls away
     with the content — once the card is scrolled the bottom band of the viewport
     loses its dim/blur in the gutters beside the card. `fixed` pins the scrim to
     the viewport so it always covers the full screen; it still renders inside the
     overlay's stacking context, below the `z-index:1` body. */
  position: fixed;
  inset: 0;
  background: rgba(38, 70, 83, 0.42);
  backdrop-filter: blur(2px);
}
.nps-overlay .nps-overlay-body {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
}

/* -- The card -------------------------------------------------------------- */
.nps-card {
  position: relative;
  background: var(--nps-surface);
  border: 1px solid var(--nps-border);
  border-radius: 20px;
  padding: 28px 26px 24px;
  box-shadow: 0 18px 48px rgba(38, 70, 83, 0.18);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--nps-ink);
  animation: nps-pop 180ms ease-out;
}
@keyframes nps-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.nps-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--nps-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: background 120ms ease, color 120ms ease;
}
.nps-close:hover { background: var(--nps-soft); color: var(--nps-ink); }

.nps-step { margin-top: 6px; }

.nps-question,
.nps-prompt {
  margin: 0 0 18px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  padding-right: 20px;
}
.nps-prompt { font-weight: 500; }

/* -- 0–10 scale ------------------------------------------------------------ */
.nps-scale {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 6px;
}
.nps-scale-btn {
  appearance: none;
  border: 1px solid #e3b9aa;
  background: var(--nps-soft);
  color: var(--nps-ink);
  border-radius: 9px;
  padding: 10px 0;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, transform 80ms ease;
}
.nps-scale-btn:hover {
  background: var(--nps-accent);
  color: #fff;
  transform: translateY(-1px);
}
.nps-scale-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--nps-muted);
}

/* -- Follow-up + promoter -------------------------------------------------- */
.nps-textarea {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 96px;
  padding: 12px 14px;
  border: 1px solid var(--nps-border);
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
  color: var(--nps-ink);
  background: #fffdfb;
}
.nps-textarea:focus {
  outline: none;
  border-color: var(--nps-accent);
  box-shadow: 0 0 0 3px rgba(208, 108, 82, 0.15);
}

.nps-thanks-header {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
}
.nps-thanks-body {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--nps-muted);
}

.nps-review-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 18px;
}
.nps-review-link {
  flex: 1 1 auto;
  text-align: center;
  padding: 11px 16px;
  border: 1px solid var(--nps-accent);
  border-radius: 999px;
  color: var(--nps-accent-strong);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background 120ms ease, color 120ms ease;
}
.nps-review-link:hover { background: var(--nps-accent); color: #fff; }

.nps-consent {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
  line-height: 1.5;
  color: var(--nps-muted);
  margin-bottom: 18px;
  cursor: pointer;
}
.nps-consent input { margin-top: 2px; }

/* -- Actions --------------------------------------------------------------- */
.nps-actions { display: flex; justify-content: flex-end; }
.nps-btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 12px 26px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.nps-btn--primary { background: var(--nps-accent); color: #fff; }
.nps-btn--primary:hover { background: var(--nps-accent-strong); }

/* -- Standalone (public) page --------------------------------------------- */
.nps-standalone {
  min-height: 100vh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  background: #fef9f0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.nps-standalone-inner { width: 100%; max-width: 460px; }
.nps-standalone-brand {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--nps-ink);
  margin-bottom: 16px;
}
/* The X shows on every surface (issue #114 requires a clear close affordance
   at any point in the flow). On the standalone page there's nothing to return
   to, so closing shows a short thank-you note (see nps-form.js onClose). */
.nps-standalone-error {
  text-align: center;
  color: var(--nps-muted);
  font-size: 15px;
  background: var(--nps-surface);
  border: 1px solid var(--nps-border);
  border-radius: 20px;
  padding: 32px 26px;
}

/* -- Small screens --------------------------------------------------------- */
@media (max-width: 420px) {
  .nps-card { padding: 24px 18px 20px; border-radius: 16px; }
  .nps-scale { gap: 4px; }
  .nps-scale-btn { padding: 9px 0; font-size: 13px; }
  .nps-review-links { flex-direction: column; }
}

/* ==========================================================================
 * Admin NPS Insights dashboard (issue #192).
 *
 * The capture card above is patient-facing; this block styles the admin-only
 * rollup rendered by AdminNpsView/AdminNpsPage: the clickable Promoter/Passive/
 * Detractor breakdown filters, the touchpoint response funnel, the Patient
 * Feedback search + list, and the per-report NPS funnel-log dropdown. Scoped
 * under `.admin-nps-*` so it never touches the capture card. Only loaded in
 * admin.html; the shell provides Tailwind utilities + Font Awesome.
 * ========================================================================== */

.admin-nps-section {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(38, 70, 83, 0.12);
  border-radius: 16px;
  padding: 16px;
}
.admin-nps-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.admin-nps-section-title {
  font-size: 13px;
  font-weight: 700;
  color: #264653;
  margin: 0;
}
.admin-nps-section-title i { color: #5c737a; margin-right: 6px; }
.admin-nps-hint { font-size: 11px; color: #97a6ac; margin: 4px 0 12px; }

/* -- Clickable breakdown filter cards ------------------------------------- */
.admin-nps-bracket {
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(38, 70, 83, 0.10);
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.admin-nps-bracket:hover { background: rgba(255, 255, 255, 0.9); }
.admin-nps-bracket.is-active {
  border-color: var(--nps-accent, #264653);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--nps-accent, #264653) 30%, transparent);
  background: #fff;
}
.admin-nps-bracket:focus-visible {
  outline: 3px solid rgba(74, 157, 138, 0.4);
  outline-offset: 2px;
}
.admin-nps-bracket-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.admin-nps-bracket-label { font-size: 12px; font-weight: 600; }
.admin-nps-bracket-range { font-size: 11px; color: #5c737a; }
.admin-nps-bracket-count { font-size: 17px; font-weight: 700; color: #264653; margin: 0; }
.admin-nps-bracket-pct { font-size: 11px; font-weight: 500; color: #5c737a; }

.admin-nps-clear,
.admin-nps-search-clear {
  border: none;
  background: transparent;
  color: #5c737a;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
}
.admin-nps-clear:hover,
.admin-nps-search-clear:hover { background: rgba(38, 70, 83, 0.08); color: #264653; }

/* -- Touchpoint funnel stats ---------------------------------------------- */
/* Auto-fit so the funnel reflows cleanly whatever the touchpoint count (the
   legacy "Email (untracked)" card makes it five) instead of a hard column count. */
.admin-nps-funnel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.admin-nps-funnel-stat {
  padding: 10px 8px;
  border-radius: 12px;
  text-align: center;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(38, 70, 83, 0.10);
}
.admin-nps-funnel-value { font-size: 18px; font-weight: 700; color: #264653; margin: 0; }
.admin-nps-funnel-label { font-size: 11px; color: #5c737a; margin: 2px 0 0; }

/* -- Patient Feedback search field ---------------------------------------- */
.admin-nps-feedback-head { align-items: center; }
.admin-nps-search { position: relative; display: flex; align-items: center; }
.admin-nps-search-icon {
  position: absolute;
  left: 10px;
  font-size: 12px;
  color: #97a6ac;
  pointer-events: none;
}
.admin-nps-search-input {
  padding: 7px 28px 7px 28px;
  border-radius: 999px;
  border: 1px solid rgba(38, 70, 83, 0.18);
  background: #fff;
  font-size: 12px;
  color: #264653;
  min-width: 240px;
}
.admin-nps-search-input:focus-visible {
  outline: none;
  border-color: var(--nps-accent, #d06c52);
  box-shadow: 0 0 0 3px rgba(208, 108, 82, 0.18);
}
.admin-nps-search-clear { position: absolute; right: 4px; }

/* -- Feedback rows + funnel-log dropdown ---------------------------------- */
.admin-nps-empty { font-size: 12px; color: #5c737a; text-align: center; padding: 16px 0; }
.admin-nps-fb-row {
  background: rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 8px;
}
.admin-nps-log { }
.admin-nps-fb-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  cursor: pointer;
  list-style: none;
}
.admin-nps-fb-head::-webkit-details-marker { display: none; }
.admin-nps-caret { color: #97a6ac; font-size: 10px; width: 12px; transition: transform 0.12s ease; }
.admin-nps-log[open] .admin-nps-caret { transform: rotate(90deg); }
.admin-nps-score {
  font-size: 12px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
}
.admin-nps-score-na { background: rgba(38, 70, 83, 0.06); color: #97a6ac; }
.admin-nps-name {
  font-size: 12px;
  font-weight: 600;
  color: #1f6f8b;
  cursor: pointer;
  text-decoration: none;
}
.admin-nps-name:hover { text-decoration: underline; }
.admin-nps-name:focus-visible { outline: 2px solid rgba(74, 157, 138, 0.5); outline-offset: 2px; border-radius: 4px; }
.admin-nps-pill {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.admin-nps-pill i { margin-right: 4px; }
.admin-nps-pill-share { background: rgba(47, 143, 107, 0.14); color: #2f8f6b; }
.admin-nps-pill-private { background: rgba(38, 70, 83, 0.06); color: #97a6ac; font-weight: 500; }
.admin-nps-meta { font-size: 11px; color: #97a6ac; margin-left: auto; }
.admin-nps-comment { font-size: 13px; color: #4a5e66; line-height: 1.5; margin: 6px 0 0 20px; }
.admin-nps-log-body {
  margin: 8px 0 2px 20px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(38, 70, 83, 0.04);
}
.admin-nps-log-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  color: #5c737a;
  padding: 2px 0;
}
.admin-nps-log-line b { color: #264653; font-weight: 600; }
