/* --- STYLE.CSS (FINALE - AJOUT STYLES ALIMENTATION) --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');
:root {
    --primary-blue: #3498DB;
    --primary-green: #2ECC71;
    --accent-orange: #E67E22;
    --danger-red: #E74C3C;
    --warning-yellow: #F1C40F;
    --background-light: #ECF0F1;
    --surface-white: #FFFFFF;
    --text-dark: #2C3E50;
    --text-muted: #7F8C8D;
    --border-light: #dde2e6;
    --border-radius-card: 15px;
    --border-radius-btn: 8px;
    --box-shadow-light: 0 4px 15px rgba(0, 0, 0, 0.08);
}
body { font-family: 'Poppins', sans-serif; background-color: var(--background-light); color: var(--text-dark); line-height: 1.6; margin: 0; }
header { background-color: var(--surface-white); padding: 1rem 2rem; display: flex; justify-content: space-between; align-items: center; box-shadow: var(--box-shadow-light); border-bottom: 3px solid var(--primary-blue); }
header h1 { font-size: 1.8rem; color: var(--primary-blue); margin-right: 2rem; }
nav { flex-grow: 1; display: flex; justify-content: center; }
nav ul { list-style-type: none; display: flex; gap: 0.8rem; padding:0; margin:0; }
nav a { text-decoration: none; color: var(--text-muted); font-weight: 500; padding: 0.6rem 1.2rem; border-radius: var(--border-radius-btn); transition: all 0.3s; white-space: nowrap; }
nav a:hover { color: var(--primary-blue); background-color: rgba(52, 152, 219, 0.1); }
nav a.active { background-color: var(--primary-blue); color: var(--surface-white); font-weight: 600; }
main { flex-grow: 1; padding: 2rem; max-width: 1200px; margin: 0 auto; }
.main-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem; }
.card { background-color: var(--surface-white); border-radius: var(--border-radius-card); box-shadow: var(--box-shadow-light); padding: 2rem; border: 1px solid #e9ecef; margin-bottom: 2rem; }
.card h3 { color: var(--text-dark); margin-bottom: 1.5rem; font-size: 1.4rem; border-bottom: 1px solid var(--border-light); padding-bottom: 0.8rem; }
button, .button { background-color: var(--primary-green); color: var(--surface-white); border: none; padding: 0.8rem 1.5rem; border-radius: var(--border-radius-btn); cursor: pointer; font-size: 1rem; font-weight: 600; font-family: 'Poppins', sans-serif; transition: all 0.3s; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; box-shadow: 0 2px 5px rgba(46, 204, 113, 0.2); }
button:hover, .button:hover { background-color: #27AE60; transform: translateY(-1px); box-shadow: 0 4px 10px rgba(46, 204, 113, 0.3); }
.button-secondary { background-color: var(--primary-blue); box-shadow: 0 2px 5px rgba(52, 152, 219, 0.2); }
.button-secondary:hover { background-color: #2980B9; box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3); }
.button-edit { background-color: var(--accent-orange); box-shadow: 0 2px 5px rgba(230, 126, 34, 0.2); }
.button-edit:hover { background-color: #D35400; box-shadow: 0 4px 10px rgba(230, 126, 34, 0.3); }
.button-delete { background-color: var(--danger-red); box-shadow: 0 2px 5px rgba(231, 76, 60, 0.2); }
.button-delete:hover { background-color: #C0392B; box-shadow: 0 4px 10px rgba(231, 76, 60, 0.3); }
.button-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
fieldset { border: none; border-top: 1px solid var(--border-light); border-radius: 0; padding: 1.5rem 0; margin: 0; }
fieldset:first-of-type { border-top: none; }
legend { font-weight: 600; color: var(--primary-blue); padding: 0; font-size: 1.1rem; margin-bottom: 1rem; }
.form-group { display: flex; flex-direction: column; margin-bottom:1rem; }
label { font-weight: 500; margin-bottom: 0.5rem; color: var(--text-dark); }
input[type="text"], input[type="date"], input[type="number"], select, textarea { -webkit-appearance: none; -moz-appearance: none; appearance: none; background-color: var(--surface-white); border: 1px solid var(--border-light); border-radius: var(--border-radius-btn); color: var(--text-dark); font-family: 'Poppins', sans-serif; font-size: 1rem; padding: 0.8rem 1rem; transition: all 0.3s; width: 100%; box-sizing: border-box; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary-blue); box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2); }
select { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%237F8C8D' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 1rem center; background-size: 1.2em; padding-right: 3rem; cursor: pointer; }
ul#animal-list, .item-list { list-style: none; padding: 0; margin: 0; }
ul#animal-list li, .item-list li { display: flex; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-light); transition: background-color 0.2s ease; gap: 1rem; }
ul#animal-list li:hover, .item-list li:hover { background-color: #F8F9FA; }
ul#animal-list li:last-child, .item-list li:last-child { border-bottom: none; }
.item-details { flex-grow: 1; }
.item-details small { color: var(--text-muted); display: block; }
.item-actions { display: flex; gap: 0.5rem; margin-left: auto; }
.status-tag { display: inline-block; padding: 0.25rem 0.75rem; font-size: 0.75rem; font-weight: 600; line-height: 1; border-radius: 20px; color: var(--surface-white); text-transform: uppercase; letter-spacing: 0.5px; margin-left: 0.5rem; vertical-align: middle; }
.status-tag.Conventionnel { background-color: var(--text-muted); }
.status-tag.Bio { background-color: var(--primary-green); }
.status-tag.Conversion { background-color: var(--accent-orange); }
.filters-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem 1.5rem; align-items: end; }
#search-input-group { grid-column: 1 / -1; }
.actions-container { display: flex; gap: 1rem; justify-content: flex-start; flex-wrap: wrap; padding-top: 1.5rem; border-top: 1px solid var(--border-light); margin-top: 1.5rem; }
.tab-nav { display: flex; border-bottom: 2px solid var(--border-light); margin-bottom: 2rem; overflow-x: auto; white-space: nowrap; }
.tab-btn { padding: 0.75rem 1.5rem; cursor: pointer; border: none; background-color: transparent; font-size: 1rem; font-weight: 500; color: var(--text-muted); border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all 0.3s; }
.tab-btn:hover { color: var(--primary-blue); background-color: rgba(52, 152, 219, 0.1); }
.tab-btn.active { background-color: var(--primary-blue); color: var(--surface-white); border-bottom-color: transparent; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.5s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.dashboard-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 2rem; align-items: start; }
.dashboard-main-column, .dashboard-sidebar-column { display: flex; flex-direction: column; gap: 2rem; }
.dashboard-main-column .card, .dashboard-sidebar-column .card { margin-bottom: 0; }
.dashboard-subgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.dashboard-subgrid .card { margin-bottom: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 1rem; text-align: center; }
.stat-item { padding: 0.5rem; }
.stat-value { display: block; font-size: 2.2rem; font-weight: 700; color: var(--primary-blue); line-height: 1; margin-bottom: 0.3rem; }
.stat-label { display: block; font-size: 0.9rem; color: var(--text-muted); }
.species-section { margin-bottom: 2rem; }
.species-section:last-child { margin-bottom: 0; }
.species-title { font-size: 1.5rem; color: var(--primary-blue); margin-bottom: 1.5rem; padding-bottom: 0.5rem; border-bottom: 2px solid var(--background-light); }
.detailed-stat-grid { display: flex; justify-content: space-around; flex-wrap: wrap; gap: 1rem; }
.card-legend { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border-light); font-size: 0.8rem; color: var(--text-muted); }
.card-legend p { margin: 0.25rem 0; }
.actions-grid { display: flex; flex-direction: column; gap: 1rem; align-items: center; }
.actions-grid .button { width: 100%; max-width: 250px; }
.loading-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(255, 255, 255, 0.8); display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 10000; transition: opacity 0.3s; }
.loading-spinner { border: 5px solid var(--border-light); border-top: 5px solid var(--primary-blue); border-radius: 50%; width: 50px; height: 50px; animation: spin 1s linear infinite; margin-bottom: 1rem; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@media (max-width: 992px) { .dashboard-layout { grid-template-columns: 1fr; } }
@media (max-width: 768px) { header { flex-direction: column; padding: 1rem; gap: 1rem; } main { padding: 1rem; } .dashboard-subgrid { grid-template-columns: 1fr; } .filters-container { grid-template-columns: 1fr; } ul#animal-list li, .item-list li { flex-direction: column; align-items: flex-start; gap: 0.8rem; } .item-actions { margin-left: 0; width: 100%; } .item-actions .button { flex-grow: 1; } nav ul { flex-wrap: wrap; justify-content: center; } }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.6); display: flex; justify-content: center; align-items: center; z-index: 1000; padding: 1rem; }
.modal-content { background-color: var(--surface-white); padding: 2rem; border-radius: var(--border-radius-card); box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2); width: 100%; max-width: 500px; animation: fadeIn 0.3s ease-out; }
.modal-title { color: var(--primary-blue); margin-top: 0; margin-bottom: 2rem; text-align: center; }

/* --- STYLES SPÉCIFIQUES PAGE ALIMENTATION --- */
.lot-card { border: 1px solid var(--border-light); border-radius: var(--border-radius-btn); padding: 1rem; margin-bottom: 1rem; }
.lot-card h4 { margin-top: 0; display: flex; justify-content: space-between; }
.lot-card .effectif { color: var(--text-muted); font-weight: 500; }
.lot-card ul { padding-left: 20px; margin-bottom: 1rem; }
.item-list li { padding: 0.8rem 1rem; }
.list-item-stock .stock-info { text-align: right; }
.list-item-stock .stock-info span { font-weight: 600; font-size: 1.1rem; display: block; }
.list-item-stock .stock-info small { font-size: 0.8rem; }
.stock-ok { color: var(--primary-green); }
.stock-warning { color: var(--accent-orange); }
.stock-alerte { color: var(--danger-red); font-weight: 700; }
/* REMPLACEZ LES ANCIENNES RÈGLES PAR CELLES-CI à la fin de style.css */

.distribution-row {
    display: flex;
    align-items: center;
    gap: 0.75rem; /* Espace entre les éléments */
    margin-bottom: 0.8rem;
}

.distribution-row label {
    flex-basis: 45%; /* Donne une largeur de base au nom de l'aliment */
    flex-shrink: 0; /* Empêche le nom de se réduire */
}

.distribution-row input {
    flex-grow: 1; /* Le champ de saisie prend la place restante */
    padding-right: 1rem; /* On garde une petite marge à droite */
    text-align: right;
}

.input-unit {
    color: var(--text-muted);
}

.btn-delete-ration-item {
    background: none;
    border: none;
    color: var(--danger-red);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.4rem;
    line-height: 1;
}
.btn-delete-ration-item:hover {
    background-color: rgba(231, 76, 60, 0.1);
    border-radius: var(--border-radius-btn);
}
.total-lot { color: var(--text-muted); font-size: 0.9em; margin-left: 0.5rem; }
/* Ajoutez ceci à la fin de style.css */
.distribution-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Deux colonnes de largeur égale */
    gap: 2rem; /* Espace entre les colonnes */
}

.distribution-column .species-title {
    margin-top: 0;
}

/* Pour les écrans plus petits (mobiles) */
@media (max-width: 992px) {
    .distribution-grid {
        grid-template-columns: 1fr; /* Une seule colonne */
    }
}
/* Ajout à la fin de style.css */
.results-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2rem;
}
.results-table th, .results-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
}
.results-table thead {
    background-color: var(--background-light);
}
.summary-container {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-light);
}
.summary-container h4 {
    margin-top: 0;
}

.table-responsive-wrapper {
    overflow-x: auto; /* C'est ce qui crée la barre de défilement horizontale */
    width: 100%;
}

.results-table th, .results-table td {
    white-space: nowrap; /* Empêche le texte de revenir à la ligne dans les cellules */
}

/* Styles pour l'impression / Export PDF */
@media print {
    /* Cacher tous les éléments inutiles */
    body > header, 
    .tab-nav,
    #gestion, /* On cache l'onglet de gestion */
    .filters-container, /* On cache les filtres */
    #btn-print-history, /* On cache le bouton d'impression lui-même */
    .btn-delete-history, /* On cache les boutons poubelle */
    #historique-summary /* On cache le résumé pour ne garder que le tableau */
    {
        display: none !important;
    }

    /* S'assurer que le contenu de l'historique est bien visible */
    main {
        padding: 0;
        margin: 0;
    }

    #historique {
        display: block !important; /* Force l'affichage de l'onglet historique */
    }

    /* Retirer les styles de "carte" pour que ça prenne toute la page */
    .card {
        box-shadow: none;
        border: none;
        padding: 0;
    }

    /* Styles pour le tableau */
    .results-table {
        font-size: 10pt; /* Une taille de police adaptée au papier */
        width: 100%;
        border: 1px solid #ccc; /* Ajoute une bordure propre */
    }

    .table-responsive-wrapper {
        overflow: visible; /* Très important : annule le scroll pour tout imprimer */
    }
}

/* --- STYLES POUR LE MENU HAMBURGER RESPONSIVE (VERSION 2.0) --- */

/* Style du bouton hamburger */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
    position: relative;
    width: 40px;
    height: 40px;
}

.hamburger-btn span {
    display: block;
    width: 25px;
    height: 3px;
    background-color: var(--text-dark);
    margin: 5px 0;
    transition: all 0.3s ease-in-out;
}

/* Animation du bouton en croix */
.hamburger-btn.is-active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}
.hamburger-btn.is-active span:nth-child(2) {
    opacity: 0;
}
.hamburger-btn.is-active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}


/* Media Query pour tablette et mobile (POINT DE RUPTURE AUGMENTÉ) */
@media (max-width: 1200px) { /* <- Changé de 992px à 1200px pour s'adapter à votre menu */

    header {
        /* On s'assure que le header reste sur une ligne même avec le hamburger */
        flex-direction: row;
        flex-wrap: nowrap; 
        justify-content: space-between;
    }

    .hamburger-btn {
        display: block; /* On affiche le bouton */
    }

    nav#main-nav {
        /* --- CORRECTIONS CLÉS POUR LE MOBILE --- */
        position: fixed; /* On le positionne par rapport à la fenêtre */
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh; /* Toute la hauteur de l'écran */
        background-color: rgba(255, 255, 255, 0.98); /* Fond blanc légèrement transparent */
        backdrop-filter: blur(5px); /* Effet de flou sur le contenu derrière */
        z-index: 1000; /* Pour passer au-dessus de tout le contenu */
        
        /* Logique pour cacher/montrer */
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        
        /* Centrage des éléments à l'intérieur */
        display: flex;
        justify-content: center;
        align-items: center;
    }

    /* Quand le menu est ouvert */
    nav#main-nav.is-open {
        opacity: 1;
        visibility: visible;
    }
    
    nav ul {
        flex-direction: column;
        align-items: center;
        gap: 1rem; /* Espace entre les liens */
        padding: 1rem 0;
    }

    nav a {
        font-size: 1.5rem; /* Police plus grande pour le mobile */
        font-weight: 500;
        padding: 1rem;
    }
    
    /* Style de l'onglet actif sur mobile (plus discret) */
    nav a.active {
        background-color: transparent; /* On retire le fond bleu */
        color: var(--primary-blue);    /* On met le texte en bleu */
        font-weight: 600;
    }
}