body {
  counter-reset: figures;
}

h1 {
  text-align: center;
  color: #e54d2e;
}

h2 {
  color: #f16930;
}

h3 {
  color: #0870b9;
}

h4 {
  color: #33a8e3;
}

.loading-spinner {
  z-index: 9999;
  background-color: rgba(255, 255, 255, 60%);
  position: fixed;
  width: 100vw;
  height: 100vh;
}

.loading-spinner .spinner-border {
  position: absolute;
  top: calc(50% - 24px);
}

figure {
  counter-increment: figures;
  text-align: center;
  box-sizing: border-box;
  padding: 10px;
}

figure figcaption {
  font-style: italic;
  font-size: 0.9em;
}

figure figcaption::before {
  content: 'Figure ' counter(figures) ', ';
}

figure img {
  max-width: 100%;
}

main {
  min-height: 100vh;
}

blockquote {
  font-size: 0.95rem !important;
  font-style: italic;
  padding: 1rem 0.5rem 1rem 2rem;
  background-color: #eee;
  border: #666 solid 1px;
  border-radius: 8px;
}

blockquote p {
  margin: 0;
}

blockquote::before {
  content: '"';
  font-family: cursive;
  display: block;
  position: relative;
  top: -11px;
  left: -33px;
  width: 20px;
  height: 20px;
  font-size: 40pt;
}

.blockquote-footer {
  margin: inherit;
}

/*** switch start ***/

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

/* Hide default HTML checkbox */

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

/* The slider */

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #dc3545;
  -webkit-transition: .4s;
  transition: .4s;
}

.slider::before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
}

input:checked+.slider {
  background-color: #198754;
}

input:focus+.slider {
  box-shadow: 0 0 1px #198754;
}

input:checked+.slider:before {
  -webkit-transform: translateX(26px);
  -ms-transform: translateX(26px);
  transform: translateX(26px);
}

/* Rounded sliders */

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/*** switch end ***/

.language-algorithm::before,
.language-python::before {
  display: block;
  font-family: sans-serif;
  font-size: 0.7rem;
  font-weight: bold;
  margin-bottom: 0.5em;
  background-color: var(--bs-dark);
  color: var(--bs-light);
  padding: 0.25rem 0.5rem;
  border-radius: 0.5rem;
}

/* Supprimer les étiquettes doublonnées à l'intérieur des tableaux */
table .language-algorithm::before,
table .language-python::before {
  display: none !important;
}

/* Embellissement des blocs de code dans les tableaux */
table pre {
  margin: 0;
  padding: 0;
  background: transparent !important;
}

table code {
  border-radius: 6px;
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.9rem;
}

pre>code.shell.python.nohighlight {
  display: block;
  background-color: #333;
  color: #eee;
  padding: 0.5rem;
}

.shell.python::before {
  display: block;
  content: attr(data-text);
  font-weight: bold;
  font-style: italic;
  text-decoration: underline;
  text-align: center;
}

.bd-clipboard {
  position: relative;
  width: 100%;
}

.btn-clipboard {
  position: absolute;
  right: 15px;
  top: 13px;
  border: 0;
  background-color: transparent;
  color: var(--bs-light);
  margin: -6px;
}

/****Tables****/

table.col-2 td {
  width: calc(100% / 2);
}

table.col-3 td {
  width: calc(100% / 3);
}

table.col-4 td {
  width: calc(100% / 4);
}

table.col-5 td {
  width: calc(100% / 5);
}

table.col-6 td {
  width: calc(100% / 6);
}

table.col-7 td {
  width: calc(100% / 7);
}

table.col-8 td {
  width: calc(100% / 8);
}

table.col-9 td {
  width: calc(100% / 9);
}

table.col-10 td {
  width: calc(100% / 10);
}

table.col-11 td {
  width: calc(100% / 11);
}

table.col-12 td {
  width: calc(100% / 12);
}

table.col-13 td {
  width: calc(100% / 13);
}

table.col-14 td {
  width: calc(100% / 14);
}

table.col-15 td {
  width: calc(100% / 15);
}

table.col-16 td {
  width: calc(100% / 16);
}

table.col-17 td {
  width: calc(100% / 17);
}

table.col-18 td {
  width: calc(100% / 18);
}

table.col-19 td {
  width: calc(100% / 19);
}

table.col-20 td {
  width: calc(100% / 20);
}

/****Tables end****/

.list-group-item pre {
  margin: initial;
}

@media print {

  h1,
  h2,
  h3,
  h4 {
    font-size: auto !important;
  }

  .row .col-sm-6 {
    width: 50%;
  }

  p {
    margin: initial;
  }

  .p-break {
    page-break-before: always;
  }

  aside {
    display: none !important;
  }

  .container {
    max-width: initial !important;
    width: initial !important;
  }

  figure {
    page-break-inside: avoid;
  }

  figure img.h2cm {
    max-height: 2cm !important;
  }

  figure img.h3cm {
    max-height: 3cm !important;
  }

  figure img.h4cm {
    max-height: 4cm !important;
  }

  figure img.h5cm {
    max-height: 5cm !important;
  }

  figure img.h6cm {
    max-height: 6cm !important;
  }

  figure img.h7cm {
    max-height: 7cm !important;
  }

  figure img.h8cm {
    max-height: 8cm !important;
  }

  figure img.h9cm {
    max-height: 9cm !important;
  }

  figure img.h10cm {
    max-height: 10cm !important;
  }

  figure img.h11cm {
    max-height: 11cm !important;
  }

  figure img.h12cm {
    max-height: 12cm !important;
  }

  figure img.h13cm {
    max-height: 13cm !important;
  }

  figure img.h14cm {
    max-height: 14cm !important;
  }

  figure img.h15cm {
    max-height: 15cm !important;
  }

  @page {
    counter-increment: page;
    counter-reset: page 1;

    @top-right {
      content: "Page " counter(page) " of " counter(pages);
    }
  }

  /* table th, table td {
    border: thin solid #000;
  } */
  .list-group-item {
    padding: initial;
    border: initial;
  }

  .list-group-item label.p-2 {
    padding: 0 0.5em !important;
  }
}

/* ======================================================
   Modern Interactive Extensions & Design System
   ====================================================== */
:root {
  --primary-color: #0d6efd;
  --secondary-color: #6c757d;
  --accent-color: #f16930;
  --bg-gradient: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.hero-banner {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #ffffff;
  border-radius: 16px;
  padding: 2.5rem 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.hero-banner h1 {
  color: #38bdf8 !important;
  font-weight: 800;
}

.card-module {
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.card-module:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 20px -3px rgba(0, 0, 0, 0.1);
}

.card-module .card-body {
  padding: 1.15rem;
}

.card-module h4 {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
}

.card-module p.card-text {
  font-size: 0.875rem;
  line-height: 1.4;
  margin-bottom: 0.75rem;
}

.card-module ul {
  margin-bottom: 0;
}

.qcm-question {
  background: #ffffff;
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  border: 2px solid #e9ecef;
  transition: border-color 0.2s ease;
}

.interactive-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
}

.interactive-box h4 {
  color: #1e293b;
  font-weight: 700;
  margin-bottom: 1rem;
}

.badge-python {
  background-color: #3776ab;
  color: white;
}

.badge-algo {
  background-color: #e54d2e;
  color: white;
}

.code-output {
  background-color: #0f172a;
  color: #38bdf8;
  font-family: 'Courier New', Courier, monospace;
  padding: 1rem;
  border-radius: 8px;
  max-height: 250px;
  overflow-y: auto;
}

canvas.interactive-canvas {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* ======================================================
   Course Sidebar Drawer System (Repliable à la Demande)
   ====================================================== */
.course-sidebar {
  position: fixed;
  top: 0;
  left: -320px;
  width: 320px;
  height: 100vh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Empêche tout débordement de la barre latérale hors écran */
  z-index: 1050;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 5px 0 25px rgba(0, 0, 0, 0.18);
}

.sidebar-top {
  flex-shrink: 0 !important;
}

.sidebar-middle {
  flex: 1 1 auto !important;
  min-height: 0 !important; /* RÈGLE CRITIQUE FLEXBOX : force le confinement strict dans la hauteur restante */
  overflow-y: auto !important;
}

.sidebar-bottom {
  flex-shrink: 0 !important;
}

.course-sidebar.open {
  left: 0 !important;
}


.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(3px);
  z-index: 1040;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.sidebar-backdrop.show {
  opacity: 1;
  visibility: visible;
}

.btn-toggle-sidebar {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 1030;
  border-radius: 30px;
  padding: 10px 18px;
  font-weight: 700;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.btn-toggle-sidebar:hover {
  transform: scale(1.06);
}

.sidebar-link {
  transition: all 0.2s ease;
}

.sidebar-link:hover {
  background-color: #f1f5f9;
  color: #0284c7 !important;
}

/* Custom Scrollbar exclusivement réservée à la Ligne 2 (Zone Centrale .sidebar-middle) */
.sidebar-middle::-webkit-scrollbar {
  width: 6px;
}

.sidebar-middle::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.sidebar-middle::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 4px;
}

.sidebar-middle::-webkit-scrollbar-thumb:hover {
  background-color: #0284c7;
}

.sidebar-middle {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f1f5f9;
}

/* ======================================================
   Print Mode Stylesheet (@media print)
   - Toutes les sections et articles sont visibles
   - Les simulations et widgets interactifs sont masqués
   ====================================================== */
@media print {
  /* Preservation exacte de toutes les couleurs de texte et d'arrière-plan */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  /* 1. Afficher TOUS les articles et TOUTES les sections */
  main,
  main article,
  main section,
  main article.d-none,
  main section.d-none {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  /* 2. Cacher uniquement les simulations, éditeurs, barres de nav, boutons et éléments interactifs */
  nav,
  footer,
  #course-sidebar,
  #sidebar-backdrop,
  #btn-toggle-sidebar,
  .interactive-box,
  .interactive-canvas,
  canvas,
  .monaco-editor-wrapper,
  .monaco-target,
  .btn,
  button,
  .qcm-feedback,
  .step-tracer-container,
  .d-print-none {
    display: none !important;
  }

  /* 3. Conservation du formatage et des couleurs */
  body {
    font-size: 12pt;
  }

  main {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
  }

  section {
    page-break-inside: avoid;
    margin-bottom: 2rem !important;
    border-bottom: 1px dashed #cbd5e1;
    padding-bottom: 1rem;
  }

  h1, h2, h3, h4 {
    page-break-after: avoid;
  }

  pre, code {
    white-space: pre-wrap !important;
  }
}

/* ======================================================
   Monaco Editor Full-Height & Layout Fixes
   ====================================================== */
.monaco-toolbar {
  height: 44px !important;
  max-height: 44px !important;
  flex: 0 0 44px !important;
  flex-grow: 0 !important;
  flex-shrink: 0 !important;
}

.monaco-editor-wrapper {
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.monaco-editor-wrapper.h-100,
.monaco-editor-wrapper[data-full-height="true"] {
  flex: 1 1 0% !important;
  min-height: 0 !important;
  height: 100% !important;
  margin: 0 !important;
}

.monaco-code-area {
  position: relative !important;
  flex: 1 1 0% !important;
  min-height: 0 !important;
  height: 100% !important;
  width: 100% !important;
}

.monaco-code-area .monaco-editor,
.monaco-code-area .monaco-editor .overflow-guard {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
}

/* Masquage strict de tout conteneur Canvas/Toolbar injecté par Matplotlib */
div[id^="matplotlib_"],
div[id*="matplotlib"],
.pyodide-mpl-container {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  width: 0 !important;
  overflow: hidden !important;
}

/* Module 3 - Portes Logiques et Tables de Vérité */
.logic-gate-img {
  max-height: 95px;
  width: 100%;
  display: block;
  margin: 0 auto;
}

.logic-icon-sm {
  height: 16px;
  vertical-align: middle;
}

.logic-icon-md {
  height: 20px;
  vertical-align: middle;
}

.logic-icon-lg {
  height: 24px;
  vertical-align: middle;
}

.sim-led-img {
  height: 42px;
}

.gate-sim-box {
  min-height: 80px;
}

.th-gate-non {
  background-color: #dc2626 !important;
  color: #ffffff !important;
}

.th-gate-et {
  background-color: #16a34a !important;
  color: #ffffff !important;
}

.th-gate-ou {
  background-color: #0284c7 !important;
  color: #ffffff !important;
}

.th-input-col {
  width: 17%;
  background-color: #334155 !important;
  color: #ffffff !important;
}

.th-output-col-non {
  width: 22%;
  background-color: #dc2626 !important;
  color: #ffffff !important;
}

.th-output-col-et {
  width: 22%;
  background-color: #16a34a !important;
  color: #ffffff !important;
}

.th-output-col-ou {
  width: 22%;
  background-color: #0284c7 !important;
  color: #ffffff !important;
}

.table-dark-header {
  background-color: #0f172a !important;
  color: #ffffff !important;
}

/* Simulation Portes Logiques - Nœuds d'entrée cliquables */
.gate-sim-svg {
  max-height: 85px;
  width: 100%;
  display: block;
}

.gate-input-interactive {
  cursor: pointer;
  outline: none;
  transition: transform 0.15s ease;
}

.gate-input-interactive:hover .gate-node-circle {
  filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.9));
  stroke: #38bdf8 !important;
  stroke-width: 2.5 !important;
}

.gate-input-interactive:focus .gate-node-circle {
  outline: none;
  filter: drop-shadow(0 0 8px rgba(34, 197, 94, 0.9));
}

.gate-input-interactive:active {
  transform: scale(0.95);
}

.gate-hit-area {
  cursor: pointer;
}

.gate-toggle-btn {
  font-size: 0.8rem;
  padding: 0.2rem 0.55rem;
  border-radius: 0.375rem;
  transition: all 0.2s ease;
}

.gate-toggle-btn:hover {
  transform: translateY(-1px);
}











