@media print {
    /* Base settings */
    @page {
        margin: 0.5cm;
        size: A4 portrait;
    }

    html, body {
        width: 210mm;
        height: 297mm;
        background-color: white !important;
        font-size: 12pt;
        line-height: 1.4;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Masquer éléments non imprimables */
    .no-print {
        display: none !important;
    }

    /* Logo and header */
    /* Masquer le logo du bas (écran) en impression */
    .logo-container.no-print {
        display: none !important;
    }

    /* Afficher le logo du haut (impression) */
    .logo-container.print-only {
        display: block !important;
        margin: 0 0 25px 0;
        text-align: center;
    }

    .logo-container.print-only img {
        height: 100px;
        border: none !important;
        box-shadow: none !important;
        filter: none !important;
    }

    /* Title banner */
    .title-banner {
        background: #067379 !important;
        color: white !important;
        padding: 12px 15px;
        border-radius: 6px;
        margin-bottom: 10px;
    }

    .title-content h1 {
        font-size: 16pt;
        text-align: center;
        width: 100% !important;
    }

    /* Masquer le dropdown année et afficher uniquement le texte */
    .annee-select {
        appearance: none;
        -webkit-appearance: none;
        -moz-appearance: none;
        background: none !important;
        border: none !important;
        color: white !important;
        font-size: inherit;
        font-weight: inherit;
        padding: 0 !important;
        margin: 0 !important;
        cursor: default;
    }

    /* Masquer la flèche du select */
    .annee-select::-ms-expand {
        display: none;
    }

    /* Info container first page */
    .info-container {
        display: flex;
        gap: 10px;
        margin-bottom: 10px;
        break-inside: avoid;
    }

    .info-container > .section {
        flex: 1;
        margin-bottom: 0;
        padding: 15px;
        border: 1px solid #e0e0e0;
        border-radius: 6px;
    }

    /* Stats première page */
    .contact-info .monitoring-stat,
    .equipments-info .monitoring-stat,
    .synthese-info .monitoring-stat,
    .impact-info .monitoring-stat {
        display: grid;
        grid-template-columns: 300px auto;
        gap: 5px;
        margin-bottom: 5px;
        align-items: baseline;
    }

    /* Section headers */
    .monitoring-card-header {
        color: #045B62 !important;
        font-size: 13pt;
        font-weight: 600;
        margin-bottom: 10px;
        padding-bottom: 5px;
        border-bottom: 1px solid #e0e0e0;
        display: flex !important;
        align-items: center;
        gap: 8px;
        white-space: normal;
    }

    .monitoring-card-header span {
        display: inline !important;
    }

    .monitoring-card-header .espece-icone {
        margin-right: 0;
    }

    /* Hide contact info */
    .contact-info {
        display: none;
    }

    .equipments-info {
        width: 100%;
    }

    /* Methode section */
    .methode-info {
        break-inside: avoid;
        background: white !important;
        border: 1px solid #e0e0e0;
        padding: 15px;
        border-radius: 6px;
        margin-bottom: 15px;
    }

    .monitoring-description {
        font-size: 11pt;
    }

    /* Masquer bannière photos méthode à l'impression */
    .methode-photos-banner {
        display: none !important;
    }

    .references {
        display: none !important;
    }

    /* === Impression : section impact - panels dépliables === */

    /* Conteneur impact */
    .impact-item {
        page-break-inside: avoid;
        margin-bottom: 15px;
    }

    /* Ligne stat : affichée en impression */
    .impact-stat-clickable {
        cursor: default;
        border: none;
        padding-left: 35px;
    }

    /* Icône espèce SVG */
    .impact-info-icon svg {
        width: 18px;
        height: 18px;
    }

    /* Panels détaillés : masqués en impression */
    .impact-detail-panel {
        display: none !important;
    }

    /* Bannière panoramique : masquée en impression */
    .impact-thumbnails-banner {
        display: none !important;
    }

    /* Parcelles section */
    .section-parcelles {
        break-before: page;
        page-break-before: always;
        padding: 10px;
        border: 1px solid #e0e0e0;
    }

    .section-parcelles .monitoring-card-header {
        display: block !important;
        white-space: normal;
    }

    .parcelle-section {
        break-inside: avoid;
        margin-bottom: 20px;
        background: white !important;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        overflow: hidden;
    }

    /* Header de parcelle - tout sur une ligne comme desktop */
    .parcelle-header {
        background: #045B62 !important;
        color: white !important;
        padding: 0.75rem 1.5rem;
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between;
        align-items: center !important;
        flex-wrap: nowrap !important;
        gap: 1rem;
    }

    .parcelle-header-left {
        display: flex !important;
        flex-direction: row !important;
        gap: 1rem;
        align-items: center !important;
        flex: 0 0 auto;
    }

    .parcelle-header-left > span {
        font-weight: 600;
        font-size: 11pt;
        white-space: nowrap;
    }

    .parcelle-header-tags {
        display: flex !important;
        flex-direction: row !important;
        gap: 0.75rem;
        align-items: center !important;
        flex-wrap: nowrap !important;
    }

    .parcelle-tag {
        background: rgba(255, 255, 255, 0.2);
        padding: 0.25rem 0.75rem;
        border-radius: 1rem;
        font-size: 0.875rem;
        white-space: nowrap;
    }

    /* Forcer les icônes d'espèces à rester inline */
    .parcelle-header .espece-icone {
        flex-shrink: 0;
        width: 24px !important;
        height: 24px !important;
    }

    /* Content de parcelle - 2 colonnes comme en desktop */
    .parcelle-content {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
        padding: 12px !important;
        background: #f8f9fa !important;
    }

    /* Layout adaptatif selon nombre de cards comme en desktop */
    .parcelle-content.one-card {
        display: grid !important;
        grid-template-columns: 1fr !important;
    }

    .parcelle-content.one-card .monitoring-card:not(.comments-card) {
        grid-column: 1 / -1;
        max-width: 400px;
        margin: 0 auto;
        width: 100%;
    }

    .parcelle-content.two-cards,
    .parcelle-content.three-plus-cards {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
    }

    /* Forcer la carte commentaires à apparaître en dernier sur toute la largeur */
    .monitoring-card.comments-card {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        order: 999 !important;
    }

    /* Les autres cartes gardent leur ordre naturel et occupent 1 colonne chacune */
    .parcelle-content .monitoring-card:not(.comments-card) {
        order: 0 !important;
        grid-column: span 1 !important;
    }

    /* Préserver la structure quand un élément est masqué */
    .monitoring-card[style*="display: none"] {
        display: none !important;
    }

    /* Forcer le layout grid même avec inline styles JavaScript */
    .parcelle-content[style] {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
    }

    .parcelle-content .monitoring-card {
        background: white !important;
        border: 1px solid #e0e0e0;
        padding: 10px;
        border-radius: 6px;
        box-shadow: none;
        width: auto !important;
        max-width: 100% !important;
        min-width: auto !important;
    }

    /* Empêcher l'héritage des styles mobile centrés */
    .monitoring-card .monitoring-stat {
        text-align: left !important;
        align-items: baseline !important;
    }

    .monitoring-card .monitoring-stat-label {
        text-align: left !important;
        width: auto !important;
    }

    .monitoring-card .monitoring-stat-value {
        justify-content: flex-end !important;
    }

    .parcelle-content .monitoring-card-header {
        color: #045B62 !important;
        font-size: 11pt;
        font-weight: 600;
        margin-bottom: 12px;
        padding-bottom: 5px;
        border-bottom: 1px solid #e0e0e0;
        display: flex !important;
        align-items: center;
        gap: 8px;
    }

    /* Stats dans les cards parcelles - alignement à gauche comme desktop */
    .parcelle-content .monitoring-stat {
        display: flex !important;
        justify-content: space-between !important;
        align-items: baseline !important;
        flex-direction: row !important;
        padding: 2px 0;
        margin-bottom: 2px;
        border-bottom: none !important;
        text-align: left !important;
    }

    .parcelle-content .monitoring-stat-label {
        font-size: 9pt;
        color: #444;
        flex: 1;
        text-align: left !important;
    }

    .parcelle-content .monitoring-stat-number {
        font-size: 9pt;
        color: #045B62 !important;
        font-weight: 600;
        text-align: right !important;
        margin-left: 15px;
        white-space: nowrap;
    }

    .parcelle-content .monitoring-stat-value {
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        justify-content: flex-end !important;
        flex-direction: row !important;
    }

    /* Uniformiser la taille de police des nombres et badges dans les cards */
    .parcelle-content .monitoring-stat-number,
    .parcelle-content .evolution-badge,
    .parcelle-content .taux-suivi-badge,
    .parcelle-content .taux-occupation-inline {
        font-size: 9pt !important;
    }

    /* Evolution indicators */
    .evolution {
        font-size: 8pt;
        padding: 2px 6px;
        margin-left: 6px;
        border-radius: 3px;
        display: inline-block;
    }

    .evolution.positive {
        background: rgba(34, 197, 94, 0.1) !important;
        color: rgb(21, 128, 61) !important;
    }

    .evolution.negative {
        background: rgba(239, 68, 68, 0.1) !important;
        color: rgb(185, 28, 28) !important;
    }

    /* Elements to hide */
    .title-actions,
    .title-icon,
    .title-content > a,
    #map-link,
    [href^="https://carto."],
    .button-container,
    #loading,
    #error,
    .tooltip-wrapper[data-tooltip]::before,
    .tooltip-wrapper[data-tooltip]::after,
    .tooltip-wrapper[data-tooltip-long]::before,
    .badge-mobile-tooltip {
        display: none !important;
    }

    /* Masquer tous les formulaires de commentaires (redondant avec .no-print mais explicite) */
    .add-comment-button,
    .add-comment-container,
    .comment-form-body,
    .comment-form-actions,
    .comment-textarea,
    .comment-password-input {
        display: none !important;
    }

    /* Footer */
    .footer {
        margin-top: 15px;
        padding-top: 10px;
        font-size: 8pt;
        border-top: 1px solid #e0e0e0;
        text-align: center;
        color: #666;
    }

    /* ===========================================
       TABLEAU GROUPES ESPÈCES - MODE IMPRESSION
       =========================================== */

    /* Afficher toutes les lignes de détail en mode impression */
    .especes-table .espece-detail-row {
        display: table-row !important;
    }

    .table-responsive {
        overflow-x: visible;
        margin-top: 20px;
    }

    .especes-table {
        width: 100%;
        border-collapse: collapse;
        border-spacing: 0;
        background: white;
        font-size: 9pt;
    }

    /* Supprimer toutes les bordures de contenu, appliquer bordures horizontales aux lignes */
    .especes-table th,
    .especes-table td {
        padding: 8px 6px;
        text-align: left;
        border: none;
        vertical-align: middle;
    }

    .especes-table tbody tr {
        border-bottom: 1px solid #ccc;
    }

    .especes-table thead tr {
        border-bottom: 2px solid #045B62;
    }

    /* Colonne Espèce (1ère colonne) */
    .especes-table th:nth-child(1),
    .especes-table td:nth-child(1) {
        padding-left: 12px;
    }

    /* Colonnes Suivis (Nb et %) */
    .especes-table td:nth-child(3),
    .especes-table td:nth-child(4) {
        text-align: center;
        white-space: nowrap;
        padding: 8px 4px;
    }

    /* Colonnes Occupés (Nb et %) */
    .especes-table td:nth-child(5),
    .especes-table td:nth-child(6) {
        text-align: center;
        white-space: nowrap;
        padding: 8px 4px;
    }

    /* Colonne Nb individus */
    .especes-table td:nth-child(7) {
        text-align: center;
    }

    /* Colonne Évolution - centrée */
    .especes-table td:nth-child(8) {
        text-align: center;
    }

    .especes-table .monitoring-stat-value {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        flex-wrap: nowrap;
    }

    /* S'assurer que les badges dans les stats ne cassent pas la ligne */
    .monitoring-stat-value .evolution-badge,
    .monitoring-stat-value .taux-suivi-badge,
    .monitoring-stat-value .taux-occupation-inline {
        flex-shrink: 0;
    }

    /* Headers */
    .especes-table th {
        background-color: #045B62 !important;
        font-weight: 600;
        color: white !important;
        padding: 8px;
    }

    .especes-table .espece-nom {
        font-weight: 600;
        color: var(--primary-color);
    }

    /* Styles pour les groupes d'espèces */
    .especes-table .groupe-espece-row {
        background-color: transparent !important;
        font-weight: 600;
        border-bottom: 1px solid #ccc;
    }

    .especes-table .groupe-espece-row td {
        font-weight: 600;
    }

    /* Ligne de total de l'exploitation */
    .especes-table .total-exploitation-row {
        background: transparent !important;
        font-weight: 600;
        border-top: 2px solid #999;
        border-bottom: 2px solid #999;
    }

    .especes-table .total-exploitation-row td {
        padding: 10px 8px;
        font-weight: 600;
        font-size: 0.95em;
    }

    .especes-table .total-exploitation-row .total-label {
        font-size: 0.9em;
        letter-spacing: 0.5px;
        text-transform: uppercase;
        color: var(--primary-color);
    }

    /* Groupe avec sous-espèces (cliquable) */
    .especes-table .groupe-nom {
        display: flex;
        align-items: center;
        gap: 8px;
        color: var(--primary-color);
        font-weight: 600;
        width: 100%;
    }

    .especes-table .groupe-toggle {
        font-size: 0.9em;
        color: var(--primary-color);
    }

    /* Groupe simple (non cliquable) */
    .especes-table .groupe-nom-simple {
        display: flex;
        align-items: center;
        gap: 8px;
        color: var(--primary-color);
        font-weight: 600;
        width: 100%;
    }

    /* Styles pour les espèces détaillées - avec indent */
    .especes-table .espece-detail-row {
        background-color: transparent !important;
        border-bottom: 1px solid #ccc;
    }

    .especes-table .espece-detail-row td:first-child {
        padding-left: 24px;
    }

    .especes-table .espece-detail {
        font-weight: 400;
        color: #666;
        font-size: 0.9em;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .especes-table .espece-detail > span {
        margin-left: 0 !important;
    }

    /* Badge pour le taux de suivi */
    .taux-suivi-badge {
        display: inline-block;
        padding: 3px 8px;
        background-color: rgba(4, 91, 98, 0.1) !important;
        color: #045B62 !important;
        border: 1px dashed rgba(4, 91, 98, 0.3) !important;
        border-radius: 3px;
        font-weight: 600;
        font-size: 0.8em;
        white-space: nowrap;
        cursor: default !important;
    }

    /* Taux de suivi faible */
    .taux-suivi-badge.low {
        background-color: rgba(239, 68, 68, 0.1) !important;
        color: #dc2626 !important;
        border: 1px dashed rgba(239, 68, 68, 0.3) !important;
    }

    /* Badge pour le pourcentage d'occupation */
    .taux-occupation-inline {
        display: inline-block;
        padding: 3px 8px;
        background-color: rgba(4, 91, 98, 0.1) !important;
        color: #045B62 !important;
        border: 1px dashed rgba(4, 91, 98, 0.3) !important;
        border-radius: 3px;
        font-weight: 600;
        font-size: 0.8em;
        white-space: nowrap;
        cursor: default !important;
    }

    .especes-table .evolution {
        font-weight: 500;
    }

    /* Badges d'évolution - Style print avec couleurs solides */
    .evolution-badge {
        display: inline-flex !important;
        align-items: center;
        gap: 4px;
        padding: 3px 8px;
        border-radius: 3px;
        font-weight: 600;
        font-size: 0.85em;
        white-space: nowrap;
        box-shadow: none !important;
    }

    /* Badges d'évolution dans les cards parcelles : uniformiser en print */
    .monitoring-card .evolution-badge {
        padding: 3px 8px;
        font-size: 0.85em;
        font-weight: 600;
        gap: 4px;
    }

    .evolution-badge.positive {
        background-color: rgba(34, 197, 94, 0.15) !important;
        color: #16a34a !important;
        border: 1px solid rgba(34, 197, 94, 0.3) !important;
    }

    .evolution-badge.negative {
        background-color: rgba(239, 68, 68, 0.15) !important;
        color: #dc2626 !important;
        border: 1px solid rgba(239, 68, 68, 0.3) !important;
    }

    .evolution-badge.stable {
        background-color: rgba(102, 102, 102, 0.1) !important;
        color: #666 !important;
        border: 1px solid rgba(102, 102, 102, 0.2) !important;
    }

    .evolution-badge.no-data {
        background-color: transparent !important;
        color: #999 !important;
        border: none !important;
        font-weight: 400;
        box-shadow: none !important;
    }

    /* ===========================================
       COMMENTAIRES - MODE IMPRESSION
       =========================================== */

    /* Afficher les cards de commentaires (parcelles et ferme) SAUF formulaires */
    /* Important: utiliser :not(.no-print) pour éviter conflit de spécificité CSS */
    .monitoring-card.comments-card:not(.no-print),
    .ferme-comment-card:not(.no-print) {
        display: block !important;
        background: white !important;
        border: 1px solid #e0e0e0;
        padding: 10px;
        border-radius: 6px;
        box-shadow: none;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    /* Card commentaire ferme : toute la largeur */
    .ferme-comment-wrapper {
        grid-column: 1 / -1 !important;
        margin-top: 30px;
    }

    /* Afficher le contenu du commentaire */
    .monitoring-comment {
        display: block !important;
        width: 100%;
        overflow-wrap: break-word;
        word-wrap: break-word;
        position: static !important;
        cursor: default !important;
    }

    .monitoring-comment p {
        border-left: 4px solid var(--primary-color);
        padding-left: 15px;
        padding-right: 15px;
        margin: 0;
        text-align: justify;
        font-size: 10pt;
        line-height: 1.5;
    }

    /* Retirer les effets hover et icône de crayon */
    .monitoring-comment.editable {
        cursor: default !important;
        background-color: transparent !important;
    }

    .monitoring-comment.editable:hover {
        background-color: transparent !important;
    }

    .monitoring-comment.editable::after {
        display: none !important;
        content: none !important;
    }

    .monitoring-comment.editable:hover::after {
        display: none !important;
    }

    /* Masquer animations et effets */
    .monitoring-card.comments-card.highlight {
        animation: none !important;
        background-color: white !important;
        box-shadow: none !important;
    }

    /* Anciens styles pour compatibilité */
    .especes-table .evolution.positive {
        color: #28a745;
    }

    .especes-table .evolution.negative {
        color: #dc3545;
    }

    .especes-table .evolution.neutral {
        color: #6c757d;
    }

    /* Espacement global des icônes d'espèces */
    .espece-icone {
        vertical-align: middle;
    }

    /* Taille des icônes en impression */
    .especes-table .espece-icone {
        width: 20px;
        height: 20px;
    }

    /* Tooltips et éléments interactifs - désactiver en print */
    .tooltip-wrapper {
        position: static !important;
        display: inline !important;
    }

    .tooltip-wrapper[data-tooltip]::before,
    .tooltip-wrapper[data-tooltip]::after,
    .tooltip-wrapper[data-tooltip-long]::before,
    .tooltip-wrapper[data-tooltip-long]::after {
        display: none !important;
        content: none !important;
    }

    /* Supprimer les cursors interactifs */
    .taux-suivi-badge,
    .taux-occupation-inline,
    .evolution-badge,
    .equipement-clickable {
        cursor: default !important;
        user-select: none !important;
    }

    .equipement-clickable {
        text-decoration: none !important;
        color: inherit !important;
    }

}