/* ============================================================
   Thème LimeSurvey « samaritains »
   Identité du design system DMS (samas-inscriptions-dms, Cours Manager) :
   rouge Samaritains, Roboto pour l'interface, Merriweather pour les intertitres,
   surfaces blanches à bordure fine, champs hauts, focus bleu visible.
   Chargé en dernier : il surcharge Fruity TwentyThree sans toucher à ses vues.
   ============================================================ */

/* ── Polices auto-hébergées (dossier files/ du thème) ─────────── */
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url("../files/roboto-latin-variable.woff2") format("woff2");
}
@font-face {
  font-family: "Roboto";
  font-style: italic;
  font-weight: 300 700;
  font-display: swap;
  src: url("../files/roboto-latin-italic-variable.woff2") format("woff2");
}
@font-face {
  font-family: "Merriweather";
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url("../files/merriweather-latin-variable.woff2") format("woff2");
}

/* ── Jetons ───────────────────────────────────────────────────── */
:root {
  --sam-brand: #D52B1E;
  --sam-brand-strong: #B42318;
  --sam-brand-soft: #FEF3F2;
  --sam-text: #171717;
  --sam-text-strong: #292B30;
  --sam-text-secondary: #676B73;
  --sam-border: #D8DADF;
  --sam-border-input: #AEB2BA;
  --sam-border-button: #C8CBD1;
  --sam-rule: #E1E3E7;
  --sam-bg: #F4F5F7;
  --sam-surface: #FFFFFF;
  --sam-success: #067647;
  --sam-success-bg: #ECFDF3;
  --sam-success-border: #ABEFC6;
  --sam-error: #B42318;
  --sam-error-bg: #FEF3F2;
  --sam-error-border: #FDA29B;
  --sam-error-text: #7A271A;
  --sam-font-sans: "Roboto", Arial, sans-serif;
  --sam-font-serif: "Merriweather", Georgia, serif;
  --sam-radius: 5px;
  --sam-radius-surface: 7px;
  --sam-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --sam-focus-ring: 0 0 0 3px #FFFFFF, 0 0 0 6px #175CD3;
  --sam-content-max: 880px;

  /* Bootstrap lit ces variables : on les aligne sur le design system */
  --bs-font-sans-serif: var(--sam-font-sans);
  --bs-body-font-family: var(--sam-font-sans);
  --bs-body-color: var(--sam-text);
  --bs-body-bg: var(--sam-bg);
  --bs-border-color: var(--sam-border);
  --bs-link-color: var(--sam-brand-strong);
  --bs-link-hover-color: var(--sam-brand);
}

/* ── Base ─────────────────────────────────────────────────────── */
html body {
  font-family: var(--sam-font-sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--sam-text);
  background-color: var(--sam-bg);
}

html body h1, html body h2, html body h3, html body h4,
html body .h1, html body .h2, html body .h3, html body .h4,
html body .large-heading,
html body label, html body dl, html body .btn,
html body .form-control, html body .form-select, html body .dropdown-menu {
  font-family: var(--sam-font-sans);
}

a { color: var(--sam-brand-strong); }
a:hover, a:focus { color: var(--sam-brand); }

/* Focus clavier : anneau bleu du design system, partout */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible {
  outline: 2px solid transparent !important;
  outline-offset: 2px;
  box-shadow: var(--sam-focus-ring) !important;
}

/* ── En-tête : barre blanche, logo à gauche (app-header) ──────── */
#survey-nav.navbar {
  position: sticky;
  top: 0;
  z-index: 800;
  min-height: 72px;
  padding: 0.65rem clamp(1rem, 2.3vw, 2rem);
  background: rgba(255, 255, 255, 0.98);
  border-bottom: 1px solid var(--sam-border);
  box-shadow: none;
}
#survey-nav > .container-fluid {
  max-width: var(--sam-content-max);
  margin-inline: auto;
  padding-inline: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
}
#survey-nav .navbar-brand.logo-container {
  margin: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}
#survey-nav .logo-container .logo {
  display: block;
  width: 190px;
  max-width: 45vw;
  height: auto;
  max-height: none;
}
/* Le menu « … » devient un bouton discret du design system */
#survey-nav .navbar-toggler {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  line-height: 1;
  border: 1px solid var(--sam-border-button);
  border-radius: var(--sam-radius);
  background: #FFFFFF;
  color: #24262B;
}
#survey-nav .navbar-toggler:hover { background: var(--sam-bg); }
#survey-nav .navbar-toggler > span {
  display: block;
  font-size: 1.25rem;
  line-height: 1;
}
#survey-nav .dropdown-menu {
  border: 1px solid var(--sam-border);
  border-radius: var(--sam-radius-surface);
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.12);
  padding: 0.4rem;
}
#survey-nav .dropdown-header {
  color: var(--sam-text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}
#survey-nav .dropdown-menu .nav-link,
#survey-nav .dropdown-menu .dropdown-item {
  border-radius: var(--sam-radius);
  color: var(--sam-text);
  font-weight: 600;
}
#survey-nav .dropdown-menu .nav-link:hover,
#survey-nav .dropdown-menu .dropdown-item:hover {
  background: var(--sam-bg);
  color: var(--sam-brand-strong);
}

/* Fruity calcule un padding-top pour sa barre fixe : inutile en sticky */
html body.brand-logo,
html body {
  padding-top: 0 !important;
}

/* ── Barre de progression fine (progress) ─────────────────────── */
.top-container {
  background: transparent;
  padding-top: 1.25rem;
}
.top-container .top-content {
  max-width: var(--sam-content-max);
  margin-inline: auto;
}
.ls-progress-container .progress {
  height: 7px;
  overflow: hidden;
  border-radius: 9px;
  background: var(--sam-rule);
}
.ls-progress-container .progress-bar {
  background: var(--sam-brand);
  border-radius: 9px;
}

/* ── Colonne de contenu ───────────────────────────────────────── */
#outerframeContainer > .row > .col-centered {
  max-width: var(--sam-content-max);
  margin-inline: auto;
}
#outerframeContainer {
  padding-top: clamp(0.75rem, 2vw, 1.25rem);
  padding-bottom: 3rem;
}
#outerframeContainer #main-col,
#outerframeContainer .group-outer-container { margin-top: 0; }
#outerframeContainer .group-container { margin-top: 0.25rem; }

/* ── Accueil : carte d'en-tête avec filet rouge (auth-card) ───── */
#welcome-container {
  background: var(--sam-surface);
  border: 1px solid var(--sam-border);
  border-top: 5px solid var(--sam-brand);
  border-radius: var(--sam-radius-surface);
  box-shadow: var(--sam-shadow);
  padding: clamp(1.4rem, 5vw, 2.2rem);
  margin-bottom: 1.5rem;
}
#welcome-container .survey-name,
html body .survey-name.large-heading {
  margin: 0 0 0.5rem;
  color: var(--sam-text);
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.035em;
}
#welcome-container .survey-description {
  color: var(--sam-text-secondary);
  font-size: 1.05rem;
  margin-bottom: 1rem;
}
#welcome-container .survey-welcome {
  color: var(--sam-text);
  margin-bottom: 0.75rem;
}
#welcome-container .survey-description p:last-child,
#welcome-container .survey-welcome p:last-child { margin-bottom: 0; }
#welcome-container .number-of-questions,
#welcome-container .question-count-text {
  color: var(--sam-text-secondary);
  font-size: 0.92rem;
  font-weight: 500;
}
#welcome-container .number-of-questions {
  /* Pas de filet : le bloc reste vide quand le nombre de questions est masqué */
  margin-top: 0.5rem;
}

/* ── Groupe de questions : titre de page (page-heading) ───────── */
.group-container .group-title {
  margin: 0.5rem 0 0.4rem;
  color: var(--sam-text);
  font-size: clamp(1.6rem, 3.6vw, 2rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
  text-align: left;
}
.group-container .group-description {
  margin-bottom: 1.5rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--sam-border);
  color: var(--sam-text-secondary);
  font-size: 1rem;
}
.group-container .group-description:empty {
  padding-bottom: 0;
}

/* ── Questions : une surface blanche par question ─────────────── */
html body .question-container {
  margin: 0 0 1rem;
  padding: 1.25rem 0.5rem 1rem;
  background-color: var(--sam-surface);
  border: 1px solid var(--sam-border);
  border-radius: var(--sam-radius-surface);
  box-shadow: var(--sam-shadow);
}
.question-container > [class*="col-"] {
  padding-inline: 1rem;
}
html body .question-container .question-title-container {
  margin-bottom: 0.75rem;
}
/* Conteneur de consignes vide (pas d'aide, pas de règle) : il gardait 30 px de marges */
html body .question-container .question-valid-container {
  margin-top: 0;
  margin-bottom: 0.75rem;
}
html body .question-container .question-valid-container:not(:has(*)) {
  display: none;
}
html body .question-container .question-help-container {
  margin-bottom: 0.75rem;
}
/* Boutons Oui / Non : pas de marge sous la rangée, la carte a déjà son rembourrage */
html body .yesno-button .btn.ls-button-label,
html body .gender-button .btn.ls-button-label {
  margin-bottom: 0;
}
.question-title-container .question-text,
.question-title-container .ls-label-question {
  color: var(--sam-text);
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.4;
}
/* Texte d'information (boilerplate) : pas de zone de réponse, donc moins de marge basse */
html body .question-container.boilerplate { padding-bottom: 0.4rem; }
/* Intertitre en Merriweather pour les textes d'information (boilerplate) */
.boilerplate .ls-label-question,
.question-container.boilerplate .question-text {
  font-family: var(--sam-font-serif);
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.7;
}
.question-container .asterisk {
  color: var(--sam-brand);
}
.question-container .ls-question-mandatory {
  color: var(--sam-text-secondary);
  font-size: 0.86rem;
  font-weight: 500;
}
.question-help-container .ls-questionhelp,
.question-help-container {
  color: var(--sam-text-secondary);
  font-size: 0.95rem;
}
.question-valid-container,
.question-valid-container .ls-questionhelp,
.question-valid-container .ls-em-tip {
  color: var(--sam-text-secondary) !important;
  font-size: 0.9rem;
}

/* Question de suite (classe CSS « question-suite » dans les attributs de la question) :
   elle se rattache à la carte précédente, séparée par un filet pointillé.
   Sert aux précisions qui s'affichent après un Oui / Non. */
html body .question-container.question-suite {
  margin-top: -1rem;
  border-top: 1px dashed var(--sam-border);
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  box-shadow: none;
  padding-top: 1rem;
}
html body .question-container:has(+ .question-suite:not(.ls-hidden):not(.ls-irrelevant)) {
  border-bottom-color: transparent;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
html body .question-container.question-suite .ls-label-question {
  font-size: 1rem;
  color: var(--sam-text-strong);
}

/* Question « au moins une réponse » (classe CSS « question-requise ») : LimeSurvey n'affiche
   l'astérisque que pour les questions obligatoires au sens strict ; on reproduit la même mention
   pour les questions imposées par un minimum de réponses (lignes ajoutées à la demande). */
html body .question-container.question-requise .question-title-container::before {
  content: "Obligatoire";
  display: block;
  margin-bottom: 0.15rem;
  padding-left: 1.1rem;
  color: var(--sam-text-secondary);
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.4;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23D52B1E' d='M13 3v7.27l6.3-3.64 1 1.73L14 12l6.3 3.64-1 1.73L13 13.73V21h-2v-7.27l-6.3 3.64-1-1.73L10 12 3.7 8.36l1-1.73L11 10.27V3z'/%3E%3C/svg%3E") no-repeat left center / 0.95rem 0.95rem;
}

/* Question en erreur : filet rouge à gauche, message lisible (error-summary) */
/* Champ en erreur : bordure rouge pleine plutôt que l'ombre décalée de Fruity */
html body .question-container.input-error .form-control:not(:focus),
html body .question-container.input-error .form-select:not(:focus) {
  box-shadow: none;
  border-color: var(--sam-error);
}
html body .question-container.input-error,
html body .question-container:has(.question-valid-container .text-danger),
html body .question-container:has(.question-valid-container .ls-em-error) {
  border-color: var(--sam-error-border);
  border-left: 5px solid var(--sam-error);
  background-color: var(--sam-surface);
}
.question-valid-container .ls-em-error,
.question-container .ls-em-error,
.question-container .text-danger,
.question-valid-container .text-danger {
  color: var(--sam-error) !important;
  font-weight: 650;
  font-style: normal;
}

/* LimeSurvey marque en erreur, dès l'affichage, les questions à minimum de réponses encore vides.
   Tant que la page n'a pas été envoyée (pas d'alerte « ls-questions-have-errors »),
   on les affiche normalement ; après un envoi incomplet, l'erreur redevient visible. */
html body #main-col:not(:has(> .ls-questions-have-errors)) .question-container.question-requise.input-error {
  border-color: var(--sam-border);
  border-left-width: 1px;
}
html body #main-col:not(:has(> .ls-questions-have-errors)) .question-container.question-suite.question-requise.input-error {
  border-top: 1px dashed var(--sam-border);
}
html body #main-col:not(:has(> .ls-questions-have-errors)) .question-requise .em_num_answers {
  display: none !important;
}
html body #main-col:not(:has(> .ls-questions-have-errors)) .question-requise .form-control:not(:focus) {
  box-shadow: none;
  border-color: var(--sam-border-input);
}
html body #main-col:not(:has(> .ls-questions-have-errors)) .question-requise .question-valid-container:not(:has(:not(.em_num_answers):not(.ls-questionhelp))) {
  display: none;
}

/* ── Réponses à choix : libellés sombres, puce rouge ──────────── */
.answer-container label,
.answer-container .control-label,
.ls-answers .radio-label,
.ls-answers .checkbox-label {
  color: var(--sam-text-strong);
  font-weight: 500;
}
.radio-item input[type="radio"]:checked + label,
.checkbox-item input[type="checkbox"]:checked + label,
.answer-item input:checked + label.radio-label,
.answer-item input:checked + label.checkbox-label {
  color: var(--sam-text);
  font-weight: 700;
}
.radio-list .answer-item,
.checkbox-list .answer-item {
  padding-block: 0.15rem;
}

/* ── Lignes ajoutées à la demande (thème de question « Input on demand ») ──
   Une puce par ligne, comme sur papier. Le libellé de chaque ligne reste lu
   par les lecteurs d'écran et sert de nom de colonne à l'export. */
.selector--inputondemand-list .selector--inputondemand-list-item {
  flex-wrap: nowrap;
  align-items: center;
  margin-bottom: 0.6rem !important;
}
.selector--inputondemand-list .selector--inputondemand-list-item::before {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin: 0 0.85rem 0 0.25rem;
  border-radius: 50%;
  background: var(--sam-brand);
}
.selector--inputondemand-list .selector--inputondemand-list-item > .control-label {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.selector--inputondemand-list .selector--inputondemand-list-item > [class*="col-"]:not(.control-label) {
  flex: 1 1 auto;
  width: auto;
  max-width: 100%;
  padding-left: 0;
}
.selector--inputondemand-addlinebutton {
  margin-top: 0.1rem;
}

/* ── Champs (field) ───────────────────────────────────────────── */
html body .form-control,
html body .form-select,
html body select.form-control {
  min-height: 48px;
  border: 1.5px solid var(--sam-border-input);
  border-radius: var(--sam-radius);
  background-color: #FFFFFF;
  color: var(--sam-text);
  padding: 0.7rem 0.8rem;
  font-size: 1rem;
  box-shadow: none;
}
html body textarea.form-control { min-height: 120px; }
html body .form-select,
html body select.form-control {
  padding-right: 2.5rem;
  background-position: right 0.8rem center;
}
html body .form-control:focus,
html body .form-select:focus {
  border-color: var(--sam-brand);
  box-shadow: var(--sam-focus-ring);
  outline: 2px solid transparent;
}
html body .form-control::placeholder { color: #8A8F98; }
.input-group > .form-control { min-height: 48px; }
.input-group .input-group-addon.btn,
.input-group .input-group-text {
  display: inline-flex;
  align-items: center;
  border-radius: 0 var(--sam-radius) var(--sam-radius) 0;
}
.help-block, .tip.help-block {
  color: var(--sam-text-secondary);
  font-size: 0.86rem;
  font-weight: 500;
  margin-top: 0.35rem;
}

/* ── Tableaux de questions (matrices) ─────────────────────────── */
.ls-answers table,
table.ls-answers {
  border-collapse: separate;
  border-spacing: 0;
}
table.ls-answers thead th,
table.ls-answers thead td {
  color: var(--sam-text-strong);
  font-weight: 700;
  font-size: 0.92rem;
  border-bottom: 1px solid var(--sam-border);
}
table.ls-answers tbody th.answertext,
table.ls-answers tbody .answertext {
  color: var(--sam-text);
  font-weight: 500;
}
table.ls-answers tbody tr > * {
  border-bottom: 1px solid var(--sam-rule);
}
table.ls-answers tbody tr:last-child > * { border-bottom: 0; }
table.ls-answers {
  --bs-table-hover-bg: #F1F2F5;
  --bs-table-striped-bg: #FAFAFB;
  --bs-table-accent-bg: transparent;
}
table.ls-answers > tbody > tr.ls-even { background-color: #FAFAFB; }
table.ls-answers > tbody > tr.ls-odd { background-color: transparent; }
table.ls-answers > tbody > tr:hover,
table.ls-answers > tbody > tr:hover > * {
  background-color: #F1F2F5;
}

/* ── Boutons (button, button--primary, button--secondary) ─────── */
html body .btn {
  min-height: 44px;
  border-radius: var(--sam-radius);
  padding: 0.65rem 1.1rem;
  font-weight: 750;
  line-height: 1.2;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}
html body .btn-lg {
  font-size: 1rem;
  padding: 0.75rem 1.4rem;
}
html body .btn:hover { transform: translateY(-1px); }
html body .btn:active { transform: none; }

html body .btn-primary {
  color: #FFFFFF;
  background-color: var(--sam-brand);
  border-color: var(--sam-brand);
}
html body .btn-primary:hover,
html body .btn-primary:focus,
html body .btn-primary:active {
  color: #FFFFFF;
  background-color: var(--sam-brand-strong);
  border-color: var(--sam-brand-strong);
}
html body .btn-outline-secondary,
html body .btn-secondary,
html body .btn-default {
  color: #24262B;
  background-color: #FFFFFF;
  border: 1px solid var(--sam-border-button);
}
html body .btn-outline-secondary:hover,
html body .btn-secondary:hover,
html body .btn-default:hover {
  color: #24262B;
  background-color: var(--sam-bg);
  border-color: var(--sam-border-input);
}

/* Pas d'ombre décorative au survol ou au clic : seul le focus clavier est souligné */
html body .btn:hover,
html body .btn:focus:not(:focus-visible),
html body .btn:active {
  box-shadow: none;
}

/* Boutons Oui / Non et Homme / Femme : boutons secondaires, rouge une fois choisis */
html body .yesno-button .btn.ls-button-label,
html body .gender-button .btn.ls-button-label {
  min-width: 104px;
  color: #24262B;
  background-color: #FFFFFF;
  border: 1.5px solid var(--sam-border-input);
  font-weight: 700;
}
html body .yesno-button .btn-check:checked + .btn.ls-button-label,
html body .gender-button .btn-check:checked + .btn.ls-button-label {
  color: #FFFFFF;
  background-color: var(--sam-brand);
  border-color: var(--sam-brand);
}

/* Barre de navigation du questionnaire */
#navigator-container.row {
  margin-inline: 0;
}
#navigator-container > [class*="col-"] {
  padding-inline: 0;
}
#navigator-container {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--sam-border);
}
.clearall-saveall-wrapper .btn {
  font-weight: 600;
}

/* ── Messages et alertes (error-summary, success-summary) ─────── */
html body .alert {
  border-radius: var(--sam-radius);
  padding: 1rem;
  border: 1px solid transparent;
  border-left-width: 5px;
}
html body .alert-danger {
  border-color: var(--sam-error-border);
  border-left-color: var(--sam-error);
  background: var(--sam-error-bg);
  color: var(--sam-error-text);
}
html body .alert-success {
  border-color: var(--sam-success-border);
  border-left-color: var(--sam-success);
  background: var(--sam-success-bg);
  color: #074D31;
}
html body .alert-warning {
  border-color: #FEDF89;
  border-left-color: #B54708;
  background: #FFFAEB;
  color: #7A2E0E;
}
html body .alert-info {
  border-color: #B2DDFF;
  border-left-color: #175CD3;
  background: #EFF8FF;
  color: #194185;
}

/* Fenêtres modales (dms-dialog) */
html body .modal-content {
  border: 1px solid var(--sam-border);
  border-radius: var(--sam-radius-surface);
  box-shadow: 0 16px 40px rgba(16, 24, 40, 0.2);
}
html body .modal-header {
  border-bottom: 1px solid var(--sam-rule);
  padding: 1rem 1.25rem;
}
html body .modal-title {
  font-weight: 750;
  color: var(--sam-text);
}
html body .modal-footer {
  border-top: 1px solid var(--sam-rule);
}

/* ── Page de fin, enregistrement, chargement ──────────────────── */
.completed-wrapper,
#completed-wrapper,
.ls-completed-wrapper,
.register-form,
.load-form,
.save-message,
.ls-printanswers {
  background: var(--sam-surface);
  border: 1px solid var(--sam-border);
  border-top: 5px solid var(--sam-brand);
  border-radius: var(--sam-radius-surface);
  box-shadow: var(--sam-shadow);
  padding: clamp(1.4rem, 5vw, 2.2rem);
}

/* ── Mobile ───────────────────────────────────────────────────── */
@media (max-width: 767.98px) {
  #survey-nav.navbar {
    min-height: 56px;
    padding: 0.35rem 0.75rem;
  }
  #survey-nav .logo-container .logo { width: 150px; }
  /* Garder la gouttière Bootstrap (0,75 rem) : sa rangée a une marge négative équivalente */
  #outerframeContainer { padding-inline: 0.75rem; }
  html body .question-container { padding: 1rem 0.25rem 0.85rem; }
  .question-container > [class*="col-"] { padding-inline: 0.85rem; }
  #navigator-container .btn { width: 100%; }
  #navigator-container > .text-start { padding-right: 0.375rem; }
  #navigator-container > .text-end { padding-left: 0.375rem; }
}
