/* survey.css — makes SurveyJS's "modern" theme sit naturally inside the app, for every survey.
   Linked by _SurveyJsAssets.cshtml right after modern.min.css, so it only loads where a survey can
   appear. survey-theme.js selects the theme; this file supplies its colours and tidies its layout.

   Everything is scoped to .sv-root-modern (the root element the modern theme renders), so nothing
   here can reach the rest of the page — the reverse of applyTheme()'s default, which wrote the
   colours onto <html> and clobbered the app's own --border-color token (see survey-theme.js).

   The modern theme was designed for a full-page questionnaire: 16px+ text, 20px titles, underline-only
   inputs and very generous spacing. Inside an entity form card that reads as a different app, so the
   rules below bring it to the app's scale — same font, same label style, boxed inputs like
   .form-control — and make it stack cleanly on a phone. */

/* ── Colours: the modern theme's variables mapped onto the app's design tokens ───────────────
   var(...) resolves live, so a survey follows the light/dark switch with the rest of the page.
   (--border-color is not redefined here: it IS the app token, inherited as-is.) */
.sv-root-modern {
  --main-color: var(--primary);
  --main-hover-color: var(--text-muted);
  --answer-background-color: transparent;
  --progress-buttons-color: var(--primary-lt);
  --text-color: var(--text);
  --foreground-light: var(--text-muted);
  --text-border-color: var(--border-color);
  --radio-checked-color: var(--primary);
  --add-button-color: var(--primary);
  --clean-button-color: var(--primary);
  --remove-button-color: var(--red);
  --error-color: var(--red);
  --error-background-color: transparent;
  --inputs-background-color: var(--bg-surface);
  --body-background-color: var(--bg-surface);
  --body-container-background-color: transparent;
  --header-background-color: var(--bg-surface-secondary);
  --light-text-color: #fff;
  --checkmark-color: #fff;
  --disable-color: var(--border-color);
  --disabled-text-color: var(--text-muted);
  --disabled-label-color: var(--text-muted);
}

/* ── Scale and font: the app's, not the theme's 16px Raleway ─────────────── */
.sv-root-modern .sv-container-modern {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
}
.sv-root-modern .sv-title { font-family: inherit; }

/* The page wraps the survey in its own card, so drop the theme's page-sized padding. */
.sv-root-modern .sv-body { padding-bottom: 0; }
.sv-root-modern .sv-body__page { margin: 0; }
.sv-root-modern .sv-page__title { font-size: 1.25em; padding-left: 0; margin-bottom: 1em; }
.sv-root-modern .sv-row:not(:last-child) { padding-bottom: 1.25rem; }

/* ── Question titles: styled like the app's own field labels ────────────────
   (_EntityFormField renders 13px / 600 / secondary text.) The theme's 20px bold titles shouted. */
.sv-root-modern .sv-question__title {
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.sv-root-modern .sv-question__header--location--top { margin-bottom: .4rem; }
/* The theme indents each answer area by .55em from its title; aligned reads cleaner. */
.sv-root-modern .sv-question__content { margin-left: 0; }
.sv-root-modern .sv-question__required-text { color: var(--red); font-size: 1em; line-height: 1; }
.sv-root-modern .sv-description { color: var(--text-muted); font-size: 12.5px; }
.sv-root-modern .sv-question__description { padding-left: 0; }   /* same .55em indent as the content */

/* ── Text inputs, comments and dropdowns: boxed like .form-control ──────────
   The theme draws only a bottom underline, which on a card looked like a line, not a field. */
.sv-root-modern .sv-text,
.sv-root-modern .sv-comment,
.sv-root-modern .sv-dropdown {
  height: auto;
  min-height: 38px;
  padding: .45rem .75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background-color: var(--bg-surface);
  color: var(--text);
  font-size: 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.sv-root-modern .sv-dropdown { padding-right: 2rem; background-position: right .75rem top 50%, 0 0; }
.sv-root-modern .sv-comment { min-height: 90px; }
.sv-root-modern .sv-text:focus,
.sv-root-modern .sv-comment:focus,
.sv-root-modern .sv-dropdown:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-lt);
}

/* ── Radio / checkbox choices ──────────────────────────────────────────────
   Comfortable 44px-ish touch rows, label vertically centred on its marker. */
.sv-root-modern .sv-item { display: flex; align-items: center; min-height: 36px; margin-bottom: .15rem; }
.sv-root-modern .sv-selectbase__label { display: flex; align-items: center; gap: .6rem; margin-left: 0; cursor: pointer; }
.sv-root-modern .sv-item__control-label { top: 0; }
.sv-root-modern .sv-item__decorator { width: 20px; height: 20px; flex: 0 0 auto; }
/* The theme parks the marker in the label's 41px left margin (position:absolute; left:-41px).
   With the label now a flex row, the marker simply sits first in it — in either text direction. */
.sv-root-modern .sv-selectbase__decorator.sv-item__decorator { position: relative; left: auto; right: auto; }
/* 20px markers with a 2px ring in the muted text colour — the theme's ring used --border-color,
   which in this app is a pale divider grey, so unchecked choices were nearly invisible. */
.sv-root-modern .sv-item__svg { width: 20px; height: 20px; }
.sv-root-modern .sv-radio__svg,
.sv-root-modern .sv-checkbox__svg { border-width: 2px; border-color: color-mix(in srgb, var(--text-muted) 70%, transparent); }
.sv-root-modern .sv-radio--checked .sv-radio__svg { border-color: var(--primary); fill: var(--primary); }

/* ── Rating: a full-width row of equal tap targets on phones ─────────────── */
.sv-root-modern .sv-rating__item-text {
  min-width: 2.5rem;
  height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border-width: 2px;
  border-color: var(--border-color);
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 600;
}
/* The theme nudges the number down with a margin to centre it by eye; flex centring replaces that. */
.sv-root-modern .sv-rating__item-text > span { margin-top: 0; }
.sv-root-modern .sv-rating__item--selected .sv-rating__item-text {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ── Matrix (desktop table form): row captions level with their radios, tighter rows ─ */
.sv-root-modern .sv-matrix td,
.sv-root-modern .sv-matrix th { vertical-align: middle; padding-top: .5rem; padding-bottom: .5rem; }
.sv-root-modern .sv-matrix .sv-table__cell--header { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }

/* ── Errors ───────────────────────────────────────────────────────────── */
.sv-root-modern .sv-question__erbox { font-size: 12.5px; font-weight: 500; }

/* ── Navigation buttons (Previous / Next / Complete): the app's button shape ─
   A single-page survey inside an entity form has every button hidden (surveyform-edit.js turns
   Complete off), which left an empty ~80px footer band; :has() drops it when nothing is visible. */
.sv-root-modern .sv-footer { margin: 1rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; }
.sv-root-modern .sv-footer:not(:has(.sv-action:not(.sv-action--hidden))) { display: none; }
.sv-root-modern .sv-btn {
  float: none;
  margin: 0;
  padding: .5rem 1.25rem;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

/* ── Phones ───────────────────────────────────────────────────────────────
   Questions placed side by side (startWithNewLine:false) and multi-column choice lists (colCount)
   have no room on a phone, so each takes the full width and choices fall into one column. A matrix
   is turned into stacked blocks by the theme's own <=600px rules; we only tighten those. */
@media (max-width: 575.98px) {
  /* Each question in a row sits in a flex wrapper <div>; stacked, every wrapper is full width with a
     gap under it. SurveyJS also pads side-by-side questions apart with an inline
     --sv-element-add-padding-* variable — meaningless once stacked, and it left the first one short. */
  .sv-root-modern .sv-row { flex-direction: column; gap: 1.25rem; }
  .sv-root-modern .sv-row > div { width: 100%; min-width: 0 !important; }
  .sv-root-modern .sv-question { padding-left: 0 !important; padding-right: 0 !important; }
  .sv-root-modern .sv-selectbase__column,
  .sv-root-modern .sv-item[class*="sv-q-col-"] { width: 100% !important; max-width: 100% !important; display: flex; }
  /* The theme's own <=600px mode turns a matrix into stacked blocks; tighten them, and make each
     row's caption read as a sub-heading over its choices. */
  .sv-root-modern .sv-matrix td { padding: .2rem 0 !important; }
  .sv-root-modern .sv-matrix .sv-table__cell--row-text { padding-top: .6rem !important; font-weight: 600; }
  .sv-root-modern .sv-matrix__label { display: flex !important; align-items: center; gap: .6rem; }
  .sv-root-modern .sv-rating { display: flex; flex-wrap: wrap; gap: .35rem; }
  .sv-root-modern .sv-rating__item-text { margin: 0; }
  .sv-root-modern .sv-footer .sv-btn { flex: 1 1 auto; }
}

/* ── The surveyform edit control (surveyform-edit.js) ──────────────────────
   Inside an entity form the survey is ONE field among others, so frame it as a group under its
   label; otherwise its questions run on into the form's own fields with nothing to tell them apart. */
entapp-surveyform-edit .fk-survey-mount {
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-surface-secondary);
}
@media (max-width: 575.98px) {
  entapp-surveyform-edit .fk-survey-mount { padding: .85rem .75rem; }
}
