/* =========================================================
   MedFiches AI — Design tokens
   Palette clinique (navy/teal) + accent "surligneur" ambre
   Display: Fraunces — Corps: Inter — Utilitaire: IBM Plex Mono
   ========================================================= */

:root {
  --bg:            #F4F8F7;
  --surface:       #FFFFFF;
  --surface-alt:   #EEF4F2;
  --ink:           #142A2E;
  --ink-muted:     #5B7278;
  --border:        #DCE7E4;

  --primary:       #0E3A45;
  --primary-soft:  #E7EEEF;
  --teal:          #3FA796;
  --teal-soft:     #E1F2EE;
  --amber:         #F2A65A;
  --amber-soft:    #FCEBD6;
  --danger:        #C1443A;
  --danger-soft:   #FBEAE8;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;

  --shadow-card: 0 1px 2px rgba(14, 58, 69, 0.04), 0 12px 28px -12px rgba(14, 58, 69, 0.14);
  --shadow-pop:  0 20px 45px -18px rgba(14, 58, 69, 0.35);
}

* { box-sizing: border-box; }

/* Garantit que [hidden] est toujours respecté, même sur des éléments
   auxquels on applique par ailleurs display:flex/grid en JS/CSS. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 15% -10%, var(--teal-soft) 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

.app-shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ---------------- HEADER ---------------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 22px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  color: var(--primary);
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  flex-shrink: 0;
}
.brand-mark svg { width: 24px; height: 24px; }

.brand-text { display: flex; flex-direction: column; }

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.28rem;
  color: var(--primary);
  letter-spacing: -0.01em;
}
.brand-name em { font-style: italic; color: var(--teal); }

.brand-name .brand-ai {
  font-size: 0.55em;
  font-weight: 700;
  font-style: normal;
  color: var(--primary);
  vertical-align: super;
  letter-spacing: 0.03em;
  margin-left: 3px;
}

.brand-tagline {
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
}

.brand-signature {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--ink-muted);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
}

.brand-link {
  text-decoration: none;
  color: inherit;
  display: block;
}
.brand-link:hover,
.brand-link:visited,
.brand-link:active {
  text-decoration: none;
  color: inherit;
}

/* ---------------- TABLEAU DE BORD (grille de fonctionnalités) ---------------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.dashboard-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.dashboard-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-pop);
}

.dashboard-card-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--card-color) 14%, white);
  color: var(--card-color);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.dashboard-card-icon svg { width: 22px; height: 22px; }

.dashboard-card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--primary);
  margin: 0 0 8px;
}

.dashboard-card-desc {
  font-size: 0.88rem;
  color: var(--ink-muted);
  line-height: 1.5;
  margin: 0 0 16px;
  flex: 1;
}

.dashboard-card-cta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--teal);
}

.dashboard-card.is-featured {
  border: 2px solid var(--amber);
  background: #FFF8EF;
  position: relative;
}
.dashboard-card.is-featured:hover {
  box-shadow: 0 20px 45px -18px rgba(242, 166, 90, 0.45);
}

.dashboard-card-badge {
  position: absolute;
  top: -11px;
  left: 20px;
  background: var(--amber);
  color: #3A2405;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  box-shadow: 0 3px 8px rgba(0,0,0,0.12);
}

/* ---------------- HERO ---------------- */
.hero { padding: 20px 4px 36px; max-width: 640px; }

.hero-eyebrow {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--teal);
  margin: 0 0 10px;
  font-weight: 600;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  font-weight: 600;
  line-height: 1.15;
  color: var(--primary);
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}

.hero-subtitle {
  color: var(--ink-muted);
  font-size: 1rem;
  margin: 0;
}

/* ---------------- STEP CARDS ---------------- */
.workflow { display: flex; flex-direction: column; }

.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 28px;
  transition: opacity 0.25s ease;
}

.step-card[data-state="locked"] { opacity: 0.6; }

.step-head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }

.step-index {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--teal);
  background: var(--teal-soft);
  border-radius: 10px;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  flex-shrink: 0;
}

.step-eyebrow {
  margin: 0 0 2px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
}

.step-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--primary);
}

.step-body { display: flex; flex-direction: column; gap: 16px; }

/* ---------------- CONNECTOR (signature element) ---------------- */
.connector { height: 90px; display: flex; justify-content: center; }
.connector svg { height: 100%; width: 40px; color: var(--teal); }
.connector-line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0.55; }
.connector-pulse { stroke-dasharray: 140; stroke-dashoffset: 140; animation: draw-pulse 2.6s ease-in-out infinite; }

@keyframes draw-pulse {
  0%   { stroke-dashoffset: 140; opacity: 0.25; }
  45%  { stroke-dashoffset: 0;   opacity: 1; }
  100% { stroke-dashoffset: -140; opacity: 0.25; }
}

/* ---------------- DROPZONE ---------------- */
.dropzone {
  border: 1.6px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  color: var(--ink-muted);
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.12s ease;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--teal); background: var(--teal-soft); }
.dropzone.dragover { border-color: var(--teal); background: var(--teal-soft); transform: scale(1.005); }
.dropzone:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }

.dropzone-icon { width: 34px; height: 34px; color: var(--teal); margin-bottom: 10px; }
.dropzone-text { margin: 0 0 4px; color: var(--ink); font-size: 0.95rem; }
.dropzone-hint { margin: 0; font-size: 0.78rem; font-family: var(--font-mono); }

/* ---------------- FILE CHIP ---------------- */
.file-chip {
  display: flex; align-items: center; gap: 10px;
  /* ---------------- background: var(--primary-soft); ---------------- */
  background: #A8E0C0;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.88rem;
  color: var(--primary);
}
.file-chip svg { width: 18px; height: 18px; flex-shrink: 0; }
.file-chip span:first-of-type { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip-size { font-family: var(--font-mono); font-size: 0.76rem; color: var(--ink-muted); margin-left: auto; } 
.file-chip-remove {
  border: none; background: transparent; cursor: pointer; color: var(--ink-muted);
  font-size: 0.9rem; padding: 2px 6px; border-radius: 6px;
}
.file-chip-remove:hover { background: rgba(0,0,0,0.06); color: var(--danger); }

/* ---------------- BUTTONS ---------------- */
.btn {
  border: none; border-radius: 999px;
  padding: 13px 24px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.94rem;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:not(:disabled):hover { transform: translateY(-1px); }
.btn:not(:disabled):active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 10px 22px -10px rgba(14,58,69,0.5); }
.btn-accent  { background: var(--amber); color: #3A2405; box-shadow: 0 10px 22px -10px rgba(242,166,90,0.55); }

/* ---------------- ERROR ---------------- */
.error-msg {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.86rem;
  margin: 0;
}

.info-msg {
  background: var(--teal-soft);
  color: var(--primary);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.86rem;
  margin: 0 0 14px;
}

/* ---------------- LOADING ---------------- */
.loading-panel {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 18px 10px 4px;
  color: var(--ink-muted);
  font-size: 0.88rem;
  text-align: center;
}
.loading-panel small { display: block; margin-top: 4px; font-size: 0.76rem; opacity: 0.8; }
.ekg { width: 100%; max-width: 280px; height: 44px; color: var(--teal); }
.ekg svg { width: 100%; height: 100%; }
.ekg-line {
  fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 620;
  stroke-dashoffset: 620;
  animation: ekg-run 1.7s linear infinite;
}
@keyframes ekg-run { to { stroke-dashoffset: 0; } }

/* ---------------- RESULT / SUMMARY SHEET ---------------- */
.result-panel { display: flex; flex-direction: column; gap: 14px; }

.result-label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--teal);
  font-weight: 600;
}

.result-heading h3 {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--primary);
}

.title-edit-row { display: flex; align-items: center; gap: 8px; }

.summary-title-input {
  flex: 1;
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--primary);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
}

.title-icon-btn {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--ink-muted);
  padding: 4px 6px;
  border-radius: 6px;
  flex-shrink: 0;
}
.title-icon-btn:hover { background: var(--surface-alt); color: var(--teal); }

.title-icon-confirm { color: #2E9E4F; font-weight: 700; }
.title-icon-confirm:hover { background: #E4F5E9; color: #2E9E4F; }

.model-badge {
  margin: 8px 0 0;
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
}

.summary-sheet {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  max-height: 460px;
  overflow-y: auto;
}
.summary-sheet h2 {
  font-family: var(--font-display);
  color: #8B1E1E;
  font-weight: 700;
  margin: 18px 0 8px;
}
.summary-sheet h3, .summary-sheet h4 {
  font-family: var(--font-display);
  color: var(--primary);
  margin: 18px 0 8px;
}
.summary-sheet h2:first-child, .summary-sheet h3:first-child, .summary-sheet h4:first-child { margin-top: 0; }
.summary-sheet p { margin: 0 0 10px; color: var(--ink); font-size: 0.94rem; }
.summary-sheet ul { margin: 0 0 12px; padding-left: 20px; }
.summary-sheet li { margin-bottom: 6px; font-size: 0.94rem; }
.summary-sheet strong { color: var(--primary); }

.summary-sheet .key-critical {
  background: #FFFACD;
  color: inherit;
  font-weight: 500;
  padding: 0 4px;
  border-radius: 3px;
}

.summary-sheet .key-annex {
  background: #E9FACD;
  color: inherit;
  font-weight: 500;
  padding: 0 4px;
  border-radius: 3px;
}


/* ---------------- STEP 2 SPECIFIC ---------------- */
.locked-hint {
  background: var(--surface-alt);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  color: var(--ink-muted);
  font-size: 0.9rem;
  text-align: center;
}

.step2-intro { margin: 0; color: var(--ink-muted); font-size: 0.92rem; }
.step2-actions { display: flex; flex-direction: column; gap: 14px; }

.fiche-preview {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}
.fiche-preview img { width: 100%; display: block; }

.zoom-btn {
  position: absolute; bottom: 14px; right: 14px;
  background: rgba(20, 42, 46, 0.82);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.zoom-btn svg { width: 16px; height: 16px; }
.zoom-btn:hover { background: rgba(20, 42, 46, 0.95); }

/* ---------------- LIGHTBOX ---------------- */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(10, 20, 22, 0.92);
  display: flex; align-items: center; justify-content: center;
  padding: 30px;
  z-index: 100;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: var(--shadow-pop); cursor: zoom-out; }
.lightbox-close {
  position: absolute; top: 22px; right: 22px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: none;
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
}
.lightbox-close:hover { background: rgba(255,255,255,0.2); }

/* ---------------- FOOTER ---------------- */
.app-footer {
  text-align: center;
  margin-top: 40px;
  color: var(--ink-muted);
  font-size: 0.78rem;
  font-family: var(--font-mono);
}


/* ---------------- ÉDITEUR DE RÉSUMÉ ---------------- */
.summary-editor {
  width: 100%;
  min-height: 320px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  resize: vertical;
}

.summary-edit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.btn-link {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--teal);
  font-weight: 600;
  font-size: 0.86rem;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-link:hover { color: var(--primary); }

.btn-link:disabled {
  color: var(--ink-muted);
  text-decoration: none;
  cursor: default;
  opacity: 1; /* évite l'effet "grisé" par défaut du navigateur sur :disabled */
}

.summary-edit-actions { display: flex; gap: 12px; align-items: center; }

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 560px) {
  .app-shell { padding: 20px 14px 44px; }
  .step-card { padding: 20px; border-radius: var(--radius-md); }
  .hero-title { font-size: 1.6rem; }
  .btn { width: 100%; }
  .app-header { flex-direction: column; align-items: flex-start; }
}

/* ---------------- LAYOUT AVEC MENU LATÉRAL ---------------- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  max-height: 100dvh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 20px;
}
.sidebar-brand .brand-mark { width: 32px; height: 32px; color: var(--primary); flex-shrink: 0; }
.sidebar-brand .brand-mark svg { width: 20px; height: 20px; }
.sidebar-brand .brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--primary);
}
.sidebar-brand .brand-name em { font-style: italic; color: var(--teal); }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-link svg { width: 19px; height: 19px; flex-shrink: 0; }
.sidebar-link:hover { background: var(--surface-alt); color: var(--ink); }
.sidebar-link.is-active { background: var(--teal-soft); color: var(--primary); font-weight: 600; }

.sidebar-footer {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--ink-muted);
  padding: 12px 10px 4px;
  flex-shrink: 0;
}

.sidebar-collapse-btn {
  margin-left: auto;
  width: 28px; height: 28px;
  border: none;
  background: none;
  color: var(--ink-muted);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease, background 0.15s ease;
}
.sidebar-collapse-btn svg { width: 16px; height: 16px; }
.sidebar-collapse-btn:hover { background: var(--surface-alt); color: var(--teal); }

/* ---------------- MENU COMPTE (popup façon ChatGPT) ---------------- */
.account-menu {
  position: relative;
  flex-shrink: 0;
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.account-menu-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
}
.account-menu-trigger:hover { background: var(--surface-alt); }

.account-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.account-name {
  flex: 1;
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-chevron { width: 16px; height: 16px; color: var(--ink-muted); flex-shrink: 0; transition: transform 0.15s ease; }
.account-menu.is-open .account-chevron { transform: rotate(180deg); }

.account-popup {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  z-index: 20;
}

.account-popup-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.account-popup-name { font-weight: 600; font-size: 0.86rem; color: var(--ink); }
.account-popup-email { font-size: 0.76rem; color: var(--ink-muted); font-family: var(--font-mono); }

.account-popup-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  font-size: 0.86rem;
  color: var(--ink);
  text-decoration: none;
}
.account-popup-item svg { width: 17px; height: 17px; flex-shrink: 0; color: var(--ink-muted); }
.account-popup-item:hover { background: var(--surface-alt); }

.account-popup-item-danger { color: var(--danger); }
.account-popup-item-danger svg { color: var(--danger); }

button.account-popup-item {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-body);
}

/* En mode menu réduit (icônes seules), cache le nom et centre l'avatar */
.sidebar.is-collapsed .account-name,
.sidebar.is-collapsed .account-chevron { display: none; }
.sidebar.is-collapsed .account-menu-trigger { justify-content: center; }
.sidebar.is-collapsed .account-popup { left: 100%; bottom: 0; width: 220px; margin-left: 8px; }


/* ---- État réduit (desktop uniquement) ---- */
.sidebar.is-collapsed { width: 76px; }
.sidebar.is-collapsed .sidebar-collapse-btn { transform: rotate(180deg); }
.sidebar.is-collapsed .brand-name,
.sidebar.is-collapsed .sidebar-link span,
.sidebar.is-collapsed .sidebar-footer {
  display: none;
}
.sidebar.is-collapsed .sidebar-brand { justify-content: center; }
.sidebar.is-collapsed .sidebar-collapse-btn { margin-left: 0; position: absolute; top: 14px; right: 6px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-card); }
.sidebar.is-collapsed .sidebar-link { justify-content: center; padding: 10px; }
.sidebar.is-collapsed { position: sticky; } /* garantit le positionnement du bouton flottant */

/* Le bouton de réduction n'a de sens que sur desktop ; sur mobile le menu reste en tiroir plein */
@media (max-width: 860px) {
  .sidebar-collapse-btn { display: none; }
}

.app-main {
  flex: 1;
  min-width: 0;
  padding: 28px 20px 60px;
  overflow-x: hidden;
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 60;
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--primary);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-card);
}
.sidebar-toggle svg { width: 20px; height: 20px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 42, 46, 0.4);
  z-index: 40;
}

/* ---------------- RESPONSIVE : MENU EN TIROIR SUR MOBILE ---------------- */
@media (max-width: 860px) {
  .sidebar-toggle { display: flex; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    max-height: 100dvh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-pop);
  }
  .sidebar.is-open { transform: translateX(0); }

  .sidebar-overlay.is-visible { display: block; }

  .app-main { padding-top: 70px; }
}



/* ---------------- QUIZ INTERACTIF ---------------- */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}
.quiz-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--primary);
  margin: 0;
}
.quiz-progress {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-muted);
  background: var(--surface-alt);
  padding: 5px 12px;
  border-radius: 999px;
}

.quiz-question-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 18px;
  line-height: 1.5;
}

.quiz-options { display: flex; flex-direction: column; gap: 10px; }

.quiz-option {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.94rem;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.quiz-option:hover:not(:disabled) { border-color: var(--teal); background: var(--teal-soft); }
.quiz-option:disabled { cursor: default; }

.quiz-option-letter {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface-alt);
  color: var(--ink-muted);
  font-weight: 700;
  font-size: 0.82rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.quiz-option.is-correct { border-color: #2E9E4F; background: #E4F5E9; }
.quiz-option.is-correct .quiz-option-letter { background: #2E9E4F; color: #fff; }
.quiz-option.is-wrong { border-color: var(--danger); background: var(--danger-soft); }
.quiz-option.is-wrong .quiz-option-letter { background: var(--danger); color: #fff; }

.quiz-explanation {
  margin-top: 18px;
  padding: 16px 18px;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--ink);
}
.quiz-explanation strong { color: var(--primary); }

.quiz-score { text-align: center; padding: 20px 10px; }
.quiz-score-value {
  font-family: var(--font-display);
  font-size: 2.6rem;
  color: var(--primary);
  margin: 8px 0;
}
.quiz-score-label {
  color: var(--ink-muted);
  font-size: 0.95rem;
  margin: 0 0 24px;
}

/* ---------------- FLASHCARDS ---------------- */
.flashcard {
  perspective: 1200px;
  height: 260px;
  margin-bottom: 20px;
  cursor: pointer;
}
.flashcard-inner {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
}
.flashcard.is-flipped .flashcard-inner { transform: rotateY(180deg); }

.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px;
  box-shadow: var(--shadow-card);
}
.flashcard-front { background: var(--surface); }
.flashcard-front p { font-size: 1.15rem; font-weight: 600; color: var(--primary); margin: 0 0 14px; }
.flashcard-hint { font-family: var(--font-mono); font-size: 0.76rem; color: var(--ink-muted); }

.flashcard-back {
  background: var(--teal-soft);
  transform: rotateY(180deg);
}
.flashcard-back p { font-size: 1.02rem; color: var(--ink); margin: 0; line-height: 1.55; }

.flashcard-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

/* ---------------- FEUILLE D'EXAMEN (cas cliniques) ---------------- */
.case-block {
  margin-bottom: 30px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.case-block:last-of-type { border-bottom: none; }

.case-vignette {
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  font-size: 0.96rem;
  line-height: 1.6;
  color: var(--ink);
  margin-bottom: 16px;
}

.case-question { margin-bottom: 14px; }
.case-question-text {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.94rem;
  margin: 0 0 8px;
}

.case-answer {
  background: var(--teal-soft);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
}

/* Révélées d'un coup au clic sur "Afficher la correction" */
.case-sheet.is-revealed .case-answer {
  max-height: 400px;
  opacity: 1;
  padding-top: 12px;
  padding-bottom: 12px;
  margin-top: 6px;
}

/* ---------------- DOCUMENTATION : SOMMAIRE ---------------- */
.doc-toc {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.doc-toc a {
  color: var(--teal);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 4px 0;
}
.doc-toc a:hover { text-decoration: underline; }

/* ---------------- LANDING PAGE ---------------- */
.landing { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

.landing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0;
  flex-wrap: wrap;
  gap: 14px;
}
.landing-header-cta { padding: 10px 20px; font-size: 0.88rem; }

.landing-hero {
  text-align: center;
  max-width: 720px;
  margin: 40px auto 60px;
}
.landing-hero-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.8rem);
  font-weight: 600;
  color: var(--primary);
  line-height: 1.15;
  margin: 14px 0 18px;
}
.landing-hero-subtitle {
  color: var(--ink-muted);
  font-size: 1.05rem;
  margin: 0 0 28px;
}
.landing-hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.landing-section { margin: 70px 0; }
.landing-section-title {
  font-family: var(--font-display);
  font-size: 1.7rem;
  color: var(--primary);
  text-align: center;
  margin: 8px 0 36px;
}
.landing-grid { margin-top: 10px; }

.landing-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 28px;
}
.landing-step { text-align: center; padding: 10px; }
.landing-step .step-index {
  display: inline-flex;
  margin-bottom: 14px;
}
.landing-step h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--primary);
  margin: 0 0 8px;
}
.landing-step p {
  color: var(--ink-muted);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0;
}

.landing-cta {
  text-align: center;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 50px 30px;
  margin: 70px 0 40px;
}
.landing-cta h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin: 0 0 22px;
}
.landing-cta .btn-primary { background: #fff; color: var(--primary); }

@media (max-width: 560px) {
  .landing-header { justify-content: center; text-align: center; }
}

.auth-page { max-width: 420px; margin: 60px auto; padding: 0 20px; }
.auth-card { padding: 34px 28px; }
.auth-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--ink-muted); margin-bottom: 4px; }
.auth-divider { text-align: center; margin: 18px 0; position: relative; color: var(--ink-muted); font-size: 0.85rem; }
.auth-divider::before, .auth-divider::after { content: ''; position: absolute; top: 50%; width: 40%; height: 1px; background: var(--border); }
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

.auth-toggle { display: flex; gap: 8px; margin-bottom: 20px; }
.auth-toggle-btn {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink-muted);
}
.auth-toggle-btn.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------------- MA BIBLIOTHÈQUE ---------------- */
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.library-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
}

.library-thumb {
  height: 130px;
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
}
.library-thumb-text {
  padding: 14px;
  align-items: flex-start;
  background: var(--surface-alt);
}
.library-thumb-preview {
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--ink-muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.library-thumb img { width: 100%; height: 100%; object-fit: cover; }
.library-thumb svg { width: 34px; height: 34px; color: var(--teal); }

/* Vignettes de fiches : montre la fiche A4 en entier (sans rognage),
   au lieu de la remplir/couper dans un cadre carré. */
.library-thumb-fiche {
  height: auto;
  aspect-ratio: 210 / 297; /* proportions A4 portrait */
  background: var(--surface-alt);
  padding: 6px;
}
.library-thumb-fiche img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* montre l'image entière, quitte à laisser un peu d'espace vide sur les côtés */
}

.library-card-body { padding: 12px 14px; }
.library-card-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-card-date {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin: 0 0 10px;
}
.library-card-actions { display: flex; gap: 10px; }
.library-card-actions button {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--teal);
  padding: 0;
}
.library-card-actions button.is-danger { color: var(--danger); }

.library-icon-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0 !important;
  border-radius: 50%;
  background: var(--teal-soft);
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.library-icon-btn svg {
  width: 15px;
  height: 15px;
  color: var(--teal);
}
.library-icon-btn:hover {
  background: var(--teal);
  border-color: var(--teal);
  transform: translateY(-1px);
}
.library-icon-btn:hover svg { color: #fff; }

.download-summary-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
}

.library-empty {
  color: var(--ink-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 20px;
}

.library-jump-links {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.btn-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-chip:hover {
  background: var(--teal-soft);
  border-color: var(--teal);
}
#r1, #r2 { scroll-margin-top: 60px; margin-bottom: 20px; }

.library-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-left: auto;
}
.library-search svg { width: 16px; height: 16px; color: var(--ink-muted); flex-shrink: 0; }
.library-search input {
  border: none;
  background: none;
  font-size: 0.85rem;
  color: var(--ink);
  width: 140px;
  outline: none;
}
.library-search input::placeholder { color: var(--ink-muted); }

@media (max-width: 560px) {
  .library-jump-links { flex-wrap: wrap; }
  .library-search { margin-left: 0; width: 100%; }
  .library-search input { width: 100%; }
}
.is-public-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #E4F5E9;
  color: #2E9E4F;
}
.is-public-badge svg { width: 15px; height: 15px; }

.load-more-wrap {
  text-align: center;
  margin-top: 24px;
}

/* ---------------- SWITCH DE LANGUE ---------------- */
.lang-switch {
  display: inline-flex;
  align-items: center;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.lang-switch-option {
  padding: 5px 14px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.lang-switch-option:hover { color: var(--ink); }

.lang-switch-option.is-active {
  background: var(--primary);
  color: #fff;
  pointer-events: none; /* la langue déjà active n'est pas cliquable */
}

.img-responsive-center-demo {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}
/* ---------------- APERÇU MINIATURE EN DIRECT (bibliothèque) ---------------- */
.fiche-thumb-scale-wrapper {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
  background: #FFFDF7;
}
.fiche-thumb-inner {
  transform: scale(0.30); /* AJUSTE cette valeur selon la largeur réelle de .library-thumb (voir note ci-dessous) */
  transform-origin: top left;
  width: 210mm;
  pointer-events: none;
}

/* ---------------- CALCUL score---------------- */
.disclaimer-banner {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #FDF3E7;
  border: 1px solid #F2A65A;
  border-radius: 10px;
  padding: 7px 10px;
  margin: 10px 0;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  color: #142A2E;
}
.calc-card { margin-bottom: 14px; padding: 0; overflow: hidden; }
.calc-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: none;
  border: none;
  padding: 18px 22px;
  cursor: pointer;
  text-align: left;
}
.calc-name { font-family: 'Kalam', cursive; font-weight: 700; font-size: 16px; color: #0E3A45; margin: 0 0 4px; }
.calc-description { font-size: 13px; color: #5A6B6E; margin: 0; }
.calc-chevron { transition: transform 0.15s ease; flex-shrink: 0; color: #5A6B6E; }
.calc-chevron.is-open { transform: rotate(180deg); }
.calc-body { padding: 0 22px 22px; }
.calc-fields { margin-bottom: 16px; }
.calc-checkbox-row, .calc-radio-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 13.5px;
  cursor: pointer;
}
.calc-result {
  background: #F4F8F7;
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 14px;
}
.calc-result-value { font-family: 'Kalam', cursive; font-weight: 700; font-size: 19px; color: #0E3A45; margin-bottom: 6px; }
.calc-result-interpretation { font-size: 13.5px; font-weight: 700; margin-bottom: 10px; }
.calc-source { font-size: 11.5px; color: #8A9A9C; font-style: italic; }

.growth-result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 640px) {
  .growth-result-grid { grid-template-columns: 1fr; }
}
.field-hint { font-size: 12px; color: #5A6B6E; margin: 4px 0 14px; }
.field-optional { font-weight: 400; color: #8A9A9C; font-size: 11.5px; }
.btn-link-inline {
  background: none; border: none; padding: 0;
  color: #0E3A45; font-weight: 700; text-decoration: underline;
  font-size: 12px; cursor: pointer;
}
.calc-normal-range { font-size: 11.5px; color: #5A6B6E; margin-top: 8px; }
.calc-result-value.is-normal, .calc-result-interpretation.is-normal { color: #2D8A5F; }
.calc-result-value.is-abnormal, .calc-result-interpretation.is-abnormal { color: #A8321F; }

.field-label {
  display: block;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13px;
  color: #142A2E;
  margin: 16px 0 6px;
}
.text-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #E3DCC8;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  background: #fff;
  color: #142A2E;
  box-sizing: border-box;
}
.text-input:focus {
  outline: none;
  border-color: #3FA796;
}
.growth-age-label {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  color: #5A6B6E;
  margin: 10px 0 4px;
}
.dashboard-outils-banner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
  background: linear-gradient(135deg, #FFFDF7 0%, #EAF4F2 100%);
  border: 1px solid #B9D4CE;
  border-left: 4px solid #3FA796;
  border-radius: 12px;
  padding: 16px 22px;
  margin: 20px 0;
  box-shadow: 0 1px 3px rgba(14, 58, 69, 0.06);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  text-decoration: none;
  cursor: pointer;
}
.dashboard-outils-banner:hover {
  box-shadow: 0 6px 16px rgba(14, 58, 69, 0.1);
  transform: translateY(-1px);
}
.dashboard-outils-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: #FFFFFF;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(14, 58, 69, 0.1);
}
.dashboard-outils-text { flex: 1; min-width: 0; }
.dashboard-outils-title {
  font-family: 'Kalam', cursive;
  font-weight: 700;
  font-size: 16.5px;
  color: #0E3A45;
  margin: 0 0 4px;
}
.dashboard-outils-subtitle {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: #3E5A56;
  margin: 0;
  line-height: 1.45;
}
.dashboard-outils-btn {
  flex-shrink: 0;
  display: inline-block;
  background: #0E3A45;
  color: #FFFDF7;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 8px;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.dashboard-outils-banner:hover .dashboard-outils-btn {
  background: #000000;
  color: #FFFDF7;
}

@media (max-width: 640px) {
  .dashboard-outils-banner { flex-direction: column; text-align: center; border-left-width: 0; border-top: 4px solid #3FA796; }
}