/* ===== CSS DÉDIÉ À L'IMPRESSION DU PLANNING ===== */

/* Configuration de base pour l'impression */
@media print {
    /* Configuration de la page */
    @page {
        size: A4 landscape;
        margin: 0.5cm;
    }
    
    /* Masquer les éléments non nécessaires à l'impression */
    body * {
        visibility: hidden;
    }
    
    /* Afficher uniquement le contenu du planning */
    .print-content, .print-content * {
        visibility: visible;
    }
    
    .print-content {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
    
    /* Styles pour le tableau principal */
    .my-table {
        width: 100% !important;
        table-layout: fixed !important;
        border-collapse: collapse !important;
        font-size: 10px !important;
        page-break-inside: avoid;
    }

    /* Désactiver le sticky pour l'impression */
    .my-table thead {
        position: static !important;
    }

    /* En-têtes du tableau */
    .my-table th {
        background-color: #f8f9fa !important;
        color: #000 !important;
        font-weight: bold !important;
        font-size: 11px !important;
        padding: 4px !important;
        border: 1px solid #000 !important;
        text-align: center !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* Cellules du tableau - dimensions exactes du web */
    .my-table td {
        width: 100px !important;
        max-height: 50px !important;
        height: 50px !important;
        padding: 0 !important;
        margin: 0 !important;
        margin-bottom: 5px !important;
        border: 1px solid #000 !important;
        font-size: 12px !important;
        vertical-align: top !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        position: relative !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* Cellule employé */
    .employee-cell {
        background-color: #f8f9fa !important;
        font-weight: bold !important;
        width: 150px !important;
        min-width: 150px !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    .employee-name {
        font-size: 10px !important;
        font-weight: bold !important;
        color: #000 !important;
    }
    
    /* Cellules de shifts - dimensions et effets exacts du web */
    .shift-cell {
        max-height: 40px !important;
        height: 40px !important;
        padding: 20px !important;
        margin: 1px !important;
        border-radius: 12px !important;
        font-size: 12px !important;
        line-height: 1.2 !important;
        color: black !important;
        font-weight: 500 !important;
        position: relative !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        align-items: center !important;
        justify-content: flex-start !important;
        padding-left: 8px !important;
        text-align: left !important;
        flex-wrap: wrap !important;
        flex-grow: 1 !important;
        text-shadow: 0 1px 1px rgba(255, 255, 255, 0.3) !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        /* Effet métallique complet du web */
        background: linear-gradient(
            135deg,
            rgba(255, 255, 255, 0.4) 0%,
            rgba(255, 255, 255, 0.2) 40%,
            rgba(255, 255, 255, 0.1) 50%,
            rgba(255, 255, 255, 0.2) 60%,
            rgba(0, 0, 0, 0.1) 100%
        ) !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2),
                    inset 0 -1px 0 rgba(0, 0, 0, 0.3),
                    inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
    }
    
    /* Effet de brillance sur le dessus - identique au web */
    .shift-cell::after {
        content: "" !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 60% !important;
        background: linear-gradient(
            to bottom,
            rgba(255, 255, 255, 0.4) 0%,
            rgba(255, 255, 255, 0.1) 100%
        ) !important;
        border-radius: 12px 12px 0 0 !important;
        pointer-events: none !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* Préserver les couleurs des postes */
    .shift-cell[style*="background-color"] {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* Styles pour les différents types de shifts */
    .shift-cell strong {
        font-size: 8px !important;
        display: block !important;
        margin-bottom: 1px !important;
    }
    
    /* Poste CSS */
    .PosteCss {
        font-size: 7px !important;
        padding: 1px !important;
        border-radius: 3px !important;
        text-align: center !important;
        margin: 1px 0 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* Heures supplémentaires - fond rouge */
    .shift-cell[style*="background-color: red"] {
        background-color: #dc3545 !important;
        color: white !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* Absences - fond gris clair */
    .shift-cell[style*="background-color: lightgray"] {
        background-color: #e9ecef !important;
        color: #000 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* Shifts non planifiés */
    .unscheduled-shift {
        position: relative !important;
    }
    
    .unscheduled-shift::before {
        content: "⚠️" !important;
        position: absolute !important;
        top: 0 !important;
        right: 0 !important;
        font-size: 8px !important;
        color: #ff6b35 !important;
        background: rgba(255, 255, 255, 0.8) !important;
        border-radius: 50% !important;
        width: 12px !important;
        height: 12px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* Différences positives et négatives */
    .positive-diff {
        background-color: #28a745 !important;
        color: white !important;
        padding: 1px 3px !important;
        border-radius: 2px !important;
        font-size: 7px !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    .negative-diff {
        background-color: #dc3545 !important;
        color: white !important;
        padding: 1px 3px !important;
        border-radius: 2px !important;
        font-size: 7px !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* Footer du tableau - uniquement sur la dernière page */
    #sticky-footer, tfoot {
        background-color: #f8f9fa !important;
        font-weight: bold !important;
        border-top: 2px solid #000 !important;
        position: static !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* Forcer le footer à apparaître seulement à la fin */
    .my-table tfoot {
        display: table-footer-group !important;
        page-break-before: avoid !important;
        page-break-after: avoid !important;
        page-break-inside: avoid !important;
        break-before: avoid !important;
        break-after: avoid !important;
        break-inside: avoid !important;
    }
    
    /* Éviter que le footer apparaisse au milieu d'une page */
    .my-table tfoot tr {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
    
    .heures_journalieres {
        text-align: center !important;
        font-weight: bold !important;
        font-size: 9px !important;
    }
    
    /* Valeurs alignées à droite */
    .value-right {
        float: right !important;
        font-size: 7px !important;
        font-weight: bold !important;
    }
    
    /* Masquer les éléments interactifs */
    .plus-icon,
    .icon-overlay,
    .drag-handle,
    .bi-grip-vertical,
    button,
    input[type="checkbox"],
    .dropdown-menu,
    .modal {
        display: none !important;
    }
    
    /* Optimisation pour les tableaux imbriqués - dimensions exactes du web */
    .my-table td table {
        width: 100% !important;
        height: 100% !important;
        table-layout: fixed !important;
        border-collapse: collapse !important;
    }
    
    .my-table td table tr {
        max-height: 40px !important;
        height: 40px !important;
        page-break-inside: avoid !important;
    }
    
    .my-table td table td {
        border: none !important;
        padding: 1px !important;
        margin: 1px !important;
    }
    
    /* Gestion des sauts de page */
    .employee-row {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
    
    /* Éviter que le footer se retrouve au milieu des employés */
    .my-table tbody {
        page-break-after: auto !important;
    }
    
    /* S'assurer que le footer reste avec le tableau */
    .my-table {
        page-break-inside: auto !important;
    }
    
    /* Forcer le footer à rester en bas de la dernière page */
    tfoot {
        position: static !important;
        bottom: auto !important;
        page-break-before: avoid !important;
        page-break-inside: avoid !important;
        break-before: avoid !important;
        break-inside: avoid !important;
    }
    
    /* Titre du planning */
    .planning-title {
        font-size: 14px !important;
        font-weight: bold !important;
        text-align: center !important;
        margin-bottom: 10px !important;
        color: #000 !important;
    }
    
    /* Optimisation de l'espace */
    body {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Forcer l'affichage des couleurs dans tous les navigateurs */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
}

/* Styles pour la prévisualisation d'impression */
.print-preview {
    background: white;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    margin: 20px auto;
    padding: 20px;
    max-width: 1200px;
}

.print-preview .my-table {
    font-size: 10px;
}

.print-preview .shift-cell {
    font-size: 8px;
    padding: 2px;
}

.print-preview .employee-name {
    font-size: 10px;
}

/* Styles pour le mode impression navigateur amélioré */
@media screen {
    .print-mode {
        background: white !important;
        color: black !important;
    }
    
    .print-mode .my-table {
        font-size: 11px !important;
        border: 1px solid #000 !important;
    }
    
    .print-mode .shift-cell {
        font-size: 9px !important;
        border: 1px solid rgba(0,0,0,0.1) !important;
    }
}
