/* Styles d'impression */
@media print {

    /* Cacher les éléments non nécessaires */
    .sidebar,
    .mobile-menu-btn,
    #overlay,
    .filters-container,
    .card-actions,
    .nav-menu,
    .alert,
    #coding-count,
    .search-box,
    .filter-group,
    .table-actions,
    .btn,
    button {
        display: none !important;
    }

    /* Ajustements du layout principal */
    .app-container {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 20px !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }

    /* Par défaut, masquer toutes les sections */
    .view-section {
        display: none !important;
    }

    /* Afficher room-detail-view pour l'impression directe (salles) */
    #room-detail-view {
        display: block !important;
    }

    /* Quand body.printing est actif (presence, coding, notation), 
       masquer TOUTES les vues pour ne montrer que #print-area */
    body.printing .app-container,
    body.printing .main-content,
    body.printing #room-detail-view,
    body.printing #presence-view,
    body.printing #coding-view,
    body.printing #notation-view,
    body.printing .view-section {
        display: none !important;
    }

    /* Style du conteneur d'impression dynamique (#print-area) */
    #print-area {
        display: block !important;
        width: 100%;
        background: white;
        color: black;
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        padding: 20px;
    }

    /* En-têtes d'impression */
    .print-header {
        text-align: center;
        margin-bottom: 30px;
        border-bottom: 2px solid #000;
        padding-bottom: 20px;
    }

    .print-header h1 {
        font-size: 24px;
        margin: 0 0 10px 0;
        color: #000;
    }

    .print-header p {
        margin: 5px 0;
        font-size: 14px;
        color: #333;
    }

    /* Tables d'impression génériques */
    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin-top: 20px;
    }

    .print-table th,
    .print-table td {
        border: 1px solid #000;
        padding: 8px 12px;
        text-align: left;
        font-size: 11pt;
        color: #000;
    }

    .print-table th {
        background-color: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        font-weight: bold;
        text-align: center;
    }

    .print-table td {
        vertical-align: middle;
    }

    .print-table td.code-cell {
        font-family: 'Courier New', monospace;
        font-weight: bold;
        font-size: 14pt;
        text-align: center;
        letter-spacing: 2px;
    }

    /* Styles pour room-detail-view */
    #room-detail-view .page-header {
        display: block !important;
        text-align: center;
        margin-bottom: 20px;
        border-bottom: 2px solid #000;
        padding: 10px 0 15px 0;
    }

    #room-detail-view .page-title {
        font-size: 22px !important;
        color: #000 !important;
        margin: 0 0 10px 0 !important;
        font-weight: bold;
    }

    #room-detail-view .page-description {
        color: #333 !important;
        font-size: 14px;
        margin: 5px 0;
    }

    #room-detail-view .table-container {
        background: white;
        color: black;
        border: none;
        box-shadow: none;
    }

    #room-detail-view .table-header {
        display: none !important;
    }

    #room-detail-view table {
        width: 100%;
        border-collapse: collapse;
        margin-top: 10px;
        background: white;
    }

    #room-detail-view table th,
    #room-detail-view table td {
        border: 1px solid #000 !important;
        padding: 10px 12px !important;
        text-align: left;
        font-size: 11pt;
        color: #000 !important;
        background: white !important;
    }

    #room-detail-view table th {
        background-color: #e5e7eb !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        font-weight: bold;
        text-align: center !important;
    }

    #room-detail-view .signature-cell {
        min-height: 50px !important;
    }

    /* Gestion des sauts de page */
    tr {
        page-break-inside: avoid;
    }

    thead {
        display: table-header-group;
    }

    tfoot {
        display: table-footer-group;
    }

    /* Styles pour les signatures des correcteurs */
    .signature-section {
        display: flex;
        align-items: center;
        gap: 15px;
    }

    .signature-label {
        margin: 0;
        font-size: 12pt;
        font-weight: bold;
        min-width: 250px;
        color: #000;
    }

    .signature-line {
        flex: 1;
        border-bottom: 1px solid #000;
        min-height: 30px;
    }

    /* Forcer chaque page à commencer sur une nouvelle feuille */
    .print-page {
        page-break-after: always;
        /* Hauteur fixe pour forcer le footer en bas sans dépasser */
        height: 90vh;
        display: flex;
        flex-direction: column;
        position: relative;
    }

    .print-page:last-child {
        page-break-after: auto;
    }

    /* Pousser les signatures tout en bas */
    .print-signatures {
        margin-top: auto;
        padding-top: 20px;
        border-top: 2px solid #000;
        display: flex;
        flex-direction: column;
        gap: 25px;
    }

    /* Paramètres de page */
    @page {
        size: A4;
        margin: 1.5cm;
    }
}

/* État printing pour preparer l'impression */
body.printing {
    overflow: hidden;
}