@import url('https://fonts.googleapis.com/css2?family=Fira+Code&family=Orbitron:wght@600&family=Lato:wght@400;700&display=swap');

:root {
  --python-blue: #306998;
  --python-yellow: #FFD43B;
  --bg-light: #ffffff;
  --accent-bg: rgba(48, 105, 152, 0.05);
  --code-bg: #f0f0f0;
  --yellow-bg: rgba(255, 212, 59, 0.15);
}

@media print {
  body { 
    margin: 0; 
    padding: 0;
    font-size: 7pt; /* Taille ultra-dense pour cheatsheet */
    line-height: 1.05; /* Interligne ultra-minimal */
  }
  /* Réserver de l'espace pour le footer template puppeteer */
  .container {
    padding-bottom: 10mm;
  }
  
  .container {
    max-width: none;
    margin: 0;
    padding: 0 0 12mm 0;
  }
  
  .columns-wrapper {
    gap: 1mm; /* Espacement minimal pour l'impression */
  }
  
  .column {
    gap: 0.05rem; /* Espacement ultra-minimal entre sections */
    background-color: rgba(248, 249, 250, 0.2); /* Fond gris très léger pour impression */
    padding: 0.1rem; /* Padding minimal pour impression */
  }
  
  section {
    page-break-inside: avoid;
    margin-bottom: 0.1em; /* Marge ultra-minimale */
    padding: 0.15rem; /* Padding ultra-minimal */
  }
  
  h1, h2, h3 {
    page-break-after: avoid;
  }
  
  h1 {
    font-size: 0.9rem; /* Taille ultra-réduite pour cheatsheet */
    margin-bottom: 0.1rem;
  }
  
  h2 {
    font-size: 0.7rem; /* Taille ultra-réduite pour cheatsheet */
    padding: 0.08rem 0.2rem 0.08rem 1rem; /* Padding ultra-minimal */
    margin-bottom: 0.05rem;
  }
  
  h2::before {
    left: 0.25rem;
    font-size: 0.6rem;
  }
  
  pre {
    page-break-inside: avoid;
    font-size: 3pt; /* Taille ultra-compacte pour le code */
    padding: 0.08rem; /* Padding ultra-minimal */
    margin: 0.03rem 0;
    line-height: 0.95; /* Interligne ultra-minimal */
  }
  
  pre::before {
    font-size: 2.5pt; /* Taille ultra-réduite */
    margin-bottom: 0.01rem;
  }
  
  ul {
    padding-left: 0.6rem; /* Padding ultra-minimal */
    margin: 0.05rem 0;
  }
  
  li {
    margin-bottom: 0.02rem; /* Espacement ultra-minimal entre éléments */
    font-size: 6pt; /* Taille ultra-dense */
  }
  
  .footnote {
    font-size: 5pt; /* Taille ultra-dense */
    margin-top: 0.05rem;
  }
}

@page {
  size: A4;
  margin: 0; /* Suppression des marges @page */
}

/* Réinitialisation globale et fond par défaut */
html {
  margin: 0;
  padding: 0;
  background-color: white;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  width: 100%;
  height: 100%;
}


/*
 * Technique robuste pour afficher un fond sur chaque page d'un PDF.
 * On utilise un pseudo-élément 'fixed' qui se répète sur chaque page.
 */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('../img/fond2.png') no-repeat top center;
  background-size: cover;
  z-index: -1;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Lato', sans-serif;
  font-size: 12px; /* Taille de base réduite pour plus de densité */
  line-height: 1.2; /* Interligne réduit */
  color: #333;
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Le body doit être transparent pour que le pseudo-élément ::before (avec l'image de fond)
     qui est positionné en arrière-plan (z-index: -1) soit visible. */
  background-color: transparent;
}


header {
  text-align: center;
  margin-bottom: 1rem;
}

h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.2rem; /* Taille drastiquement réduite */
  color: var(--python-blue);
  text-align: center;
  margin: 0.3rem 0; /* Marges réduites */
}

/* Layout principal pour l'affichage web des fiches - OPTIMISÉ DENSITÉ */
.container {
  max-width: 210mm; /* Largeur A4 */
  min-height: 297mm; /* Hauteur A4 pour les fiches */
  margin: 0 auto; /* Centrage sur le web */
  padding: 0; /* Suppression du padding pour taille exacte A4 */
  display: flex;
  flex-direction: column;
  gap: 0.2rem; /* Espacement minimal */
  box-sizing: border-box;
}

/* Wrapper pour les deux colonnes */
.columns-wrapper {
  display: flex;
  gap: 2mm; /* Espacement visuel entre colonnes */
  align-items: flex-start;
  min-height: 0; /* Permet aux colonnes de se rétrécir */
}

/* Colonnes de taille identique */
.column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem; /* Espacement minimal entre sections */
  min-width: 0; /* Permet aux colonnes de se rétrécir */
  background-color: rgba(248, 249, 250, 0.3); /* Fond gris très léger */
  padding: 0.3rem; /* Padding léger pour le fond */
  border-radius: 4px; /* Coins légèrement arrondis */
}

section {
  background: var(--accent-bg);
  padding: 0.4rem; /* Padding minimal pour densité maximale */
  border-radius: 4px; /* Border radius minimal */
  box-shadow: 0 0 3px rgba(0,0,0,0.05); /* Ombre très réduite */
  width: 100%;
  box-sizing: border-box;
  break-inside: avoid; /* Évite la coupure des sections */
  margin-bottom: 0.2rem; /* Marge minimale */
}

h2 {
  color: #000;
  font-size: 0.9rem; /* Taille drastiquement réduite */
  margin: 0 0 0.3rem 0; /* Marges minimales */
  font-weight: 700;
  font-family: 'Orbitron', sans-serif;
  position: relative;
  padding: 0.2rem 0.4rem 0.2rem 1.5rem; /* Padding minimal */
  background: var(--yellow-bg);
  border-left: 0.3rem solid var(--python-yellow); /* Bordure réduite */
  border-radius: 3px; /* Border radius minimal */
  box-shadow: inset 0 0 0.1em rgba(255, 212, 59, 0.8);
}

h2::before {
  content: attr(data-icon);
  position: absolute;
  left: 0.4rem; /* Position ajustée */
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem; /* Taille réduite */
}

pre {
  background: var(--code-bg);
  padding: 0.2rem; /* Padding encore plus minimal */
  border-radius: 2px; /* Border radius minimal */
  overflow-x: auto;
  font-family: 'Fira Code', monospace;
  font-size: 0.6rem; /* Taille ultra-réduite pour le code */
  position: relative;
  margin: 0.1rem 0; /* Marges minimales */
  line-height: 1.1; /* Interligne réduit */
}

pre::before {
  content: "root@python:~$ ";
  color: #555;
  display: block;
  margin-bottom: 0.05rem; /* Marge minimale */
  font-size: 0.5rem; /* Taille ultra-réduite */
}

code {
  font-family: 'Fira Code', monospace;
}

ul {
  padding-left: 1rem; /* Padding réduit */
  margin: 0.2rem 0; /* Marges minimales */
}

li {
  margin-bottom: 0.1rem; /* Espacement minimal entre éléments */
  font-size: 0.9rem; /* Taille légèrement réduite */
}

.footnote {
  text-align: center;
  font-size: 0.7rem; /* Taille réduite */
  margin-top: 0.3rem; /* Marge minimale */
  color: #555;
  width: 100%;
}

/* Footer pour les fiches HTML */
.fiche-footer {
  margin-top: auto;
  padding: 1rem 0;
  background-color: rgba(248, 249, 250, 0.8);
  border-top: 1px solid #e9ecef;
  text-align: center;
  font-size: 0.8rem;
  color: #6c757d;
}

.footer-content {
  max-width: 210mm;
  margin: 0 auto;
  padding: 0 1rem;
}

.footer-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

@media screen and (max-width: 768px) {
  .footer-info {
    flex-direction: column;
    text-align: center;
  }
}

/* Responsive design pour les petits écrans */
@media screen and (max-width: 768px) {
  .container {
    padding: 0 5px; /* Padding encore plus réduit sur mobile */
  }
  
  .columns-wrapper {
    flex-direction: column; /* Passage en une colonne sur mobile */
    gap: 0.2rem;
  }
  
  .column {
    gap: 0.2rem;
  }
  
  section {
    padding: 0.3rem; /* Padding minimal sur mobile */
  }
  
  h1 {
    font-size: 1rem; /* Taille réduite sur mobile */
  }
  
  h2 {
    font-size: 0.8rem; /* Taille réduite sur mobile */
  }
  
  pre {
    font-size: 0.5rem; /* Code ultra-petit sur mobile */
    padding: 0.15rem;
  }
}
