/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-primary:   #1a3a6b;   /* UniFR bleu */
  --color-secondary: #c8102e;   /* UniFR rouge */
  --color-bg:        #f5f7fa;
  --color-surface:   #ffffff;
  --color-border:    #d0d7e3;
  --color-text:      #1c1c1c;
  --color-muted:     #6b7280;
  --color-error:     #b91c1c;
  --color-error-bg:  #fef2f2;
  --color-success:   #166534;
  --color-success-bg:#f0fdf4;
  --radius:          8px;
  --shadow:          0 2px 8px rgba(0,0,0,.08);
  --max-w:           720px;
}

html { font-size: 16px; }
body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--color-primary); }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 1rem; }

/* ── Header ───────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--color-primary);
  color: #fff;
  padding: .75rem 0;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.site-logo {
  font-size: .85rem;
  opacity: .85;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.site-project {
  font-size: 1.1rem;
  font-weight: 700;
  border-left: 2px solid rgba(255,255,255,.4);
  padding-left: 1rem;
}

/* ── Main ─────────────────────────────────────────────────────────────────── */
.site-main { flex: 1; padding: 2rem 0 3rem; }

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--color-border);
  border-radius: 999px;
  height: 8px;
  margin-bottom: 2rem;
  position: relative;
  overflow: visible;
}
.progress-bar {
  background: var(--color-primary);
  height: 100%;
  border-radius: 999px;
  transition: width .4s ease;
  min-width: 4px;
}
.progress-label {
  display: block;
  font-size: .8rem;
  color: var(--color-muted);
  margin-top: .3rem;
  text-align: right;
}

/* ── Alert ────────────────────────────────────────────────────────────────── */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  border: 1px solid;
}
.alert-error {
  background: var(--color-error-bg);
  border-color: #fca5a5;
  color: var(--color-error);
}
.alert ul { margin: .5rem 0 0 1.25rem; }

/* ── Step ─────────────────────────────────────────────────────────────────── */
.survey-step {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}
.step-title {
  font-size: 1.3rem;
  color: var(--color-primary);
  margin-bottom: 1.75rem;
  padding-bottom: .75rem;
  border-bottom: 2px solid var(--color-border);
}

/* ── Question wrap ────────────────────────────────────────────────────────── */
.question-wrap { margin-bottom: 1.75rem; }
.question-wrap.q-hidden { display: none; }
.question-wrap.has-error .question-text,
.question-wrap.has-error legend { color: var(--color-error); }
.question-wrap.has-error .radio-options,
.question-wrap.has-error .checkbox-options,
.question-wrap.has-error .text-input,
.question-wrap.has-error .textarea-input,
.question-wrap.has-error .select-input {
  outline: 2px solid var(--color-error);
  border-radius: 4px;
}

/* ── Question text & help ─────────────────────────────────────────────────── */
.question-text {
  font-weight: 600;
  margin-bottom: .6rem;
  display: block;
}
fieldset.question { border: none; }
fieldset.question legend.question-text { float: none; width: 100%; }
.question-help {
  font-size: .88rem;
  color: var(--color-muted);
  margin-bottom: .6rem;
}
.required { color: var(--color-secondary); margin-left: .2em; }
.mandatory .question-text::after { content: ' *'; color: var(--color-secondary); }
fieldset.mandatory legend.question-text::after { content: ' *'; color: var(--color-secondary); }

/* ── Radio / Yes-No ───────────────────────────────────────────────────────── */
.radio-options, .yesno-options { display: flex; flex-direction: column; gap: .5rem; }
.radio-label {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  cursor: pointer;
  padding: .5rem .75rem;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  transition: background .15s, border-color .15s;
}
.radio-label:hover { background: #f0f4ff; border-color: var(--color-primary); }
.radio-label input[type="radio"] { margin-top: .2rem; flex-shrink: 0; accent-color: var(--color-primary); }
.yesno-options { flex-direction: row; gap: 1rem; }

/* ── Checkbox ─────────────────────────────────────────────────────────────── */
.checkbox-options { display: flex; flex-direction: column; gap: .5rem; }
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  cursor: pointer;
  padding: .5rem .75rem;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  transition: background .15s, border-color .15s;
}
.checkbox-label:hover { background: #f0f4ff; border-color: var(--color-primary); }
.checkbox-label input[type="checkbox"] { margin-top: .25rem; flex-shrink: 0; accent-color: var(--color-primary); }

/* ── Text inputs ──────────────────────────────────────────────────────────── */
.text-input, .select-input {
  width: 100%;
  padding: .55rem .75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color .15s, box-shadow .15s;
}
.text-input:focus, .select-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26,58,107,.15);
}
.textarea-input {
  width: 100%;
  padding: .65rem .75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: .97rem;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  resize: vertical;
  min-height: 200px;
  transition: border-color .15s, box-shadow .15s;
}
.textarea-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26,58,107,.15);
}

/* ── Multiple short text ──────────────────────────────────────────────────── */
.multishorttext-fields { display: flex; flex-direction: column; gap: .75rem; }
.field-row { display: flex; flex-direction: column; gap: .3rem; }
.field-row label { font-size: .9rem; color: var(--color-muted); }

/* ── Dropdown ─────────────────────────────────────────────────────────────── */
.question-dropdown .select-input { max-width: 400px; }

/* ── Upload ───────────────────────────────────────────────────────────────── */
.upload-field { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: .5rem; }
.file-input { display: none; }
.file-label {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem 1.1rem;
  background: var(--color-primary);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: .95rem;
  transition: background .15s;
}
.file-label:hover { background: #122d54; }
.file-name-display { font-size: .88rem; color: var(--color-muted); }
.upload-current {
  background: var(--color-success-bg);
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: .75rem 1rem;
  margin-bottom: .75rem;
  font-size: .9rem;
  color: var(--color-success);
}

/* ── Boilerplate ──────────────────────────────────────────────────────────── */
.boilerplate-text {
  background: #fffbe6;
  border-left: 4px solid #fbbf24;
  padding: 1rem 1.25rem;
  border-radius: 0 6px 6px 0;
  font-size: .95rem;
}
.boilerplate-text p { margin-bottom: .5rem; }
.boilerplate-text p:last-child { margin-bottom: 0; }
.boilerplate-text address { font-style: normal; margin-top: .5rem; }

/* ── Form actions ─────────────────────────────────────────────────────────── */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  padding: .65rem 1.5rem;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, box-shadow .15s;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: #122d54; }
.btn-secondary { background: var(--color-surface); color: var(--color-primary); border: 2px solid var(--color-primary); }
.btn-secondary:hover { background: #f0f4ff; }

/* ── Thank you ────────────────────────────────────────────────────────────── */
.thankyou-box {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 2.5rem;
  box-shadow: var(--shadow);
  max-width: 600px;
  margin: 2rem auto;
  text-align: center;
}
.thankyou-box h1 { color: var(--color-primary); margin-bottom: 1rem; font-size: 1.5rem; }
.thankyou-box p { margin-bottom: .75rem; color: var(--color-muted); }
.thankyou-team { font-style: italic; margin-top: 1.5rem; }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--color-primary);
  color: rgba(255,255,255,.7);
  font-size: .82rem;
  padding: .75rem 0;
  text-align: center;
}
.site-footer a { color: rgba(255,255,255,.9); }

/* ── Admin ────────────────────────────────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th, .admin-table td {
  padding: .6rem .8rem;
  border: 1px solid var(--color-border);
  text-align: left;
}
.admin-table th { background: #f1f5fb; font-weight: 600; }
.admin-table tr:nth-child(even) { background: #fafbfd; }
.badge { padding: .2em .6em; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge-completed { background: var(--color-success-bg); color: var(--color-success); }
.badge-partial   { background: #fffbe6; color: #92400e; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .survey-step { padding: 1.25rem; }
  .form-actions { flex-direction: column-reverse; }
  .btn { width: 100%; justify-content: center; }
  .yesno-options { flex-direction: column; }
}
