/* 
 * Print CSS - Optimisation pour l'impression
 * Green UX : Réduit l'encre, le papier et améliore la lisibilité
 */

@media print {
  /* === Reset et optimisation générale === */
  * {
    background: white !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  /* === Optimisation de la page === */
  @page {
    margin: 2cm;
    size: A4;
  }

  body {
    font-size: 12pt;
    line-height: 1.5;
    color: #000;
    background: #fff;
  }

  /* === Cacher les éléments non nécessaires à l'impression === */
  nav,
  header,
  footer,
  aside,
  .navbar,
  .sidebar,
  .no-print,
  .btn,
  button,
  .settings-panel,
  .navbar-vertical,
  .navbar-top,
  [class*="navbar"],
  [class*="sidebar"],
  [class*="offcanvas"],
  .modal-backdrop,
  .toast,
  .alert-dismissible .btn-close,
  .dropdown,
  .pagination,
  .breadcrumb,
  .tooltip,
  .popover,
  .print-hide {
    display: none !important;
  }

  /* === Optimisation du contenu principal === */
  .container,
  .container-fluid,
  main,
  .content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
  }

  /* === Typographie optimisée === */
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
    page-break-inside: avoid;
    font-weight: bold;
    color: #000;
  }

  h1 { font-size: 24pt; margin-top: 0; }
  h2 { font-size: 18pt; }
  h3 { font-size: 14pt; }
  h4, h5, h6 { font-size: 12pt; }

  /* === Paragraphes === */
  p {
    orphans: 3;
    widows: 3;
    page-break-inside: avoid;
  }

  /* === Liens === */
  a {
    text-decoration: underline;
    color: #000 !important;
  }

  /* Afficher l'URL après les liens (utile pour les documents imprimés) */
  a[href^="http"]:after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    font-style: italic;
  }

  /* Ne pas afficher l'URL pour les liens internes */
  a[href^="#"]:after,
  a[href^="/"]:after {
    content: "";
  }

  /* === Tableaux === */
  table {
    width: 100%;
    border-collapse: collapse;
    page-break-inside: avoid;
  }

  thead {
    display: table-header-group;
  }

  tr {
    page-break-inside: avoid;
  }

  th, td {
    border: 1px solid #000;
    padding: 8px;
    text-align: left;
  }

  th {
    background: #f0f0f0 !important;
    font-weight: bold;
  }

  /* === Images === */
  img {
    max-width: 100% !important;
    page-break-inside: avoid;
    page-break-after: avoid;
    /* Convertir en niveaux de gris pour économiser l'encre */
    filter: grayscale(100%);
    -webkit-filter: grayscale(100%);
  }

  /* Garder les logos en couleur si nécessaire */
  .logo img,
  .print-color {
    filter: none !important;
    -webkit-filter: none !important;
  }

  /* === Listes === */
  ul, ol {
    page-break-inside: avoid;
  }

  /* === Cartes et panneaux === */
  .card,
  .panel,
  .modal-content {
    border: 1px solid #000 !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    margin-bottom: 1cm;
  }

  .card-header {
    background: #f0f0f0 !important;
    border-bottom: 1px solid #000 !important;
    font-weight: bold;
  }

  /* === Formulaires === */
  input,
  textarea,
  select {
    border: 1px solid #000 !important;
    background: white !important;
  }

  /* === Badges et labels (simplifier) === */
  .badge {
    display: inline !important;
    border: 1px solid #000 !important;
    background: white !important;
    color: #000 !important;
    padding: 2px 4px !important;
  }

  /* === Utilitaires d'impression === */
  .page-break {
    page-break-before: always;
  }

  .avoid-break {
    page-break-inside: avoid;
  }

  /* === Optimisation spécifique GRU === */
  .timeline-item {
    page-break-inside: avoid;
    margin-bottom: 0.5cm;
  }

  .chat-message {
    border: 1px solid #ccc !important;
    page-break-inside: avoid;
  }

  /* Simplifier les icônes FontAwesome */
  .fa, .fas, .far, .fab {
    font-size: 0 !important;
  }

  /* === Footer personnalisé pour l'impression === */
  body:after {
    content: "Imprimé le " attr(data-print-date);
    display: block;
    text-align: center;
    font-size: 10pt;
    color: #666;
    margin-top: 2cm;
  }
}

/* === Styles spécifiques au calendrier === */

/* Masquer les éléments avec la classe print-hide */
.print-hide {
  display: none !important;
}

/* Conserver les couleurs pour le calendrier FullCalendar */
.fc,
.fc *,
.fc-event,
.fc-event *,
.fc-timegrid-event,
.fc-timegrid-col-events {
  -webkit-print-color-adjust: exact !important;
  print-color-adjust: exact !important;
  color-adjust: exact !important;
}

/* Permettre les couleurs de fond sur les événements */
.fc-event {
  background: inherit !important;
  color: inherit !important;
}

.fc-event-main {
  color: white !important;
}

/* Calendrier en mode paysage */
.fc {
  min-width: auto !important;
}

/* Masquer le header du calendrier (boutons, filtres) mais pas les badges des guichets */
.fc .card-header {
  display: none !important;
}

/* Afficher tout le calendrier sans scroll */
.fc-scroller,
.fc-scroller-liquid,
.fc-scroller-liquid-absolute,
.fc-timegrid-body,
.fc-timegrid-slots,
.fc-timegrid-cols {
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
  position: relative !important;
}

.fc-view-harness,
.fc-view-harness-active,
.fc-timegrid {
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
}

.fc-scrollgrid,
.fc-scrollgrid-liquid {
  height: auto !important;
}

.fc-scrollgrid-section,
.fc-scrollgrid-section-body,
.fc-scrollgrid-section-liquid {
  height: auto !important;
}

/* S'assurer que le conteneur du calendrier est aussi en auto */
.fc-timegrid-slot {
  height: 2.5em !important;
}

/* Page en mode paysage pour le calendrier */
@page {
  size: A4 landscape;
  margin: 1cm;
}

/* === Media queries spécifiques === */

/* Pour impression en noir et blanc */
@media print and (monochrome) {
  * {
    color: #000 !important;
    background: #fff !important;
  }
}

/* Pour petits formats (économie de papier) */
@media print and (max-width: 21cm) {
  body {
    font-size: 10pt;
  }
  
  h1 { font-size: 18pt; }
  h2 { font-size: 14pt; }
  h3 { font-size: 12pt; }
}
