/* "Generate a full proposal" - confirmation dialog + completion popup.
 *
 * DESIGN NOTE. This dialog has one job: convince the user that what it is
 * about to spend minutes on is the RIGHT target, using only facts. So it is
 * built as an evidence sheet, not a marketing card. Every fact carries the
 * table it came from, set in the mono face, directly under the value. That
 * source line is the signature of this component and the reason it does not
 * look like every other confirm modal in the app - it is the visual form of
 * "this is data, not a guess".
 *
 * Every colour and font here is an existing --helm-* token, so light and
 * dark both work by construction (helm-design.css re-points the tokens under
 * [data-bs-theme="dark"]) and nothing drifts when the palette moves.
 */

.pa-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 37, 68, 0.55);
  z-index: 1085;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4vh 1rem;
  overflow-y: auto;
}

.pa-dialog {
  background: var(--helm-surface, #fff);
  color: var(--helm-text, #1A1D26);
  border: 1px solid var(--helm-border, #E2E6EF);
  border-radius: 10px;
  box-shadow: var(--helm-shadow-lg, 0 8px 24px rgba(27, 58, 107, 0.12));
  width: min(660px, 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  font-family: var(--helm-font, sans-serif);
}

/* ---------------------------------------------------------- header */
.pa-head {
  padding: 1.1rem 1.35rem 0.85rem;
  border-bottom: 1px solid var(--helm-border, #E2E6EF);
}

.pa-eyebrow {
  font-family: var(--helm-font-mono, monospace);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--helm-text-muted, #4B5563);
  margin: 0 0 0.3rem;
}

.pa-title {
  font-size: 1.16rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
}

.pa-kindtag {
  display: inline-block;
  margin-top: 0.45rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid var(--helm-border, #E2E6EF);
  color: var(--helm-text-secondary, #374151);
  background: var(--helm-surface-subtle, #F0F2F8);
}

/* ------------------------------------------------ the warning band
 * Deliberately not dismissible and deliberately above the facts: the
 * mismatch it reports is the single thing most likely to waste the user's
 * time, and burying it under a table would be the same as hiding it. */
.pa-warn {
  margin: 0;
  padding: 0.85rem 1.35rem 0.9rem 1.1rem;
  border-left: 5px solid var(--helm-danger, #d73027);
  background: color-mix(in srgb, var(--helm-danger, #d73027) 10%,
              var(--helm-surface, #fff));
  border-bottom: 1px solid var(--helm-border, #E2E6EF);
}

.pa-warn--caution {
  border-left-color: var(--helm-warning, #fdae61);
  background: color-mix(in srgb, var(--helm-warning, #fdae61) 16%,
              var(--helm-surface, #fff));
}

.pa-warn-head {
  display: flex;
  gap: 0.55rem;
  align-items: baseline;
  font-weight: 700;
  font-size: 0.94rem;
  margin: 0 0 0.3rem;
  color: var(--helm-text, #1A1D26);
}

.pa-warn-detail {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--helm-text-secondary, #374151);
}

/* ---------------------------------------------------------- body */
.pa-body {
  padding: 1rem 1.35rem 1.2rem;
  overflow-y: auto;
}

.pa-sectitle {
  font-family: var(--helm-font-mono, monospace);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--helm-text-muted, #4B5563);
  margin: 1.1rem 0 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--helm-border, #E2E6EF);
}

.pa-sectitle:first-child { margin-top: 0; }

/* The evidence sheet. A definition list, because that is what it is. */
.pa-facts {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(9rem, 34%) 1fr;
  gap: 0.05rem 1rem;
}

.pa-facts dt {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--helm-text-secondary, #374151);
  padding: 0.45rem 0 0.1rem;
}

.pa-facts dd {
  margin: 0;
  padding: 0.45rem 0 0.5rem;
  font-size: 0.9rem;
  color: var(--helm-text, #1A1D26);
  border-bottom: 1px solid var(--helm-border, #E2E6EF);
  overflow-wrap: anywhere;
}

.pa-facts dt + dd { border-bottom: 1px solid var(--helm-border, #E2E6EF); }

/* THE signature: provenance under every value. */
.pa-src {
  display: block;
  margin-top: 0.2rem;
  font-family: var(--helm-font-mono, monospace);
  font-size: 0.68rem;
  line-height: 1.35;
  color: var(--helm-text-muted, #4B5563);
}

.pa-unknown { color: var(--helm-text-muted, #4B5563); font-style: italic; }

/* capability components: quiet bars, the number is what matters */
.pa-comp { display: grid; gap: 0.35rem; }

.pa-comp-row {
  display: grid;
  grid-template-columns: 8.5rem 1fr 2.6rem;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
}

.pa-comp-track {
  height: 6px;
  border-radius: 3px;
  background: var(--helm-surface-subtle, #F0F2F8);
  border: 1px solid var(--helm-border, #E2E6EF);
  overflow: hidden;
}

.pa-comp-fill {
  display: block;
  height: 100%;
  background: var(--helm-primary-fill, #1B3A6B);
}

.pa-comp-fill--low { background: var(--helm-danger-fill, #d73027); }

.pa-comp-val {
  font-family: var(--helm-font-mono, monospace);
  text-align: right;
  color: var(--helm-text-secondary, #374151);
}

/* ------------------------------------------- approach picker (bug 2120)
 * "What kind of proposal is this?" - shown before the facts dialog for an
 * organization target with more than one real option on file. Same card
 * language as the rest of the app's radio-card pickers (e.g. the CRM
 * promote-to-tenant modal), reusing --helm-* tokens so it needs no new
 * palette. */
.pa-approach-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.pa-approach-card {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--helm-border, #E2E6EF);
  border-radius: 8px;
  cursor: pointer;
  background: var(--helm-surface, #fff);
}

.pa-approach-card:hover { background: var(--helm-surface-subtle, #F0F2F8); }

.pa-approach-card--checked {
  border-color: var(--helm-primary-fill, #1B3A6B);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--helm-primary-fill, #1B3A6B) 20%, transparent);
}

.pa-approach-card input[type="radio"] {
  margin-top: 0.2rem;
  flex-shrink: 0;
  accent-color: var(--helm-primary-fill, #1B3A6B);
}

.pa-approach-body { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }

.pa-approach-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--helm-text, #1A1D26);
}

.pa-approach-who,
.pa-approach-strategy {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--helm-text-secondary, #374151);
}

.pa-approach-who strong,
.pa-approach-strategy strong { color: var(--helm-text, #1A1D26); }

.pa-note {
  margin: 0.9rem 0 0;
  padding: 0.6rem 0.75rem;
  border: 1px dashed var(--helm-border, #E2E6EF);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--helm-text-secondary, #374151);
  background: var(--helm-surface-subtle, #F0F2F8);
}

/* ---------------------------------------------------------- footer */
.pa-foot {
  padding: 0.9rem 1.35rem 1.1rem;
  border-top: 1px solid var(--helm-border, #E2E6EF);
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
}

.pa-question {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  flex: 1 1 15rem;
}

.pa-reassure {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--helm-text-muted, #4B5563);
}

.pa-actions { display: flex; gap: 0.5rem; }

.pa-btn {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  border: 1px solid var(--helm-border, #E2E6EF);
  background: var(--helm-surface, #fff);
  color: var(--helm-text, #1A1D26);
}

.pa-btn--go {
  background: var(--helm-primary-fill, #1B3A6B);
  border-color: var(--helm-primary-fill, #1B3A6B);
  color: #fff;
}

.pa-btn--go.pa-btn--risky {
  background: var(--helm-danger-fill, #d73027);
  border-color: var(--helm-danger-fill, #d73027);
}

.pa-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* The completion popup's actions are anchors wearing button chrome ("Open
   the draft", "Download the brief"). Underlined text inside a filled button
   reads as a styling accident, not a control. */
a.pa-btn { text-decoration: none; display: inline-block; }

.pa-btn:focus-visible,
.pa-dialog [tabindex]:focus-visible {
  outline: 3px solid var(--helm-accent, #00757F);
  outline-offset: 2px;
}

/* --------------------------------------------------- completion popup */
.pa-done {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1092;
  width: min(24rem, calc(100vw - 2rem));
  background: var(--helm-surface, #fff);
  color: var(--helm-text, #1A1D26);
  border: 1px solid var(--helm-border, #E2E6EF);
  border-left: 5px solid var(--helm-success, #167536);
  border-radius: 8px;
  box-shadow: var(--helm-shadow-lg, 0 8px 24px rgba(27, 58, 107, 0.12));
  padding: 0.9rem 1rem;
  font-family: var(--helm-font, sans-serif);
}

.pa-done--failed { border-left-color: var(--helm-danger, #d73027); }

.pa-done-title { font-weight: 700; font-size: 0.95rem; margin: 0 0 0.3rem; }
.pa-done-msg {
  margin: 0 0 0.7rem;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--helm-text-secondary, #374151);
}
.pa-done-actions { display: flex; gap: 0.5rem; }

/* draft prose: the visible marker for a fact that is genuinely missing */
.pa-gap {
  font-family: var(--helm-font-mono, monospace);
  font-size: 0.9em;
  padding: 0 0.25em;
  border-radius: 3px;
  background: color-mix(in srgb, var(--helm-warning, #fdae61) 28%,
              transparent);
  color: var(--helm-text, #1A1D26);
}

@media (prefers-reduced-motion: no-preference) {
  .pa-backdrop { animation: pa-fade 120ms ease-out; }
  .pa-done { animation: pa-fade 160ms ease-out; }
}

@keyframes pa-fade { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 30rem) {
  .pa-facts { grid-template-columns: 1fr; gap: 0; }
  .pa-facts dt { padding-bottom: 0; border-bottom: 0; }
  .pa-comp-row { grid-template-columns: 6.5rem 1fr 2.6rem; }
}
