/* =======================================================================
   MARKDOWN EDITOR DSFR - STYLE 100% DSFR
   Bleu marine officiel : #000091
   ======================================================================= */

/* --- VARIABLES --- */
:root {
  --blue-marine: #000091;
  --blue-marine-hover: #1212ff;
  --blue-marine-active: #2323ff;
}

/* --- CONTENEUR --- */
.fr-container {
  max-width: 1200px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 5rem !important;
  padding-right: 5rem !important;
}

main {
  padding-top: 2rem !important;
  padding-bottom: 2rem !important;
}

/* =======================================================================
   TOOLBAR : ordre = markdown-fixed-bar EN HAUT, toolbar-tabs EN BAS
   ======================================================================= */

.dsfr-toolbar {
  background: white;
  padding: 0;
  margin-bottom: 0;
  border: none;
  border-bottom: 2px solid var(--blue-marine);
  display: flex;
  flex-direction: column;
}

/* ---- 1. BARRE MARKDOWN (toujours visible, en PREMIER dans le flex) ---- */
.markdown-fixed-bar {
  order: 0;
  background: var(--background-contrast-grey, #f6f6f6);
  padding: 0.4rem 1rem;
  border-bottom: 1px solid var(--border-default-grey, #ddd);
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  align-items: center;
}

.markdown-fixed-bar .toolbar-group {
  display: inline-flex;
  gap: 0.2rem;
  margin-right: 1rem;
  padding-right: 1rem;
  border-right: 1px solid var(--border-default-grey, #ddd);
  align-items: center;
}

.markdown-fixed-bar .toolbar-group:last-child {
  border-right: none;
}

/* Boutons de la barre Markdown - fond blanc avec bordure */
.markdown-fixed-bar .fr-btn {
  background: white !important;
  color: var(--blue-marine) !important;
  border: 1px solid #c1c1fb !important;
  box-shadow: none !important;
  padding: 0.3rem 0.5rem !important;
  min-width: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 4px !important;
}

.markdown-fixed-bar .fr-btn:hover {
  background: #ebebff !important;
  border-color: var(--blue-marine) !important;
}

.markdown-fixed-bar .fr-btn i {
  font-size: 1rem;
}

/* Thème sombre pour barre Markdown */
[data-fr-scheme="dark"] .markdown-fixed-bar {
  background: #1e1e1e;
  border-bottom-color: #444;
}

[data-fr-scheme="dark"] .markdown-fixed-bar .toolbar-group {
  border-right-color: #444;
}

[data-fr-scheme="dark"] .markdown-fixed-bar .fr-btn {
  background: #2a2a2a !important;
  color: #c8c8ff !important;
  border-color: #555 !important;
}

[data-fr-scheme="dark"] .markdown-fixed-bar .fr-btn:hover {
  background: #3a3a6a !important;
  border-color: #8888ff !important;
}

/* ---- 2. BARRE DES ONGLETS (en SECOND dans le flex) ---- */
.toolbar-tabs {
  order: 1;
  display: flex;
  gap: 0;
  background: var(--blue-marine);
  padding: 0;
  align-items: center;
}

/* Boutons onglets - non actif */
.toolbar-tab,
.toolbar-tab.fr-btn,
.toolbar-tab.fr-btn--sm {
  background: transparent !important;
  color: white !important;
  border: none !important;
  border-bottom: 3px solid transparent !important;
  padding: 0.5rem 1.2rem !important;
  cursor: pointer;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  transition: background 0.15s;
  white-space: nowrap;
}

.toolbar-tab:hover,
.toolbar-tab.fr-btn:hover {
  background: rgba(255, 255, 255, 0.12) !important;
  color: white !important;
  border-bottom-color: rgba(255,255,255,0.3) !important;
}

/* Onglet actif - fond blanc */
.toolbar-tab.active,
.toolbar-tab.active.fr-btn,
.toolbar-tab.active.fr-btn--sm {
  background: white !important;
  color: var(--blue-marine) !important;
  border: none !important;
  border-bottom: 3px solid var(--blue-marine) !important;
  font-weight: 700 !important;
}

/* Séparateur visuel avant le bouton plein écran */
.fullscreen-tab-btn::before {
  content: '';
  display: inline-block;
  width: 1px;
  height: 1.2rem;
  background: rgba(255, 255, 255, 0.3);
  margin-right: 0.8rem;
}

/* Thème sombre pour onglet actif */
[data-fr-scheme="dark"] .toolbar-tab.active,
[data-fr-scheme="dark"] .toolbar-tab.active.fr-btn {
  background: #2a2a2a !important;
  color: #c8c8ff !important;
  border-bottom-color: #c8c8ff !important;
}

[data-fr-scheme="dark"] .toolbar-tabs {
  background: #0d0d5e;
}

/* ---- BOUTON PLEIN ÉCRAN (tout à droite dans toolbar-tabs) ---- */
.fullscreen-tab-btn {
  margin-left: auto !important;
  background: rgba(255, 255, 255, 0.15) !important;
  color: white !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  border-radius: 4px !important;
  padding: 0.3rem 0.8rem !important;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.4rem !important;
  margin-right: 0.5rem !important;
  box-shadow: none !important;
  transition: background 0.15s;
  min-width: 0 !important;
  white-space: nowrap !important;
}

.fullscreen-tab-btn i {
  font-size: 0.85rem;
}

.fullscreen-tab-btn:hover {
  background: rgba(255, 255, 255, 0.28) !important;
  border-color: rgba(255, 255, 255, 0.6) !important;
}

body.fullscreen-mode .fullscreen-tab-btn {
  display: none !important;
}

/* ---- BOUTON EXIT plein écran ---- */
.exit-inline {
  background: rgba(255, 80, 80, 0.25) !important;
  color: white !important;
  border: 1px solid rgba(255, 150, 150, 0.5) !important;
  border-radius: 4px !important;
  padding: 0.3rem 0.8rem !important;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  display: none;
  align-items: center !important;
  gap: 0.4rem !important;
  margin-right: 0.5rem !important;
  margin-left: auto !important;
  box-shadow: none !important;
  white-space: nowrap;
  transition: background 0.15s;
}

.exit-inline i {
  font-size: 0.85rem;
}

.exit-inline:hover {
  background: rgba(255, 80, 80, 0.45) !important;
  border-color: rgba(255, 150, 150, 0.8) !important;
}

body.fullscreen-mode .exit-inline {
  display: inline-flex !important;
}

/* ---- 3. CONTENU DES ONGLETS ---- */
.toolbar-content {
  order: 2;
  padding: 0.6rem 1rem;
  background: white;
  min-height: 52px;
  border-top: 1px solid #e8e8ff;
}

[data-fr-scheme="dark"] .toolbar-content {
  background: #1a1a2e;
  border-top-color: #333;
}

.toolbar-panel {
  display: none;
}

.toolbar-panel.active {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* ---- GROUPES dans les panels ---- */
.toolbar-group {
  display: inline-flex;
  gap: 0.4rem;
  margin-right: 1rem;
  padding-right: 1rem;
  border-right: 1px solid var(--border-default-grey, #ddd);
  flex-wrap: wrap;
  align-items: center;
}

.toolbar-group:last-child {
  border-right: none;
  margin-right: 0;
  padding-right: 0;
}

[data-fr-scheme="dark"] .toolbar-group {
  border-right-color: #444;
}

/* ---- BOUTONS dans les panels - Bleu marine DSFR avec icon + label ---- */
.toolbar-content .fr-btn,
.toolbar-panel .fr-btn {
  background: var(--blue-marine) !important;
  color: white !important;
  border: none !important;
  box-shadow: none !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.35rem !important;
  padding: 0.35rem 0.7rem !important;
  border-radius: 4px !important;
  font-size: 0.8rem !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  transition: background 0.15s, transform 0.1s;
}

.toolbar-content .fr-btn:hover,
.toolbar-panel .fr-btn:hover {
  background: var(--blue-marine-hover) !important;
  transform: translateY(-1px);
}

.toolbar-content .fr-btn i,
.toolbar-panel .fr-btn i {
  font-size: 0.9rem;
}

/* Thème sombre : boutons panels */
[data-fr-scheme="dark"] .toolbar-content .fr-btn,
[data-fr-scheme="dark"] .toolbar-panel .fr-btn {
  background: #3232a8 !important;
  color: white !important;
}

[data-fr-scheme="dark"] .toolbar-content .fr-btn:hover,
[data-fr-scheme="dark"] .toolbar-panel .fr-btn:hover {
  background: #4040c0 !important;
}

/* Cacher les labels de groupe */
.toolbar-group-label {
  display: none !important;
}

/* =======================================================================
   ÉDITEUR ET PREVIEW
   ======================================================================= */

.editor-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin: 2rem auto;
  max-width: 1400px;
  padding: 0;
}

.editor-panel,
.preview-panel {
  background: white;
  border: 2px solid var(--border-default-grey, #ddd);
  border-radius: 0.25rem;
  overflow: hidden;
}

.panel-header {
  background: var(--background-alt-grey, #f6f6f6);
  padding: 1rem 1.5rem;
  border-bottom: 2px solid var(--border-default-grey, #ddd);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-title-grey, #161616);
}

#markdown-input {
  width: 100%;
  min-height: 600px;
  padding: 2rem;
  font-family: 'Courier New', Consolas, Monaco, monospace;
  font-size: 14px;
  line-height: 1.8;
  border: none;
  resize: vertical;
  background: white;
  color: var(--text-default-grey, #3a3a3a);
}

#markdown-input:focus {
  outline: 2px solid var(--blue-marine);
  outline-offset: -2px;
}

#preview {
  min-height: 600px;
  padding: 2rem;
  overflow-y: auto;
}

/* Composants DSFR dans le preview */
#preview .fr-alert { margin-bottom: 1rem; }
#preview .fr-callout { margin-bottom: 1rem; }
#preview .fr-badge { margin-right: 0.5rem; margin-bottom: 0.5rem; }
#preview .fr-card { margin-bottom: 1rem; }
#preview h1, #preview h2, #preview h3 { margin-top: 1.5rem; margin-bottom: 0.75rem; }
#preview p { margin-bottom: 1rem; }
#preview ul, #preview ol { margin-bottom: 1rem; padding-left: 2rem; }

/* Thème sombre éditeur */
[data-fr-scheme="dark"] .editor-panel,
[data-fr-scheme="dark"] .preview-panel {
  background: #1a1a2e;
  border-color: #333;
}

[data-fr-scheme="dark"] .panel-header {
  background: #111128;
  border-color: #333;
  color: #e0e0ff;
}

[data-fr-scheme="dark"] #markdown-input {
  background: #1a1a2e;
  color: #e0e0ff;
}

/* =======================================================================
   BARRE D'ACTIONS
   ======================================================================= */

.action-bar {
  background: var(--background-action-low-blue-france, #ebebff);
  padding: 1.5rem;
  border-top: 2px solid var(--blue-marine);
  border-radius: 0 0 0.25rem 0.25rem;
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 2rem auto;
  max-width: 1400px;
}

.action-bar .fr-btn {
  min-width: 140px !important;
  background-color: var(--blue-marine) !important;
  color: white !important;
  border: none !important;
}

.action-bar .fr-btn:hover {
  background-color: var(--blue-marine-hover) !important;
}

[data-fr-scheme="dark"] .action-bar {
  background: #111128;
  border-color: #3232a8;
}

/* =======================================================================
   MODE PLEIN ÉCRAN
   ======================================================================= */

body.fullscreen-mode {
  overflow: hidden !important;
}

body.fullscreen-mode .fr-header,
body.fullscreen-mode .fr-footer {
  display: none !important;
}

body.fullscreen-mode main {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  padding: 0 !important;
  margin: 0 !important;
  z-index: 9999 !important;
  background: var(--background-default-grey, white) !important;
  display: flex !important;
  flex-direction: column !important;
}

body.fullscreen-mode .fr-container {
  max-width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
  height: 100vh !important;
  display: flex !important;
  flex-direction: column !important;
  flex: 1 !important;
}

body.fullscreen-mode .dsfr-toolbar {
  margin: 0 !important;
  border-radius: 0 !important;
  flex-shrink: 0 !important;
}

body.fullscreen-mode .toolbar-content {
  padding: 0.4rem 1rem !important;
}

body.fullscreen-mode .editor-container {
  flex: 1 !important;
  margin: 0 !important;
  padding: 0 !important;
  max-width: 100% !important;
  gap: 0 !important;
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  height: 100% !important;
  overflow: hidden !important;
}

body.fullscreen-mode .editor-panel,
body.fullscreen-mode .preview-panel {
  height: 100% !important;
  border-radius: 0 !important;
  border-left: none !important;
  border-right: none !important;
  display: flex !important;
  flex-direction: column !important;
}

body.fullscreen-mode .panel-header {
  flex-shrink: 0 !important;
}

body.fullscreen-mode #markdown-input,
body.fullscreen-mode #preview {
  flex: 1 !important;
  width: 100% !important;
  min-height: 0 !important;
  overflow-y: auto !important;
}

body.fullscreen-mode .action-bar {
  flex-shrink: 0 !important;
  border-radius: 0 !important;
  padding: 0.6rem 1rem !important;
  margin: 0 !important;
  max-width: 100% !important;
}

/* =======================================================================
   NOTIFICATION
   ======================================================================= */

.notification {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 1rem 1.5rem;
  background: #18753c;
  color: white;
  border-radius: 0.25rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  animation: slideIn 0.3s ease;
  font-weight: 600;
}

@keyframes slideIn {
  from { transform: translateY(100px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* =======================================================================
   RESPONSIVE
   ======================================================================= */

@media (max-width: 1200px) {
  .fr-container { padding-left: 3rem !important; padding-right: 3rem !important; }
}

@media (max-width: 992px) {
  .editor-container { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .fr-container { padding-left: 1rem !important; padding-right: 1rem !important; }
  .toolbar-tab { padding: 0.4rem 0.7rem !important; font-size: 0.78rem !important; }
}

/* --- Transitions globales douces --- */
* { transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease; }
button, .fr-btn { transition: all 0.15s ease !important; }

/* =======================================================================
   SLIDES
   ======================================================================= */

.slide-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 400px;
}

.slide-progress {
  height: 3px;
  background: var(--border-default-grey, #ddd);
  margin-bottom: 1.5rem;
  border-radius: 2px;
}

.slide-progress-bar {
  height: 100%;
  background: var(--blue-marine, #000091);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.slide-content {
  flex: 1;
  padding: 0.5rem 0;
}

.slide-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1rem;
  border-top: 1px solid var(--border-default-grey, #ddd);
  margin-top: 1.5rem;
  gap: 1rem;
}

.slide-counter {
  font-size: 0.875rem;
  color: var(--text-mention-grey, #666);
  font-weight: 600;
  white-space: nowrap;
}

/* Raccourcis clavier : tooltip discret sous le textarea */
.editor-panel::after {
  content: 'Ctrl+B Gras · Ctrl+I Italique · Ctrl+K Lien · Tab Indenter';
  display: block;
  padding: 0.25rem 1rem;
  font-size: 0.7rem;
  color: var(--text-mention-grey, #888);
  background: var(--background-alt-grey, #f6f6f6);
  border-top: 1px solid var(--border-default-grey, #eee);
  letter-spacing: 0.02em;
}

[data-fr-scheme="dark"] .slide-controls {
  border-top-color: #444;
}

[data-fr-scheme="dark"] .slide-progress {
  background: #333;
}

[data-fr-scheme="dark"] .editor-panel::after {
  background: #111128;
  color: #666;
  border-top-color: #333;
}

/* =======================================================================
   BOUTON PLEIN ÉCRAN dans la barre Markdown
   ======================================================================= */

.markdown-bar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-left: 1rem;
  border-left: 1px solid var(--border-default-grey, #ddd);
}

/* Bouton plein écran - icône + texte, discret */
.fullscreen-md-btn {
  background: transparent !important;
  color: var(--blue-marine) !important;
  border: 1px solid var(--blue-marine) !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.35rem !important;
  white-space: nowrap !important;
  padding: 0.3rem 0.7rem !important;
  border-radius: 4px !important;
  min-width: 0 !important;
}

.fullscreen-md-btn i {
  font-size: 0.9rem;
}

.fullscreen-md-btn:hover {
  background: var(--blue-marine) !important;
  color: white !important;
}

body:not(.fullscreen-mode) .exit-inline {
  display: none !important;
}

body.fullscreen-mode .fullscreen-md-btn {
  display: none !important;
}

/* Bouton EXIT — icône + texte, couleur atténuée (bleu marine transparent) */
.markdown-bar-right .exit-inline {
  background: rgba(0, 0, 145, 0.12) !important;
  color: var(--blue-marine) !important;
  border: 1px solid rgba(0, 0, 145, 0.3) !important;
  border-radius: 4px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.35rem !important;
  white-space: nowrap !important;
  margin-left: 0 !important;
  font-size: 0.8rem !important;
}

.markdown-bar-right .exit-inline i {
  font-size: 0.9rem;
}

.markdown-bar-right .exit-inline:hover {
  background: rgba(0, 0, 145, 0.22) !important;
  border-color: rgba(0, 0, 145, 0.5) !important;
}

body.fullscreen-mode .markdown-bar-right .exit-inline {
  display: inline-flex !important;
}

/* Supprimer les anciens styles plein écran standalone */
.fullscreen-tab-btn { display: none !important; }

[data-fr-scheme="dark"] .markdown-bar-right {
  border-left-color: #444;
}

[data-fr-scheme="dark"] .fullscreen-md-btn {
  background: #3232a8 !important;
}

/* =======================================================================
   DROPDOWNS ACTION BAR (Copier / Télécharger)
   ======================================================================= */

.action-dropdown-group {
  position: relative;
}

.action-dropdown-group > .fr-btn {
  background-color: var(--blue-marine) !important;
  color: white !important;
  border: none !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.4rem !important;
}

/* Flèche indicatrice sur le bouton parent */
.action-dropdown-group > .fr-btn::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid white;
  margin-left: 0.2rem;
  transition: transform 0.2s;
}

.action-dropdown-group > .fr-btn[aria-expanded="true"]::after {
  transform: rotate(180deg);
}

.action-dropdown-group > .fr-btn:hover {
  background-color: var(--blue-marine-hover) !important;
}

/* Menu dropdown */
.action-dropdown {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: white;
  border: 2px solid var(--blue-marine);
  border-radius: 4px;
  min-width: 200px;
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  z-index: 1000;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.12);
}

.action-dropdown[hidden] {
  display: none;
}

.action-dropdown li {
  margin: 0;
  padding: 0;
}

.action-dropdown .fr-nav__link {
  display: flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
  padding: 0.6rem 1rem !important;
  width: 100% !important;
  text-align: left !important;
  background: transparent !important;
  color: var(--text-default-grey, #3a3a3a) !important;
  border: none !important;
  cursor: pointer !important;
  font-size: 0.875rem !important;
  font-weight: 400 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.action-dropdown .fr-nav__link:hover {
  background: var(--background-action-low-blue-france, #ebebff) !important;
  color: var(--blue-marine) !important;
}

.action-dropdown .fr-nav__link i {
  font-size: 1rem;
  opacity: 0.8;
}

[data-fr-scheme="dark"] .action-dropdown {
  background: #1a1a2e;
  border-color: #3232a8;
}

[data-fr-scheme="dark"] .action-dropdown .fr-nav__link {
  color: #e0e0ff !important;
}

[data-fr-scheme="dark"] .action-dropdown .fr-nav__link:hover {
  background: #2a2a5a !important;
}

/* =======================================================================
   AUTO-SCROLL TEXTAREA - highlight de la ligne active
   ======================================================================= */

#markdown-input {
  scroll-behavior: smooth;
}

/* Indicateur ligne courante (pseudo via box-shadow inset sur focus) */
#markdown-input:focus {
  outline: 2px solid var(--blue-marine);
  outline-offset: -2px;
  box-shadow: inset 3px 0 0 var(--blue-marine);
}

/* =======================================================================
   PLEIN ÉCRAN SLIDES
   ======================================================================= */

/* Topbar de la slide : barre de progression + bouton FS à droite */
.slide-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.slide-topbar .slide-progress {
  flex: 1;
  margin-bottom: 0;
}

/* Bouton entrer plein écran slides — icône + texte, discret */
.slide-fs-btn {
  background: transparent !important;
  color: var(--blue-marine) !important;
  border: 1px solid var(--blue-marine) !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.35rem !important;
  white-space: nowrap !important;
  padding: 0.3rem 0.7rem !important;
  border-radius: 4px !important;
  font-size: 0.8rem !important;
  flex-shrink: 0;
}

.slide-fs-btn i { font-size: 0.9rem; }

.slide-fs-btn:hover {
  background: var(--blue-marine) !important;
  color: white !important;
}

/* Bouton quitter plein écran slides — atténué */
.slide-fs-exit-btn {
  background: rgba(0, 0, 145, 0.12) !important;
  color: var(--blue-marine) !important;
  border: 1px solid rgba(0, 0, 145, 0.3) !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.35rem !important;
  white-space: nowrap !important;
  font-size: 0.8rem !important;
  flex-shrink: 0;
}

.slide-fs-exit-btn i { font-size: 0.9rem; }

.slide-fs-exit-btn:hover {
  background: rgba(0, 0, 145, 0.22) !important;
  border-color: rgba(0, 0, 145, 0.5) !important;
}

/* Plein écran slides : le preview occupe tout l'écran */
body.slides-fs-active #preview.slides-fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 10000 !important;
  background: white !important;
  padding: 2rem 3rem !important;
  overflow-y: auto !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  border: none !important;
}

[data-fr-scheme="dark"] body.slides-fs-active #preview.slides-fullscreen {
  background: #0d0d1a !important;
}

/* Slide content en plein écran : texte plus grand */
body.slides-fs-active .slide-content {
  font-size: 1.15rem;
}

body.slides-fs-active .slide-content h1 { font-size: 2.5rem; }
body.slides-fs-active .slide-content h2 { font-size: 2rem; }
body.slides-fs-active .slide-content h3 { font-size: 1.5rem; }

/* Contrôles slides en plein écran : épinglés en bas */
body.slides-fs-active .slide-controls {
  margin-top: auto;
  padding-top: 2rem;
}

/* =======================================================================
   PANEL HEADER PREVIEW avec boutons slides
   ======================================================================= */

#preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

#slides-header-btns {
  display: none;
  align-items: center;
  gap: 0.5rem;
}

/* =======================================================================
   ANIMATION CHANGEMENT DE SLIDE
   ======================================================================= */

@keyframes slideInFromRight {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInFromLeft {
  from { opacity: 0; transform: translateX(-40px); }
  to   { opacity: 1; transform: translateX(0); }
}

.slide-anim-next {
  animation: slideInFromRight 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.slide-anim-prev {
  animation: slideInFromLeft 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

/* =======================================================================
   POLICE ADAPTATIVE EN PLEIN ÉCRAN SLIDES
   ======================================================================= */

body.slides-fs-active #preview.slides-fullscreen .slide-content {
  font-size: clamp(1rem, 2vw, 1.4rem);
}

body.slides-fs-active #preview.slides-fullscreen .slide-content h1 {
  font-size: clamp(1.8rem, 5vw, 3.5rem);
  line-height: 1.15;
}

body.slides-fs-active #preview.slides-fullscreen .slide-content h2 {
  font-size: clamp(1.4rem, 3.5vw, 2.5rem);
  line-height: 1.2;
}

body.slides-fs-active #preview.slides-fullscreen .slide-content h3 {
  font-size: clamp(1.1rem, 2.5vw, 1.8rem);
}

body.slides-fs-active #preview.slides-fullscreen .slide-content p,
body.slides-fs-active #preview.slides-fullscreen .slide-content li {
  font-size: clamp(0.95rem, 1.8vw, 1.3rem);
  line-height: 1.7;
}

/* Supprimer les anciens styles font-size fixes */
body.slides-fs-active .slide-content { font-size: unset; }
body.slides-fs-active .slide-content h1 { font-size: unset; }
body.slides-fs-active .slide-content h2 { font-size: unset; }
body.slides-fs-active .slide-content h3 { font-size: unset; }

/* =======================================================================
   BOUTONS SLIDES PLEIN ÉCRAN dans toolbar-tabs
   ======================================================================= */

/* Bouton "Plein écran" slides — même style que le bouton plein écran global */
.slide-tab-fs-btn {
  margin-left: auto !important;
  background: rgba(255, 255, 255, 0.15) !important;
  color: white !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  border-radius: 4px !important;
  padding: 0.3rem 0.8rem !important;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  display: none;
  align-items: center !important;
  gap: 0.4rem !important;
  margin-right: 0.5rem !important;
  white-space: nowrap !important;
  box-shadow: none !important;
  transition: background 0.15s;
}

.slide-tab-fs-btn:hover {
  background: rgba(255, 255, 255, 0.28) !important;
  border-color: rgba(255, 255, 255, 0.6) !important;
}

/* Bouton "Quitter le plein écran" slides — atténué */
.slide-tab-fs-exit-btn {
  margin-left: auto !important;
  background: rgba(0, 0, 145, 0.2) !important;
  color: white !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  border-radius: 4px !important;
  padding: 0.3rem 0.8rem !important;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  display: none;
  align-items: center !important;
  gap: 0.4rem !important;
  margin-right: 0.5rem !important;
  white-space: nowrap !important;
  box-shadow: none !important;
  transition: background 0.15s;
}

.slide-tab-fs-exit-btn:hover {
  background: rgba(0, 0, 145, 0.35) !important;
}

/* =======================================================================
   SLIDES - TOPBAR (barre progression + bouton plein écran)
   ======================================================================= */

.slide-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.2rem;
  overflow: hidden;
}

.slide-topbar .slide-progress {
  flex: 1;
  margin-bottom: 0 !important;
}

/* Bouton Plein écran dans la slide */
.slide-fs-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 500;
  background: transparent;
  color: var(--blue-marine, #000091);
  border: 1px solid var(--blue-marine, #000091);
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.slide-fs-btn:hover {
  background: var(--blue-marine, #000091);
  color: white;
}

/* Bouton Quitter plein écran dans la slide — atténué */
.slide-fs-exit-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 500;
  background: rgba(0, 0, 145, 0.1);
  color: var(--blue-marine, #000091);
  border: 1px solid rgba(0, 0, 145, 0.3);
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.slide-fs-exit-btn:hover {
  background: rgba(0, 0, 145, 0.2);
}

/* =======================================================================
   ANIMATION SLIDES — correction overflow hidden pour que ça marche
   ======================================================================= */

.slide-wrapper {
  overflow: hidden;
}

@keyframes slideFromRight {
  from { opacity: 0; transform: translateX(50px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideFromLeft {
  from { opacity: 0; transform: translateX(-50px); }
  to   { opacity: 1; transform: translateX(0); }
}

.slide-anim-next {
  animation: slideFromRight 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}
.slide-anim-prev {
  animation: slideFromLeft 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

/* =======================================================================
   FIX CARTES DSFR - hauteur uniforme et badges
   ======================================================================= */

/* Cartes dans une grille : hauteur 100% pour uniformiser */
.fr-grid-row .fr-card {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.fr-card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.fr-card__content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Badge au-dessus du titre */
.fr-card__content .fr-badge {
  margin-bottom: 0.5rem;
  align-self: flex-start;
}

/* Titre et description prennent l'espace disponible */
.fr-card__title {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.fr-card__desc {
  margin-top: 0;
  flex: 1;
}

/* Image de carte : ratio uniforme */
.fr-card__img {
  aspect-ratio: 16/9;
  overflow: hidden;
  background: var(--background-contrast-grey, #f6f6f6);
}

.fr-card__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* =======================================================================
   FIX SLIDES - Responsive + Scroll + Boutons visibles
   ======================================================================= */

/* Wrapper de slide : scroll activé + hauteur max */
.slide-wrapper {
  display: flex;
  flex-direction: column;
  max-height: 100%;
  overflow-y: auto !important; /* SCROLL MOLETTE ACTIVÉ */
  overflow-x: hidden;
  padding-bottom: 1rem;
}

/* Contenu de slide : responsive avec tailles adaptatives */
.slide-content {
  flex: 1;
  overflow-x: hidden;
  word-wrap: break-word;
  padding: 0.5rem 0;
  min-height: 0; /* permet le shrink */
}

/* Titres responsives en mode slides */
.slide-content h1 {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  line-height: 1.2;
  margin: 1rem 0 0.75rem;
}

.slide-content h2 {
  font-size: clamp(1.2rem, 3vw, 2rem);
  line-height: 1.25;
  margin: 0.75rem 0 0.5rem;
}

.slide-content h3 {
  font-size: clamp(1rem, 2.2vw, 1.5rem);
  line-height: 1.3;
  margin: 0.5rem 0;
}

.slide-content p,
.slide-content li {
  font-size: clamp(0.875rem, 1.5vw, 1.1rem);
  line-height: 1.6;
}

/* Contrôles slides : TOUJOURS VISIBLES en bas */
.slide-controls {
  flex-shrink: 0;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-default-grey, #ddd);
  background: white;
  position: sticky;
  bottom: 0;
  z-index: 10;
}

/* Mode plein écran slides : scroll + boutons fixes */
body.slides-fs-active #preview.slides-fullscreen {
  overflow-y: auto !important; /* SCROLL MOLETTE EN PLEIN ÉCRAN */
  padding: 1.5rem 2rem 2rem;
}

body.slides-fs-active .slide-wrapper {
  max-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.slides-fs-active .slide-content {
  flex: 1;
  min-height: 0;
  overflow-y: visible;
}

/* Topbar et contrôles sticky en plein écran */
body.slides-fs-active .slide-topbar {
  position: sticky;
  top: 0;
  background: white;
  z-index: 20;
  padding: 0.75rem 0;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--border-default-blue-france, #e5e5f4);
}

body.slides-fs-active .slide-controls {
  position: sticky;
  bottom: 0;
  background: white;
  z-index: 20;
  padding: 1rem 0 0.5rem;
  margin-top: auto;
  border-top: 2px solid var(--border-default-blue-france, #e5e5f4);
}

/* Dark mode */
[data-fr-scheme="dark"] .slide-controls,
[data-fr-scheme="dark"] body.slides-fs-active .slide-topbar,
[data-fr-scheme="dark"] body.slides-fs-active .slide-controls {
  background: #1a1a2e;
  border-color: #444;
}

[data-fr-scheme="dark"] body.slides-fs-active #preview.slides-fullscreen {
  background: #0d0d1a !important;
}

/* Composants DSFR dans slides : responsive */
.slide-content .fr-card,
.slide-content .fr-tile,
.slide-content .fr-callout,
.slide-content .fr-alert {
  font-size: clamp(0.875rem, 1.4vw, 1rem);
}

.slide-content .fr-card__title,
.slide-content .fr-tile__title {
  font-size: clamp(1rem, 2vw, 1.3rem) !important;
}

/* Images responsives dans slides */
.slide-content img {
  max-width: 100%;
  height: auto;
}

/* Mobile : réduire encore les tailles */
@media (max-width: 768px) {
  body.slides-fs-active #preview.slides-fullscreen {
    padding: 1rem;
  }
  
  .slide-content h1 { font-size: clamp(1.3rem, 5vw, 1.8rem); }
  .slide-content h2 { font-size: clamp(1.1rem, 4vw, 1.5rem); }
  .slide-content h3 { font-size: clamp(0.95rem, 3vw, 1.2rem); }
  
  .slide-controls button {
    font-size: 0.75rem;
    padding: 0.4rem 0.6rem;
  }
}

/* =======================================================================
   VIDÉOS (composant media)
   ======================================================================= */

.fr-content-media {
  margin: 1.5rem 0;
}

.fr-content-media__img {
  position: relative;
  background: #000;
  border-radius: 4px;
  overflow: hidden;
}

.fr-responsive-vid {
  width: 100%;
  height: auto;
  display: block;
  max-width: 100%;
}

/* Légende vidéo */
.fr-content-media p {
  color: var(--text-mention-grey, #666);
  font-size: 0.875rem;
  margin-top: 0.5rem;
  font-style: italic;
}

/* =======================================================================
/* =======================================================================
   TABLEAUX MARKDOWN - Style DSFR officiel avec classe fr-table
   ======================================================================= */

/* Wrapper DSFR pour tableaux */
#preview table {
  display: table;
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  border: none;
  background: transparent;
  font-size: 0.875rem;
}

/* Container responsive DSFR */
#preview table {
  box-shadow: inset 0 -1px 0 0 var(--border-default-grey);
}

#preview thead {
  background: transparent;
}

#preview thead th {
  padding: 1rem;
  text-align: left;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text-title-grey, #161616);
  border-bottom: 2px solid var(--border-plain-grey, #ddd);
  background: var(--background-contrast-grey, #f6f6f6);
}

#preview tbody {
  background: white;
}

#preview tbody tr {
  border-bottom: 1px solid var(--border-default-grey, #e5e5e5);
  transition: background 0.15s;
}

#preview tbody tr:nth-child(even) {
  background: var(--background-alt-grey, #f9f9f9);
}

#preview tbody tr:hover {
  background: var(--background-contrast-grey-hover, #eeeeee);
}

#preview tbody td {
  padding: 1rem;
  color: var(--text-default-grey, #3a3a3a);
  vertical-align: top;
}

/* Alignement */
#preview table th[align="center"],
#preview table td[align="center"] { text-align: center; }
#preview table th[align="right"],
#preview table td[align="right"] { text-align: right; }

/* Dark mode */
[data-fr-scheme="dark"] #preview thead th {
  color: #e0e0ff;
  background: #2a2a3e;
  border-bottom-color: #444;
}

[data-fr-scheme="dark"] #preview tbody {
  background: #1a1a2e;
}

[data-fr-scheme="dark"] #preview tbody tr {
  border-bottom-color: #333;
}

[data-fr-scheme="dark"] #preview tbody tr:nth-child(even) {
  background: #20202e;
}

[data-fr-scheme="dark"] #preview tbody tr:hover {
  background: #2a2a40;
}

[data-fr-scheme="dark"] #preview tbody td {
  color: #c8c8e0;
}

/* Mobile : scroll horizontal */
@media (max-width: 768px) {
  #preview table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* Supprimer les anciens styles table génériques */
table:not(#preview table) {
  /* garde les styles par défaut pour d'autres tables */
}
    overflow-x: auto;
    white-space: nowrap;
  }
}
