/* ==================================== */
/* PRINT STYLES - PARTOGRAMME           */
/* Phase 15 - Impression A4             */
/* ==================================== */

@media print {
  /* ============================================
     PAGE SETUP - A4
     ============================================ */

  @page {
    size: A4;
    margin: 15mm 10mm 15mm 10mm;
  }

  /* ============================================
     RESET POUR IMPRESSION
     ============================================ */

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  html, body {
    width: 210mm;
    height: auto;
    margin: 0;
    padding: 0;
    font-size: 10pt;
    line-height: 1.4;
    color: #000 !important;
    background: #fff !important;
  }

  /* ============================================
     MASQUER ELEMENTS NON IMPRIMABLES
     ============================================ */

  /* Navigation et controles */
  .nav-tabs,
  .view-controls,
  .view-toggles,
  .btn-add-observation,
  .btn-primary,
  .btn-secondary,
  .btn-close,
  .btn-toggle,
  .theme-toggle,
  .observation-panel,
  .form-actions,
  .postpartum-actions,
  .legend-toggle,
  .action-wheel,
  .modal-overlay {
    display: none !important;
  }

  /* Elements interactifs */
  input,
  select,
  textarea,
  button {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  /* Afficher les valeurs au lieu des champs */
  input:not([type="checkbox"]):not([type="radio"]),
  select {
    appearance: none;
    -webkit-appearance: none;
    padding: 0 !important;
    min-height: auto !important;
  }

  /* ============================================
     LAYOUT IMPRESSION
     ============================================ */

  .partogramme-main {
    padding: 0 !important;
    display: block !important;
  }

  .panels-container {
    position: static !important;
    overflow: visible !important;
  }

  .workflow-panel {
    position: static !important;
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto !important;
    page-break-inside: avoid;
    break-inside: avoid;
    margin-bottom: 20mm;
    border: none !important;
    padding: 0 !important;
    background: transparent !important;
  }

  /* Afficher tous les panels */
  .workflow-panel {
    display: block !important;
  }

  /* ============================================
     TITRES ET EN-TETES
     ============================================ */

  .panel-header {
    border-bottom: 2pt solid #000;
    padding-bottom: 3mm;
    margin-bottom: 5mm;
  }

  .panel-header h2 {
    font-size: 14pt;
    font-weight: bold;
    margin: 0 0 2mm 0;
  }

  .panel-header p {
    font-size: 9pt;
    color: #666;
  }

  .panel-header-row {
    flex-direction: row;
  }

  /* ============================================
     FORMULAIRES ET SECTIONS
     ============================================ */

  .form-section {
    border: 1pt solid #ccc;
    padding: 4mm;
    margin-bottom: 4mm;
    page-break-inside: avoid;
    break-inside: avoid;
    background: transparent !important;
  }

  .form-section legend {
    font-size: 10pt;
    font-weight: bold;
    padding: 0 2mm;
    background: #fff;
  }

  .form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3mm 5mm;
  }

  .edit-group {
    margin-bottom: 2mm;
  }

  .edit-group label {
    font-size: 8pt;
    font-weight: 500;
    color: #333;
    text-transform: uppercase;
  }

  /* ============================================
     TABLEAUX
     ============================================ */

  .table-responsive {
    overflow: visible;
    border: 1pt solid #000;
  }

  .chrono-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9pt;
  }

  .chrono-table th,
  .chrono-table td {
    border: 0.5pt solid #ccc;
    padding: 2mm;
    text-align: left;
  }

  .chrono-table th {
    background: #f0f0f0 !important;
    font-weight: bold;
    font-size: 8pt;
  }

  .chrono-table tr:nth-child(even) {
    background: #fafafa !important;
  }

  /* Masquer colonne Actions */
  .chrono-table th:last-child,
  .chrono-table td:last-child {
    display: none;
  }

  /* ============================================
     GRAPHIQUE SVG PARTOGRAMME
     ============================================ */

  .graph-wrapper {
    width: 100%;
    height: auto;
    overflow: visible;
    border: 1pt solid #000;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  #partogram-svg {
    width: 100%;
    height: auto;
    max-height: 120mm;
  }

  .graph-legend {
    display: flex;
    justify-content: center;
    gap: 5mm;
    margin-top: 3mm;
    font-size: 8pt;
  }

  .legend-item {
    display: flex;
    align-items: center;
    gap: 2mm;
  }

  .legend-events {
    display: none;
  }

  /* ============================================
     CARTES ET INDICATEURS
     ============================================ */

  .bebe-rcf-card,
  .postpartum-hemorragie-card {
    border: 1pt solid #ccc;
    padding: 3mm;
    margin: 3mm 0;
    background: transparent !important;
  }

  /* ============================================
     COULEURS RCF POUR IMPRESSION
     ============================================ */

  .rcf-normal { color: #0a0 !important; }
  .rcf-faible-risque { color: #a80 !important; }
  .rcf-risque-intermediaire { color: #f60 !important; }
  .rcf-risque-important { color: #7c2d12 !important; }
  .rcf-risque-majeur { color: #c00 !important; }
  .rcf-incomplet { color: #475569 !important; }

  /* ============================================
     STATUTS HEMORRAGIE
     ============================================ */

  .postpartum-hemorragie-status.is-normal {
    color: #0a0 !important;
  }

  .postpartum-hemorragie-status.is-vigilance {
    color: #f60 !important;
  }

  .postpartum-hemorragie-status.is-alerte {
    color: #c00 !important;
  }

  .postpartum-hemorragie-status.is-severe {
    color: #c00 !important;
    font-weight: 700;
  }

  .postpartum-hemorragie-card.is-severe {
    border: 2pt solid #c00 !important;
  }

  /* ============================================
     SAUTS DE PAGE
     ============================================ */

  /* Eviter les coupures dans les sections */
  .form-section,
  .bebe-rcf-card,
  .postpartum-hemorragie-card,
  .table-responsive,
  .graph-wrapper {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* Nouvelle page avant certaines sections */
  #panel-partogramme,
  #panel-postpartum {
    page-break-before: always;
    break-before: page;
  }

  /* ============================================
     EN-TETE ET PIED DE PAGE
     ============================================ */

  /* Header d'impression */
  .print-header {
    display: block !important;
    text-align: center;
    margin-bottom: 5mm;
    padding-bottom: 3mm;
    border-bottom: 1pt solid #000;
  }

  .print-header h1 {
    font-size: 16pt;
    margin: 0;
  }

  /* ============================================
     CHECKBOXES POUR IMPRESSION
     ============================================ */

  .checkbox-group input[type="checkbox"]:checked + span::before {
    content: '\2713 ';
    font-weight: bold;
  }

  .checkbox-group input[type="checkbox"]:not(:checked) + span::before {
    content: '\2610 ';
  }

  .checkbox-group input[type="checkbox"] {
    display: none;
  }
}
