/* --- Base et Mise en page --- */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f7f2;
    color: #333;
    margin: 0;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

h1 { color: #2e7d32; margin-bottom: 5px; }
.scientific-name { font-style: italic; color: #555; margin-bottom: 20px; }

/* --- STYLE POUR L'INDEX --- */
.controls { margin-bottom: 20px; display: flex; gap: 10px; }
input[type="text"] {
    flex: 1; padding: 12px; border: 1px solid #ddd;
    border-radius: 8px; font-size: 1rem; outline: none;
}
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th { background-color: #e8f5e9; color: #2e7d32; text-align: left; padding: 15px; border-bottom: 2px solid #c8e6c9; }
td { padding: 15px; border-bottom: 1px solid #eee; cursor: pointer; }
tr:hover td { background-color: #f1f8e9; }

/* --- STYLE POUR LA FICHE --- */
.section-title {
    background-color: #2e7d32;
    color: white;
    padding: 12px 15px;
    border-radius: 6px;
    margin: 30px 0 15px 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

.info-block {
    background: #f9fbf9;
    padding: 15px;
    border-left: 4px solid #81c784;
    border-radius: 4px;
}

.info-block h3 {
    margin: 0 0 8px 0;
    font-size: 0.8rem;
    color: #2e7d32;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-block h3 .material-icons {
    font-size: 18px;
    color: #81c784;
}

.info-content { 
    padding-left: 26px; 
    line-height: 1.5; 
    font-size: 0.95rem; 
}

/* --- GALERIE --- */
.galerie {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin: 20px 0 10px 0;
}
.galerie img {
    width: 100%; aspect-ratio: 1/1; object-fit: cover;
    border-radius: 8px; cursor: zoom-in; border: 1px solid #eee;
}
.credits-photos { font-size: 0.7rem; color: #999; text-align: center; font-style: italic; }

/* --- LIGHTBOX & BOUTONS --- */
.lightbox {
    display: none; position: fixed; z-index: 3000;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); align-items: center; justify-content: center;
}
.lightbox img { max-width: 90%; max-height: 85%; }
.close-lightbox { position: absolute; top: 20px; right: 30px; color: white; font-size: 40px; cursor: pointer; }

.no-print { margin-top: 40px; text-align: center; }
button {
    background: #2e7d32; color: white; border: none; padding: 12px 25px;
    border-radius: 6px; cursor: pointer; font-size: 1rem;
}

@media print {
    .no-print, .lightbox { display: none !important; }
    .container { box-shadow: none; border: none; width: 100%; padding: 0; }
}
/* Bouton Remonter en haut */
.back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #2e7d32;
    color: white;
    border: none;
    cursor: pointer;
    display: none; /* Caché par défaut */
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: opacity 0.3s, transform 0.3s;
    z-index: 1000;
}

.back-to-top:hover {
    background-color: #1b5e20;
    transform: scale(1.1);
}

.back-to-top .material-icons {
    font-size: 24px;
}

/* ============================================================
   OPTIMISATION PDF & IMPRESSION (NETTOYÉ ET CORRIGÉ)
   ============================================================ */

/* 1. Cache le saut de page sur l'écran du site */
.page-break {
    display: none;
}

@media print {
    /* Force le conteneur à ne pas utiliser Flex ou Grid pour le PDF */
    #ficheContent, .container {
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
    }

    /* Rend le saut de page effectif */
    .page-break {
        display: block !important;
        page-break-before: always !important;
        height: 1px !important; /* Petit espace pour forcer le rendu */
        margin-bottom: -1px !important;
    }

    /* Désactive la grille (grid) pour les infos techniques sur le PDF */
    /* C'est ce qui empêche souvent le bon rendu des blocs */
    .info-grid {
        display: block !important; 
    }

    .info-block {
        display: block !important;
        page-break-inside: avoid !important; /* Empêche de couper un bloc en deux */
        break-inside: avoid !important;
        margin-bottom: 15px !important;
        width: 100% !important;
    }

    /* Empêche les images de déborder sur la page suivante si trop grandes */
    .galerie img {
        max-height: 400px !important;
        object-fit: contain !important;
        page-break-inside: avoid !important;
    }

    /* Cache tous les boutons et éléments inutiles */
    button, .no-print, .back-to-top, .lightbox, .close-lightbox {
        display: none !important;
    }

    /* Force le texte en noir pour l'impression */
    body {
        background: white !important;
        color: black !important;
    }
}
