/**
 * Styles d'impression pour les rapports de ventes
 * Optimisé pour l'impression PDF et papier
 */

/* ========================================
   MODE IMPRESSION ACTIVÉ (classe sur body)
   ======================================== */
body.printing-mode * {
  visibility: hidden !important;
}

body.printing-mode #report-content,
body.printing-mode #report-content * {
  visibility: visible !important;
}

body.printing-mode #report-content {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Masquer les éléments indésirables même dans #report-content */
body.printing-mode button,
body.printing-mode .btn,
body.printing-mode #reportTypeTabs,
body.printing-mode .nav-pills,
body.printing-mode #customPeriodFilter,
body.printing-mode .no-print {
  display: none !important;
  visibility: hidden !important;
}

/* ========================================
   RÈGLES GÉNÉRALES D'IMPRESSION
   ======================================== */
@media print {
  /* Reset général pour l'impression */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  body {
    margin: 0;
    padding: 0;
    background: white !important;
  }

  /* Masquer TOUT par défaut sauf #report-content */
  body * {
    visibility: hidden !important;
  }

  #report-content,
  #report-content * {
    visibility: visible !important;
  }

  /* Positionner #report-content pour qu'il prenne toute la page */
  #report-content {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
  }

  /* Masquer les éléments non imprimables */
  .sidebar,
  .navbar,
  .header-nav,
  .side-nav,
  .nav-pills,
  #reportTypeTabs,
  #customPeriodFilter,
  button,
  .btn,
  .no-print,
  .breadcrumb,
  .footer,
  [v-cloak],
  .ant-layout-sider,
  .ant-layout-header,
  .ant-menu,
  .page-header,
  script,
  noscript {
    display: none !important;
    visibility: hidden !important;
  }

  /* Conteneur principal du rapport */
  #report-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
  }

  .card {
    box-shadow: none !important;
    border: none !important;
    page-break-inside: avoid;
  }

  .card-header {
    background: white !important;
    border-bottom: 2px solid #333 !important;
    padding: 10px 0 !important;
  }

  .card-body {
    padding: 10px 0 !important;
  }

  /* ========================================
     EN-TÊTE DU RAPPORT
     ======================================== */
  .card-header h1 {
    font-size: 18pt !important;
    color: #000 !important;
    margin-bottom: 5px !important;
  }

  .card-header small {
    font-size: 10pt !important;
    color: #333 !important;
  }

  /* ========================================
     CARTES STATISTIQUES (OVERVIEW)
     ======================================== */
  .row {
    display: flex !important;
    flex-wrap: wrap !important;
    page-break-inside: avoid;
  }

  .col-md-4,
  .col-md-6 {
    width: 33.333% !important;
    padding: 5px !important;
    page-break-inside: avoid;
  }

  .col-md-8 {
    width: 66.666% !important;
    padding: 5px !important;
  }

  .col-md-6 {
    width: 50% !important;
  }

  .col-12 {
    width: 100% !important;
  }

  /* Cartes de statistiques */
  .card.h-100 {
    border: 1px solid #ddd !important;
    margin-bottom: 10px !important;
    padding: 10px !important;
  }

  .media.align-items-center i {
    font-size: 24pt !important;
  }

  .media h3 {
    font-size: 16pt !important;
    color: #000 !important;
  }

  .media p {
    font-size: 9pt !important;
    color: #666 !important;
  }

  .badge {
    font-size: 8pt !important;
    padding: 2px 6px !important;
  }

  /* ========================================
     GRAPHIQUES CHART.JS
     ======================================== */
  .chart-container {
    page-break-inside: avoid;
    margin: 15px 0 !important;
    padding: 10px !important;
    border: 1px solid #ddd !important;
  }

  .chart-container strong {
    font-size: 11pt !important;
    color: #000 !important;
    display: block;
    margin-bottom: 10px !important;
  }

  canvas.chart {
    max-height: 300px !important;
    page-break-inside: avoid;
  }

  /* Graphiques spécifiques */
  #per-hour-chart,
  #per-day-chart,
  #per-method-chart,
  #daily-growth-chart,
  #monthly-evolution-chart,
  #avg-basket-chart {
    page-break-inside: avoid;
  }

  /* ========================================
     TABLEAUX
     ======================================== */
  .table {
    font-size: 9pt !important;
    border-collapse: collapse !important;
    width: 100% !important;
    page-break-inside: auto;
  }

  .table thead {
    background: #f5f5f5 !important;
    border-bottom: 2px solid #333 !important;
  }

  .table thead th {
    padding: 8px !important;
    font-weight: bold !important;
    color: #000 !important;
    border: 1px solid #ddd !important;
  }

  .table tbody tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  .table tbody td {
    padding: 6px !important;
    border: 1px solid #ddd !important;
    color: #000 !important;
  }

  .table-hover tbody tr:hover {
    background: transparent !important;
  }

  /* Images dans les tableaux */
  .avatar.avatar-image,
  .avatar.avatar-lg {
    width: 30px !important;
    height: 30px !important;
  }

  .avatar img {
    max-width: 30px !important;
    max-height: 30px !important;
  }

  /* ========================================
     ANALYSE CLIENT ET SECTIONS SPÉCIALES
     ======================================== */
  .shadow-sm {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
  }

  h5.font-weight-bold {
    font-size: 12pt !important;
    color: #000 !important;
    border-bottom: 1px solid #ddd !important;
    padding-bottom: 5px !important;
  }

  .text-center h2 {
    font-size: 20pt !important;
    color: #000 !important;
  }

  .text-center p {
    font-size: 10pt !important;
    color: #666 !important;
  }

  /* ========================================
     GESTION DES SAUTS DE PAGE
     ======================================== */
  .mb-5,
  .mb-4,
  .mb-3 {
    page-break-inside: avoid;
  }

  /* Force saut de page avant certaines sections */
  .row.mb-5 {
    page-break-before: auto;
  }

  /* Éviter les sauts au milieu d'une carte */
  .card-body .row {
    page-break-inside: avoid;
  }

  /* ========================================
     COULEURS OPTIMISÉES POUR L'IMPRESSION
     ======================================== */
  .text-success {
    color: #28a745 !important;
  }

  .text-primary {
    color: #007bff !important;
  }

  .text-warning {
    color: #ffc107 !important;
  }

  .text-danger {
    color: #dc3545 !important;
  }

  .text-info {
    color: #17a2b8 !important;
  }

  .text-secondary {
    color: #6c757d !important;
  }

  .text-muted {
    color: #6c757d !important;
  }

  /* Badges avec bordures pour meilleure visibilité en N&B */
  .badge-warning {
    border: 1px solid #ffc107 !important;
  }

  /* ========================================
     ICÔNES ANTICON / FONTAWESOME
     ======================================== */
  .anticon,
  .fa,
  .fas {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* ========================================
     OPTIMISATIONS SPÉCIFIQUES
     ======================================== */
  
  /* Pas de caption vide visible */
  caption {
    font-size: 9pt !important;
    color: #666 !important;
    padding: 10px !important;
  }

  /* Marges et espacement */
  .m-l-15,
  .m-l-10 {
    margin-left: 10px !important;
  }

  .m-b-0 {
    margin-bottom: 0 !important;
  }

  .m-b-3 {
    margin-bottom: 8px !important;
  }

  /* Alignement */
  .text-right {
    text-align: right !important;
  }

  .text-center {
    text-align: center !important;
  }

  /* ========================================
     LAYOUT PRINCIPAL
     ======================================== */
  .ant-layout,
  .ant-layout-content {
    background: white !important;
  }

  main {
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Conteneur Vue.js */
  [v-cloak] {
    display: none !important;
  }

  #daily-sales,
  #weekly-sales,
  #monthly-sales,
  #annual-sales {
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* ========================================
     OPTIMISATIONS POUR PDF
     ======================================== */
  @page {
    margin: 1.5cm 1cm;
    size: A4 portrait;
  }

  /* En-tête et pied de page personnalisés si nécessaire */
  @page :first {
    margin-top: 1cm;
  }

  /* ========================================
     RESPONSIVE POUR DIFFÉRENTES TAILLES
     ======================================== */
  .d-flex {
    display: flex !important;
  }

  .flex-wrap {
    flex-wrap: wrap !important;
  }

  .justify-content-between {
    justify-content: space-between !important;
  }

  .justify-content-around {
    justify-content: space-around !important;
  }

  .align-items-center {
    align-items: center !important;
  }
}

/* ========================================
   MODE APERÇU AVANT IMPRESSION
   ======================================== */
body.print-preview {
  background: #f5f5f5 !important;
}

body.print-preview * {
  visibility: hidden !important;
}

body.print-preview #report-content,
body.print-preview #report-content * {
  visibility: visible !important;
}

body.print-preview .sidebar,
body.print-preview .navbar,
body.print-preview .header-nav,
body.print-preview .side-nav,
body.print-preview .nav-pills,
body.print-preview #reportTypeTabs,
body.print-preview #customPeriodFilter,
body.print-preview .breadcrumb,
body.print-preview .footer,
body.print-preview .ant-layout-sider,
body.print-preview .ant-layout-header,
body.print-preview button,
body.print-preview .btn {
  display: none !important;
  visibility: hidden !important;
}

body.print-preview #report-content {
  max-width: 210mm;
  margin: 20px auto;
  background: white;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  padding: 20px;
  position: relative;
  visibility: visible !important;
}

