/* =========================================================
   Formesia — styles communs
   Couleurs : violet #5B2FC0 · encre #211A33 · corail #FF6B4F
   Polices : Nunito (titres) et Inter (texte), via Google Fonts.
   Pour un hébergement 100 % suisse, téléchargez ces polices et
   servez-les depuis /assets/fonts (voir README).
   ========================================================= */

:root {
  --fm-violet: #5B2FC0;
  --fm-violet-dark: #43209A;
  --fm-violet-soft: #F1ECFD;
  --fm-ink: #211A33;
  --fm-muted: #5E5873;
  --fm-coral: #FF6B4F;
  --fm-line: #ECE9F3;
  --fm-bg: #F7F6FB;
}

html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--fm-ink); }
img { max-width: 100%; }
dc-import { display: block; width: 100%; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--fm-violet); }
a:hover { color: var(--fm-violet-dark); }

/* Focus visible au clavier */
:focus-visible { outline: 3px solid var(--fm-coral); outline-offset: 2px; border-radius: 6px; }

/* Texte réservé aux lecteurs d'écran */
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Survols partagés */
.nav-link:hover, .ghost:hover, .row-btn:hover { background: #F4F0FD; }
.card:hover { border-color: #B9A6F0; box-shadow: 0 8px 22px rgba(91, 47, 192, 0.08); }
.tile:hover { border-color: #B9A6F0; box-shadow: 0 6px 18px rgba(91, 47, 192, 0.08); }
.qtype:hover { border-color: #B9A6F0; background: #FBFAFE; }
.frow:hover { background: #FBFAFE; }
.bar:hover { filter: brightness(1.12); }

/* Notifications (FM.toast) */
.fm-toasts { position: fixed; z-index: 1000; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.fm-toast { padding: 12px 18px; border-radius: 12px; background: var(--fm-ink); color: #FFFFFF; font: 600 14px/1.4 Inter, system-ui, sans-serif; box-shadow: 0 10px 30px rgba(33, 26, 51, 0.25); transition: opacity .3s, transform .3s; max-width: min(520px, 90vw); }
.fm-toast-error { background: #B8341A; }
.fm-toast-out { opacity: 0; transform: translateY(8px); }

/* Boîtes de dialogue (FM.dialog, FM.confirm, FM.prompt) */
.fm-modal-back { position: fixed; inset: 0; z-index: 999; background: rgba(33, 26, 51, 0.45); display: flex; align-items: center; justify-content: center; padding: 20px; }
.fm-modal { width: 100%; max-width: 460px; background: #FFFFFF; border-radius: 20px; padding: 24px; box-sizing: border-box; display: flex; flex-direction: column; gap: 14px; font: 15px/1.5 Inter, system-ui, sans-serif; color: var(--fm-ink); box-shadow: 0 20px 50px rgba(33, 26, 51, 0.25); }
.fm-modal h2 { margin: 0; font-family: Nunito, sans-serif; font-weight: 900; font-size: 22px; line-height: 1.2; }
.fm-modal p { margin: 0; color: #4A4460; }
.fm-modal label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.fm-input { height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid #DCD8E6; font: inherit; font-weight: 400; color: var(--fm-ink); box-sizing: border-box; width: 100%; }
textarea.fm-input { height: 110px; padding: 12px 14px; resize: vertical; }
.fm-modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.fm-btn, .fm-btn-ghost { min-height: 44px; padding: 0 18px; border-radius: 12px; font-weight: 700; font-size: 14px; }
.fm-btn { border: 0; background: var(--fm-violet); color: #FFFFFF; }
.fm-btn-danger { background: #B8341A; }
.fm-btn-ghost { border: 1px solid #DCD8E6; background: #FFFFFF; color: var(--fm-ink); }
.fm-menu { position: absolute; z-index: 50; min-width: 200px; background: #FFFFFF; border: 1px solid var(--fm-line); border-radius: 14px; padding: 6px; box-shadow: 0 12px 30px rgba(33, 26, 51, 0.14); display: flex; flex-direction: column; }
.fm-menu button { text-align: left; min-height: 38px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; font-size: 14px; color: var(--fm-ink); }
.fm-menu button:hover { background: var(--fm-violet-soft); }
.fm-menu button.danger { color: #B8341A; }

/* Éditeur : champs modifiables sur place, qui gardent l'apparence du texte affiché */
.fm-inline { display: block; width: 100%; box-sizing: border-box; padding: 4px 8px; margin-left: -8px !important; border: 1px dashed transparent; border-radius: 8px; background: transparent; font-family: inherit; line-height: 1.3; }
.fm-inline:hover { border-color: #DCD8E6; }
.fm-inline:focus { outline: none; border-color: var(--fm-violet); border-style: solid; background: #FFFFFF; }
.fm-inline[readonly] { border-color: transparent; }
.fm-inline::placeholder { color: #9A93AE; }
.fm-icon-btn { width: 34px; height: 34px; border: 0; border-radius: 9px; background: transparent; color: #4A4460; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 18px; }
.fm-icon-btn:hover { background: var(--fm-violet-soft); }
.fm-icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }

/* Application responsive (seuils du prototype) : rail d'icônes sur tablette, onglets en bas sur mobile.
   Les styles des écrans sont en ligne : ces règles ne touchent que les conteneurs fm-shell / fm-side / fm-page. */
@media (max-width: 1023px) {
  .fm-shell { flex-wrap: nowrap !important; }
  .fm-side { flex: 0 0 76px !important; position: sticky; top: 0; align-self: flex-start; height: 100vh; overflow-y: auto; box-sizing: border-box; }
  .fm-page { padding: 24px !important; }
  .fm-admin-side { flex-basis: 100% !important; }
}
@media (max-width: 639px) {
  .fm-shell { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .fm-side { flex: 0 0 0 !important; width: 0; height: auto; overflow: visible; border: 0 !important; position: static; }
  .fm-page { padding: 16px !important; }
  .fm-page h1 { font-size: 24px !important; }
  body:has(.fm-shell) .fm-toasts { bottom: calc(88px + env(safe-area-inset-bottom)); }
  .fm-ed-head { padding: 10px 16px !important; }
  .fm-ed-main { order: -1; }
  .fm-scroll-x { flex-basis: 100% !important; min-width: 0; overflow-x: auto; justify-content: flex-start !important; scrollbar-width: none; }
  .fm-scroll-x::-webkit-scrollbar { display: none; }
  .fm-scroll-x > * { flex: none; }
}

@media print {
  .fm-side { display: none !important; }
  .fm-noprint, #fm-toasts { display: none !important; }
  body { background: #FFFFFF !important; }
  section, li { break-inside: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
