/* Base styles */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding-bottom: 80px; /* Espace pour le footer fixe sur toutes les tailles d'écran */
    background-color: #f4f4f4;
    color: #333;
}

/* Header - Masqué par défaut (mobile-first) et visible au survol sur desktop */
header {
    background-color: #333;
    color: white;
    padding: 1em 0;
    text-align: center;
    /* Styles pour la visibilité conditionnelle */
    display: none; /* Masqué par défaut pour les écrans < 610px */
    opacity: 0; /* Initialement invisible sur desktop */
    transition: opacity 0.3s ease-in-out; /* Animation douce */
}
/* Afficher le header au survol sur desktop */
@media (min-width: 610px) {
    header {
        display: block; /* Affiché comme un bloc sur desktop */
    }
    header:hover {
        opacity: 1; /* Rendre visible au survol */
    }
}


header h1 {
    margin: 0;
}
header nav ul { /* Style pour la navigation du header */
    list-style: none;
    padding: 0;
    text-align: center;
    margin-top: 10px;
}
header nav ul li {
    display: inline;
    margin: 0 15px;
}
header nav ul li a {
    color: white;
    text-decoration: none;
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 5px;
    transition: background-color 0.2s ease-in-out;
}
header nav ul li a:hover,
header nav ul li a.active {
    background-color: #555;
}


/* Main content */
main {
    padding: 20px;
    text-align: center;
    padding-top: 10px; /* Ajuste si le header est plus petit */
}
h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
}

/* Products Container */
#products-container {
    display: grid;
    grid-template-columns: 1fr; /* Mobile-first: une seule colonne par défaut */
    gap: 25px;
    padding: 20px;
    max-width: 1200px;
    margin: 20px auto;
    background-color: #f8f8f8;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

/* Product Card Styles */
.product-card {
    background-color: #ffffff;
    border-radius: 10px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    
    width: 80%; /* Occupe 80% de la largeur disponible */
    margin: 0 auto; /* Centre la carte produit */
    max-width: 600px; /* Conserve une largeur maximale pour éviter qu'elle ne soit trop large */
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

.product-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-bottom: 1px solid #eee;
}

.product-card-content {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-card h3 {
    font-size: 1.3em;
    color: #333;
    margin-top: 0;
    margin-bottom: 10px;
    min-height: 2.6em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-card p.description {
    font-size: 0.9em;
    color: #666;
    line-height: 1.5;
    margin-bottom: 10px;
    flex-grow: 1;
    max-height: 4.5em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
}

.product-card .price {
    font-size: 1.4em;
    color: #007bff;
    font-weight: bold;
    margin-bottom: 10px;
}

.product-card .stock {
    font-size: 0.85em;
    color: #888;
    margin-bottom: 15px;
}

.product-card button {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 12px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.2s ease-in-out;
    width: 100%;
}

.product-card button:hover {
    background-color: #218838;
}

.product-card button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* Loading/Error messages */
#loading-message, #error-message {
    text-align: center;
    font-size: 1.1em;
    color: #555;
    padding: 30px;
}
#error-message {
    color: #dc3545;
}

/* Footer Navigation - Maintenant fixe et visible sur toutes les tailles d'écran */
footer {
    background-color: #333;
    color: white;
    text-align: center;
    padding: 0;
    position: fixed; /* Fixe le footer en bas */
    bottom: 0;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    display: flex; /* Utilise flexbox pour les éléments de navigation */
    justify-content: space-around; /* Distribue les éléments uniformément */
    align-items: center;
    height: 70px; /* Hauteur du footer nav */
}

.footer-nav {
    display: flex;
    flex-wrap: wrap; /* Permet aux éléments de passer à la ligne */
    width: 100%;
    height: 100%;
    justify-content: space-around;
    align-items: center;
}

.footer-nav a {
    flex: 1 1 auto;
    min-width: 100px;
    max-width: 20%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-decoration: none;
    font-size: 0.75em;
    padding: 5px 0;
    transition: background-color 0.2s ease-in-out;
    height: 100%;
    box-sizing: border-box;
}

.footer-nav a:hover,
.footer-nav a.active {
    background-color: #555;
}

.footer-nav .icon {
    font-size: 1.5em;
    margin-bottom: 3px;
}

/* Masquer le texte de copyright du footer car le nav footer est toujours là */
.desktop-footer-text {
    display: none !important;
}


/* Media query pour les très petits écrans (pour le footer) */
@media (max-width: 450px) {
    .footer-nav a {
        font-size: 0.7em;
        min-width: 80px;
    }
    .footer-nav .icon {
        font-size: 1.3em;
    }
}

/* Media query pour tablettes et ordinateurs (> 610px) */
@media (min-width: 610px) {
    /* Le padding-bottom du body reste inchangé (80px) */
    
    /* Le header est maintenant géré par ses propres règles par défaut et hover */
    /* header reste `display: block` et nav aussi */
    
    /* Pour les écrans plus grands : affichage en grille */
    #products-container {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }

    .product-card {
        max-width: none; /* Supprime la largeur max sur les grands écrans */
        width: 80%; /* Applique la largeur de 80% sur les écrans plus grands */
        margin: initial; /* Supprime le centrage automatique sur les grands écrans */
    }

    /* Le footer reste fixe et le footer-nav reste visible, pas de changement de position */
    footer {
        /* Pas de changement de position ou de display ici, il reste fixed flex */
        padding: 0; /* Assure pas de padding supplémentaire */
        height: 70px; /* Maintient la hauteur fixe */
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2); /* Maintient l'ombre */
    }
    /* .footer-nav n'est plus masqué sur desktop */
}

/* Media query additionnelle pour les écrans > 768px */
@media (min-width: 768px) {
    .product-card {
        width: 90%;
    }
}