@import url("https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&family=Momo+Trust+Display&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Lato", sans-serif;
  min-height: 100vh;
  padding: 20px;
 display: flex;
 flex-direction: column;
  
}

.container {
  margin: 0 auto;
  width: 100%;
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.header {
  background:black;
  color: white;
  padding: 30px;
  text-align: center;
}

.header h1 {
  font-size: 3em;
  font-weight: 900;
  margin-bottom: 10px;
}

.status {
  display: inline-block;
  padding: 5px 15px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  font-size: 0.9em;
  margin-top: 10px;
}

.tabs {
  display: flex;
  background: #f3f4f6;
  border-bottom: 2px solid #e5e7eb;
  flex-wrap: wrap;
}

.tab {
  flex: 1;
  min-width: 100px;
  padding: 15px;
  text-align: center;
  cursor: pointer;
  background: none;
  border: none;
  font-size: 1em;
  color: #6b7280;
  transition: all 0.3s;
}

.tab.active {
  background: white;
  color: #000000;
  font-weight: bold;
}

.content {
  padding: 30px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  margin-bottom: 5px;
  color: #374151;
  font-weight: 500;
}

input,
select {
  width: 100%;
  padding: 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 1em;
  transition: border-color 0.3s;
}

input:focus,
select:focus {
  outline: none;
  border-color: #4f46e5;
}

.btn {
  padding: 12px 30px;
  background:  #000000;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1em;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.btn-sm {
  padding: 6px 15px;
  font-size: 0.8em;
}

.card {
  background: #f9fafb;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.card h3 {
  color: #4f46e5;
  margin-bottom: 15px;
}

.grades-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 15px;
  margin-top: 15px;
}

.grade-input {
  display: flex;
  flex-direction: column;
}

.grade-input label {
  font-size: 0.9em;
  margin-bottom: 5px;
}

.results {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border-radius: 12px;
  padding: 25px;
  margin-top: 20px;
}

.results h3 {
  margin-bottom: 15px;
  font-size: 1.5em;
}

.result-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.result-item:last-child {
  border-bottom: none;
}

.result-value {
  font-weight: bold;
  font-size: 1.2em;
}

.student-list {
  list-style: none;
}

.subjects-section {
  margin-top: 20px;
}

.subject-name {
  font-weight: 500;
}

.subject-item {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  align-items: center;
}

.subject-item input {
  flex: 2;
}

.subject-item input[type="number"] {
  flex: 1;
  max-width: 80px;
  text-align: center;
}

.btn-add {
  background:  #006443;
  padding: 8px 20px;
  font-size: 0.9em;
}

/* --- Dashboard Card Styles --- */

.class-cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.class-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  transition: all 0.3s;
  overflow: hidden;
}

.class-card:hover {
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
  border-color: #4f46e5;
}

/* Style spécifique pour les cartes de gestion (Classes & Élèves) */
.class-card-management {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.3s;
}

.class-card-management:hover {
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
  border-color: #4f46e5;
}
/* Fin Style spécifique pour les cartes de gestion */

.class-card .card-summary,
.class-card-management .card-summary {
  padding: 20px;
  background: #f9fafb;
  flex-grow: 1;
}

.class-card h3,
.class-card-management h3 {
  color: #4f46e5;
  margin-bottom: 10px;
  font-size: 1.4em;
}

.class-card p,
.class-card-management p {
  margin: 5px 0;
  color: #374151;
  font-size: 0.95em;
}

.class-card span,
.class-card-management span {
  font-weight: bold;
  margin-left: 5px;
}

.class-card .avg-value.pass,
.avg-value.pass {
  /* Ajout pour la modale de détails */
  color: #10b981; /* Vert pour réussite (>= 10) */
}

.class-card .avg-value.fail,
.avg-value.fail {
  /* Ajout pour la modale de détails */
  color: #ef4444; /* Rouge pour échec (< 10) */
}

/* --- Student Average Display (Used in Modal) --- */

.student-avg-item {
  display: flex;
  justify-content: space-between;
  align-items: center; /* Ajout pour aligner le bouton */
  padding: 10px 0;
  border-bottom: 1px dashed #e5e7eb;
  font-size: 0.95em;
  cursor: pointer; /* Rendre l'élément cliquable */
  transition: background-color 0.2s;
}

.student-avg-item:hover {
  background-color: #f8f8ff; /* Effet visuel au survol */
}

.student-avg-item:last-child {
  border-bottom: none;
}

.student-avg-name {
  font-weight: 600;
  color: #1f2937;
  flex-grow: 1;
}

.student-avg-score {
  font-weight: 700;
  margin-left: 10px;
}

/* --- Modal Styles --- */

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  background-color: #fefefe;
  margin: 5% auto;
  padding: 30px;
  width: 90%;
  max-width: 600px;
  border-radius: 12px;
  position: relative;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  animation-name: animatetop;
  animation-duration: 0.4s;
}

@keyframes animatetop {
  from {
    top: -300px;
    opacity: 0;
  }
  to {
    top: 5%;
    opacity: 1;
  }
}

.close-btn {
  color: #aaa;
  float: right;
  font-size: 32px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  margin-top: -15px;
  margin-right: -10px;
}

.close-btn:hover,
.close-btn:focus {
  color: #4f46e5;
  text-decoration: none;
  cursor: pointer;
}

#modalTitle {
  color: #4f46e5;
  margin-bottom: 20px;
  font-size: 1.5em;
  border-bottom: 2px solid #eef2ff;
  padding-bottom: 10px;
}

#modalBody ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* --- Footer Styling et Responsive (inchangés) --- */

.app-footer {
  width: 100%;
  padding: 15px 20px;
  background-color: #333;
  color: #f4f4f4;
  text-align: center;
  font-size: 0.85em;
  box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
  margin-top: 40px;
}

.footer-content p {
  margin: 5px 0;
  line-height: 1.4;
}

@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .header h1 {
    font-size: 2em;
  }

  .content {
    padding: 15px;
  }

  .tab {
    flex-basis: 50%;
    min-width: 0;
    padding: 10px 5px;
    font-size: 0.9em;
  }

  .grades-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .subject-item {
    flex-direction: row;
  }

  .subject-item input {
    padding: 10px;
  }

  .subject-item input[type="number"] {
    max-width: 60px;
  }

  .footer-content {
    flex-direction: column;
  }
  .footer-content p {
    text-align: center !important;
  }

  .modal-content {
    margin: 10px auto;
    width: 95%;
  }
}

@media (min-width: 768px) {
  .app-footer {
    padding: 20px 40px;
  }

  .footer-content {
    display: flex;
    justify-content: space-between;
    max-width: 1000px;
    margin: 0 auto;
  }

  .footer-content p {
    margin: 0;
    text-align: left;
  }

  .footer-content p:last-child {
    text-align: right;
  }
}

/* --- STYLES D'IMPRESSION (PRINT MEDIA QUERY) --- */
@media print {
  /* 1. Cacher les éléments non essentiels */
  .header,
  .tabs,
  .app-footer,
  .form-group,
  .no-print,
  #selectStudentResults,
  .loading-message,
  .btn:not(.print-button) {
    display: none !important;
  }

  /* Le bouton d'impression lui-même est caché une fois le dialogue d'impression ouvert */
  .print-button {
    display: none !important;
  }

  /* 2. Réinitialiser le conteneur de l'application pour la page entière */
  body {
    background: white;
    padding: 0;
  }
  .container {
    box-shadow: none !important;
    margin: 0 !important;
    max-width: none !important;
    width: 100% !important;
  }
  .content,
  #resultsContainer {
    padding: 10px;
  }

  /* 3. Style des cartes et des tableaux */
  .card {
    border: 1px solid #000 !important;
    box-shadow: none !important;
    margin-bottom: 20px !important;
    page-break-inside: avoid; /* Empêche une carte d'être coupée au milieu */
  }

  table {
    width: 100% !important;
    border-collapse: collapse;
  }
  th,
  td {
    border: 1px solid #000 !important;
    padding: 5px !important;
    color: black !important; /* Force la couleur noire */
  }

  /* 4. Gestion des signatures */
  .teacher-signature {
    width: 100px; /* Espace pour la signature dans le tableau annuel */
    height: 30px;
    /* Laisser vide pour la signature manuelle */
  }
  .teacher-signature-small {
    width: 80px; /* Espace pour la signature dans le tableau trimestriel */
    height: 20px;
    /* Laisser vide pour la signature manuelle */
  }

  /* 5. Disposition des sections Trimestres/Séquences */
  .trimester-breakdown,
  .sequence-breakdown {
    display: block !important; /* Empile les cartes horizontalement */
    overflow-x: visible !important;
    padding-bottom: 0 !important;
  }
  .trim-card {
    min-width: 100% !important;
    margin-bottom: 30px !important;
    page-break-after: always; /* Force un saut de page après chaque trimestre */
  }
  /* Sauf pour le dernier trimestre et le résumé annuel */
  .trim-card:last-of-type {
    page-break-after: auto;
  }

  /* 6. Bloc de signature du Censeur */
  .signature-block {
    display: flex;
    justify-content: space-around;
    margin-top: 50px;
    padding: 10px 0;
    /* Pas de bordure pour éviter la répétition du saut de page */
    page-break-before: auto;
    page-break-inside: avoid;
  }
  .signature-item {
    text-align: center;
    width: 30%;
    font-size: 0.9em;
  }
  .signature-line {
    height: 1px;
    background: #000;
    margin: 15px 0 5px 0;
    border: none;
  }
}

/* --- NOUVEAU: Notification System (Toast) --- */
#notification-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column-reverse; /* Pour que le plus récent soit en haut */
}

.toast {
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    margin-top: 10px;
    opacity: 0;
    transition: opacity 0.5s, transform 0.5s;
    transform: translateX(-100%); /* Commence hors écran à gauche */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    min-width: 250px;
    font-weight: bold;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.success {
    background-color: #4CAF50; /* Vert pour succès */
}

.toast.error {
    background-color: #f44336; /* Rouge pour erreur */
}

.toast.info {
    background-color: #2196F3; /* Bleu pour information */
}
