:root { --primary: #2563eb; --secondary: #1e293b; --bg: #f3f4f6; --white: #ffffff; }
body { font-family: 'Segoe UI', sans-serif; background: var(--bg); margin: 0; padding: 20px; color: var(--secondary); }
* { box-sizing: border-box; }
a { text-decoration: none; color: var(--primary); } 
a:hover { text-decoration: underline; }

/* Header & Nav */
.header { background: var(--white); padding: 15px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }

/* Forms */
.form-container { background: var(--white); padding: 30px; border-radius: 10px; max-width: 400px; margin: 50px auto; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
input, select { width: 100%; padding: 10px; margin: 8px 0 20px 0; border: 1px solid #ccc; border-radius: 5px; }
.btn { background: var(--primary); color: white; padding: 10px 15px; border-radius: 5px; border: none; cursor: pointer; display: inline-block; text-align: center; }
.btn:hover { background: #1d4ed8; text-decoration: none; }
.btn-danger { background: #ef4444; color: white; }

/* Recherche */
.search-bar { background: var(--white); padding: 20px; border-radius: 8px; margin-bottom: 30px; display: flex; gap: 10px; }
.search-input { flex-grow: 1; margin: 0; }

/* --- GRILLE DES PRODUITS (Layout) --- */
.product-grid {
    display: grid;
    /* Cela crée des colonnes automatiques de minimum 250px */
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 30px;
    padding: 20px 0;
}

/* --- LA CARTE (Conteneur du produit) --- */
.card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    overflow: hidden; /* Empêche l'image de dépasser les bords ronds */
    display: flex;
    flex-direction: column; /* Pour aligner image et texte verticalement */
    transition: transform 0.2s;
}

.card:hover {
    transform: translateY(-5px); /* Petit effet de levier au survol */
}

/* --- L'IMAGE (La correction est ici) --- */
.card-img {
    width: 100%;        /* Prend toute la largeur de la carte */
    height: 200px;      /* Force une hauteur fixe (ex: 200px) */
    object-fit: contain;  /* Coupe l'image proprement sans la déformer */
    display: block;
}

/* --- LE CORPS DE LA CARTE --- */
.card-body {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Pousse le bouton vers le bas pour qu'ils soient tous alignés */
}

/* Tables Admin */
table { width: 100%; border-collapse: collapse; background: white; margin-top: 20px; }
th, td { padding: 10px; border-bottom: 1px solid #ddd; text-align: left; }
th { background: var(--secondary); color: white; }
/* --- Styles pour la Galerie et l'Édition --- */
.gallery-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.gallery-item { position: relative; width: 100px; height: 100px; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; border-radius: 5px; border: 1px solid #ddd; }
.btn-delete-img {
    position: absolute; top: -5px; right: -5px;
    background: red; color: white; border-radius: 50%;
    width: 20px; height: 20px; text-align: center; line-height: 20px;
    font-size: 12px; cursor: pointer; text-decoration: none;
}
.main-image-preview { width: 150px; height: 150px; object-fit: cover; margin-bottom: 10px; border-radius: 8px; border: 2px solid #2563eb; }
/* --- RESPONSIVE DESIGN (MOBILE) --- */

/* Règle pour les écrans de moins de 768px (Tablettes et Mobiles) */
@media screen and (max-width: 768px) {

    /* 1. Le Corps général */
    body {
        padding: 10px; /* Moins de marge sur les côtés */
    }

    /* 2. L'En-tête (Header) */
    .header {
        flex-direction: column; /* Empile le titre et les boutons */
        text-align: center;
        gap: 15px;
    }
    
    .header div {
        display: flex;
        flex-direction: column; /* Empile les boutons (Panier, Admin, Logout) */
        width: 100%;
        gap: 10px;
    }
    
    .header .btn {
        width: 100%; /* Boutons pleine largeur pour être faciles à cliquer */
        margin: 0 !important;
    }

    /* 3. La page Détail Produit */
    .form-container {
        flex-direction: column; /* L'image passe AU-DESSUS du texte */
    }
    
    .form-container > div {
        width: 100% !important; /* Force la largeur à 100% */
        min-width: 0 !important;
    }
    
    /* On réduit la hauteur de l'image principale sur mobile */
    #mainImage {
        height: 250px !important; 
    }

    /* 4. La Barre de recherche */
    .search-bar {
        flex-direction: column;
    }
    
    .search-bar input, 
    .search-bar select, 
    .search-bar button {
        width: 100% !important;
        margin: 5px 0;
    }

    /* 5. Les Tableaux (Admin et Panier) */
    /* Astuce : on rend le tableau scrollable horizontalement */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    /* 6. Grille produits */
    .product-grid {
        grid-template-columns: 1fr; /* 1 seule colonne sur mobile (optionnel) */
        /* Ou laissez auto-fill si vous voulez 2 colonnes sur les gros mobiles */
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); 
        gap: 15px;
    }
    
    .card-img {
        height: 180px; /* Images un peu moins hautes sur mobile */
    }
}
/* --- BOUTON FILTRE (TOGGLE) --- */
.btn-filter-toggle {
    background-color: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%; /* Pleine largeur sur mobile */
    justify-content: center;
    transition: background 0.2s;
}

.btn-filter-toggle:hover {
    background-color: #e2e8f0;
}

/* --- VOLET DÉROULANT (Caché par défaut) --- */
#filterPanel {
    display: none; /* Caché par défaut */
    margin-top: 15px;
    padding: 15px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}
/* --- TAGS COMPACTS (MINI) --- */
.tag-label {
    display: inline-flex;
    align-items: center;
    background: #f8fafc;
    
    /* 1. MOINS D'ESPACE INTERNE (Haut/Bas: 3px, Gauche/Droite: 8px) */
    padding: 3px 8px;
    
    border: 1px solid #cbd5e1;
    
    /* 2. ARRONDIS PLUS PETITS */
    border-radius: 12px;
    
    cursor: pointer;
    
    /* 3. TEXTE PLUS PETIT */
    font-size: 0.75rem; /* Environ 12px */
    font-weight: 500;
    
    transition: all 0.2s;
    user-select: none;
    line-height: 1; /* Empêche le tag d'être trop haut */
}

/* Style quand c'est coché (reste bleu) */
.tag-label:has(input:checked) {
    background-color: #eff6ff;
    border-color: #2563eb;
    color: #2563eb;
}

/* 4. RÉDUIRE LA CHECKBOX À L'INTÉRIEUR */
.tag-label input {
    margin: 0 4px 0 0 !important;
    transform: scale(0.8); /* Réduit la case à 80% de sa taille */
    vertical-align: middle;
}
/* --- MENU ADMIN (ONGLETS) --- */
.admin-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 10px;
    flex-wrap: wrap;
}

.admin-nav a {
    text-decoration: none;
    color: #64748b;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    transition: all 0.2s;
}

.admin-nav a:hover {
    background: #e2e8f0;
}

/* Style pour l'onglet actif (Celui sur lequel on est) */
.admin-nav a.active {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}
/* --- AMÉLIORATION TEXTAREA (Description) --- */
textarea {
    width: 100%;
    min-height: 150px; /* Force une hauteur minimale confortable */
    padding: 15px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-family: inherit;
    resize: vertical; /* Permet à l'utilisateur d'agrandir vers le bas si besoin */
    line-height: 1.5;
}