/* ============================================================
 * The Money Tool — master stylesheet
 * Brand tokens + wizard UI (tabs, chips, sections, validation)
 * ============================================================ */

:root {
  --primary-purple: #501283;
  --primary-green:  #A6CE38;
  --body-text:      #333333;
  --cool-neutral:   #C0BFCB;
  --warm-neutral:   #F2F2F2;
  --money-yellow:   #FFF9C4;
  --error-red:      #b00020;
  --success-green:  #0a7a4a;
  --warning-amber:  #b47e00;
}

body {
  font-family: 'Roboto', 'Source Sans Pro', system-ui, sans-serif;
  color: var(--body-text);
  background: var(--warm-neutral);
  margin: 0;
  padding: 0;
}

h1, h2, h3 {
  font-family: 'Poppins', 'Source Sans Pro', system-ui, sans-serif;
  color: var(--primary-purple);
}

.wizard-shell { max-width: 720px; margin: 0 auto; padding: 24px 16px; }

.wordmark {
  font-family: 'Poppins', sans-serif;
  font-weight: 800;
  font-size: 28px;
  color: var(--primary-purple);
  margin: 0 0 24px 0;
}

.auth-card, .section-card {
  background: #fff;
  border: 1px solid var(--cool-neutral);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 16px;
}

.auth-card h2, .section-card h2 {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 20px;
  color: var(--primary-purple);
  margin: 0 0 16px 0;
}

.section-card h2 .section-toggle {
  float: right;
  font-size: 14px;
  font-weight: 400;
  color: var(--body-text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.section-card h2 .section-toggle input {
  width: auto;
  margin: 0;
}

.form-row { margin-bottom: 12px; }

.form-row label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
}

.form-row input,
.form-row textarea,
.form-row select {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  font-size: 16px;
  border: 1px solid var(--cool-neutral);
  border-radius: 4px;
  font-family: inherit;
  background: #fff;
}

.form-row textarea { min-height: 80px; resize: vertical; }

.form-row .helper {
  font-size: 12px;
  color: #666;
  margin-top: 4px;
}

.form-row-inline {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.form-row-inline label {
  font-size: 14px;
  font-weight: 700;
}

.form-row-inline input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.btn {
  display: inline-block;
  padding: 10px 20px;
  font-size: 16px;
  font-weight: 700;
  font-family: 'Poppins', sans-serif;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: var(--primary-purple);
  color: #fff;
}

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

.btn-secondary {
  background: transparent;
  color: var(--primary-purple);
  border: 1px solid var(--primary-purple);
}

.btn-ghost {
  background: transparent;
  color: #333;
  border: 1px solid var(--cool-neutral);
}

.btn-small {
  padding: 6px 12px;
  font-size: 14px;
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.session-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.session-banner .who { font-size: 14px; }
.session-banner .who strong { color: var(--primary-purple); }

.draft-meta {
  font-size: 12px;
  color: #666;
  margin-top: 8px;
  word-break: break-all;
}

.scenario-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--cool-neutral);
  padding-bottom: 4px;
}

.scenario-tab {
  position: relative;
  padding: 8px 16px;
  padding-right: 28px;
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 14px;
  background: transparent;
  color: var(--body-text);
  border: 1px solid var(--cool-neutral);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
}

.scenario-tab.active {
  background: #fff;
  color: var(--primary-purple);
  border-color: var(--primary-purple);
  border-bottom: 2px solid #fff;
  margin-bottom: -1px;
}

.scenario-tab.add {
  padding-right: 16px;
  color: var(--primary-purple);
  border-style: dashed;
}

.scenario-tab .tab-x {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  line-height: 1;
  color: #999;
  padding: 2px 4px;
  border-radius: 3px;
}

.scenario-tab .tab-x:hover {
  color: var(--error-red);
  background: rgba(176, 0, 32, 0.08);
}

.scenario-pane { padding-top: 8px; }

.hero-chips-wrap { margin-top: 8px; }

.hero-group { margin-bottom: 12px; }

.hero-group-label {
  font-family: 'Poppins', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-purple);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.hero-chip {
  padding: 6px 12px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  border: 1px solid var(--cool-neutral);
  border-radius: 16px;
  color: var(--body-text);
  cursor: pointer;
}

.hero-chip.selected {
  background: var(--money-yellow);
  border: 2px solid var(--primary-purple);
  padding: 5px 11px;
  color: var(--primary-purple);
  font-weight: 600;
}

.hero-other {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
}

.hero-other input {
  flex: 1;
  padding: 6px 10px;
  font-size: 14px;
  border: 1px solid var(--cool-neutral);
  border-radius: 4px;
}

.validation-summary {
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 12px;
  display: none;
}

.validation-summary.has-errors {
  display: block;
  background: #fde8ec;
  color: var(--error-red);
  border: 1px solid var(--error-red);
}

.validation-summary.has-warnings {
  display: block;
  background: #fff7e0;
  color: var(--warning-amber);
  border: 1px solid var(--warning-amber);
}

.validation-summary.ok {
  display: block;
  background: #e6f7ee;
  color: var(--success-green);
  border: 1px solid var(--success-green);
}

.has-error {
  border-color: var(--error-red) !important;
  border-width: 2px !important;
  background: #fffafb !important;
}

.has-warning {
  border-color: var(--warning-amber) !important;
  border-width: 2px !important;
  background: #fffdf5 !important;
}

.hero-chips-wrap.has-error {
  border: 2px solid var(--error-red);
  background: #fffafb;
  padding: 8px;
  border-radius: 6px;
}

.inline-error {
  color: var(--error-red);
  font-size: 14px;
  margin-top: 8px;
}

.inline-status {
  color: var(--body-text);
  font-size: 14px;
  margin-top: 8px;
}

.hidden { display: none !important; }

.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 4px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
}

.toast.visible { opacity: 1; }
.toast.success { background: var(--success-green); }
.toast.error   { background: var(--error-red); }

.debug-pane {
  margin-top: 24px;
  padding: 12px;
  background: #fff;
  border: 1px dashed var(--cool-neutral);
  border-radius: 4px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 400px;
  overflow-y: auto;
}

.debug-pane h3 {
  margin: 0 0 8px 0;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  color: var(--primary-purple);
}
/* ----- Step 5(f) round-trip verifier banner ------------------------------- */
#roundtrip-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  padding: 16px;
  font-family: 'Roboto', sans-serif;
  font-weight: bold;
  font-size: 16px;
  text-align: center;
  word-break: break-word;
}
#roundtrip-banner.banner-pass { background-color: #A6CE38; color: #333333; }
#roundtrip-banner.banner-fail { background-color: #C62828; color: #ffffff; }
/* ============================================================
 * Settings modal -- chat #11 addition
 * Used by assets/settings-modal.js (MoneyToolSettings).
 * ============================================================ */

#settings-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(51, 51, 51, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

#settings-modal-card {
  background: #FFFFFF;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 480px;
  padding: 24px;
  font-family: Roboto, Arial, sans-serif;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

#settings-modal-card h2 {
  margin: 0 0 20px 0;
  font-family: Poppins, Arial, sans-serif;
  font-size: 22px;
  font-weight: 600;
  color: #501283;
}

.settings-field {
  margin-bottom: 18px;
}

.settings-field label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: #333333;
  margin-bottom: 6px;
}

.settings-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  font-size: 16px;
  font-family: Roboto, Arial, sans-serif;
  border: 1px solid #C0BFCB;
  border-radius: 4px;
  background: #FFFFFF;
  color: #333333;
}

.settings-field input:focus {
  outline: none;
  border-color: #501283;
  box-shadow: 0 0 0 2px rgba(80, 18, 131, 0.15);
}

.settings-field input:disabled {
  background: #F5F5F5;
  color: #888888;
}

.settings-helper {
  font-size: 12px;
  color: #666666;
  margin-top: 4px;
  line-height: 1.4;
}

.settings-error {
  min-height: 20px;
  font-size: 13px;
  color: #C62828;
  margin: 0 0 12px 0;
  line-height: 1.4;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

.settings-actions button {
  min-height: 44px;
  padding: 10px 20px;
  font-size: 15px;
  font-family: Roboto, Arial, sans-serif;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
}

.settings-actions .btn-primary {
  background: #501283;
  color: #FFFFFF;
  border-color: #501283;
}

.settings-actions .btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.settings-actions .btn-ghost {
  background: #FFFFFF;
  color: #501283;
  border-color: #C0BFCB;
}

body.modal-open {
  overflow: hidden;
}
/* ============================================================
 * Preview page chrome -- chat #11 addition
 * Used by /preview.html + assets/preview.js (MoneyToolPreview).
 * ============================================================ */

#preview-root {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  font-family: Roboto, Arial, sans-serif;
  color: #333333;
}

#preview-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 0;
  border-bottom: 1px solid #C0BFCB;
  margin-bottom: 16px;
}

.preview-back {
  color: #501283;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 4px;
}

.preview-back:hover {
  text-decoration: underline;
}

.preview-title {
  font-family: Poppins, Arial, sans-serif;
  font-weight: 600;
  font-size: 22px;
  color: #501283;
  flex: 1;
}

.preview-borrower {
  font-size: 14px;
  color: #666666;
}

#preview-email-region {
  background: #F5F5F5;
  border: 1px solid #C0BFCB;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 16px;
  overflow-x: auto;
}

#preview-email-frame {
  background: #FFFFFF;
  margin: 0 auto;
  max-width: 600px;
  border: 1px solid #E0E0E0;
}

#preview-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

#preview-actions button {
  min-height: 44px;
  padding: 10px 20px;
  font-size: 15px;
  font-family: Roboto, Arial, sans-serif;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  flex: 0 1 auto;
}

#preview-actions .btn-primary {
  background: #501283;
  color: #FFFFFF;
  border-color: #501283;
}

#preview-actions .btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#preview-actions .btn-ghost {
  background: #FFFFFF;
  color: #501283;
  border: 1px solid #C0BFCB;
}

#preview-actions .btn-send {
  background: #A6CE38;
  color: #333333;
  border-color: #A6CE38;
}

#preview-stub {
  background: #FFFFFF;
  border: 1px solid #C0BFCB;
  border-radius: 6px;
  padding: 32px;
  text-align: center;
}

#preview-stub h2 {
  font-family: Poppins, Arial, sans-serif;
  color: #501283;
  font-size: 22px;
  margin: 0 0 12px 0;
}

#preview-stub p {
  font-size: 15px;
  line-height: 1.5;
  color: #333333;
  margin: 0 0 12px 0;
}

.preview-back-button {
  display: inline-block;
  margin-top: 16px;
  padding: 12px 20px;
  background: #501283;
  color: #FFFFFF;
  text-decoration: none;
  border-radius: 4px;
  font-weight: 600;
  min-height: 44px;
  line-height: 20px;
}

#preview-bootloading {
  text-align: center;
  padding: 32px;
  color: #888888;
  font-size: 14px;
}

/* Modal overlays for the edit picker, edit modal, and fallback copy */
.preview-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(51, 51, 51, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.preview-modal-card {
  background: #FFFFFF;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 480px;
  padding: 24px;
  font-family: Roboto, Arial, sans-serif;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.preview-modal-card-wide {
  max-width: 640px;
}

.preview-modal-card h3 {
  margin: 0 0 16px 0;
  font-family: Poppins, Arial, sans-serif;
  font-size: 20px;
  color: #501283;
  font-weight: 600;
}

.preview-modal-card p {
  font-size: 14px;
  line-height: 1.5;
  color: #333333;
  margin: 0 0 12px 0;
}

.edit-picker-list {
  list-style: none;
  margin: 0 0 16px 0;
  padding: 0;
}

.edit-picker-list li {
  margin: 0 0 8px 0;
}

.edit-picker-list button {
  width: 100%;
  text-align: left;
  background: #FFFFFF;
  color: #501283;
  border: 1px solid #C0BFCB;
  border-radius: 4px;
  padding: 14px 16px;
  font-size: 15px;
  font-family: Roboto, Arial, sans-serif;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.edit-picker-list button:hover {
  background: #F5F0FA;
}

#edit-modal-textarea,
#fallback-copy-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  font-size: 15px;
  font-family: Roboto, Arial, sans-serif;
  line-height: 1.5;
  border: 1px solid #C0BFCB;
  border-radius: 4px;
  background: #FFFFFF;
  color: #333333;
  resize: vertical;
}

#edit-modal-textarea:focus,
#fallback-copy-textarea:focus {
  outline: none;
  border-color: #501283;
  box-shadow: 0 0 0 2px rgba(80, 18, 131, 0.15);
}

.edit-modal-counter {
  font-size: 12px;
  color: #888888;
  text-align: right;
  margin-top: 4px;
  margin-bottom: 12px;
}

.preview-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

.preview-modal-actions button {
  min-height: 44px;
  padding: 10px 20px;
  font-size: 15px;
  font-family: Roboto, Arial, sans-serif;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
}

.preview-modal-actions .btn-primary {
  background: #501283;
  color: #FFFFFF;
  border-color: #501283;
}

.preview-modal-actions .btn-ghost {
  background: #FFFFFF;
  color: #501283;
  border-color: #C0BFCB;
}

/* Toast */
.preview-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #333333;
  color: #FFFFFF;
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 14px;
  font-family: Roboto, Arial, sans-serif;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms, transform 200ms;
  z-index: 1100;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.preview-toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
