/**
 * Styles spécifiques pour les cartes d'ingrédients et ustensiles
 * Basé strictement sur page-themes-cards.css
 * Seule différence : fond blanc pour les images (object-fit: contain)
 * 
 * MISE À JOUR : Support des grilles AJAX (#ingredients-grid, #ustensiles-grid)
 */

/* ============================================
   GRILLE CSS POUR AJAX (pas DataTables)
   ============================================ */

#ingredients-grid,
#ustensiles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    width: 100%;
}

/* Responsive : Tablettes (2 colonnes) */
@media (max-width: 1024px) {
    #ingredients-grid,
    #ustensiles-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

/* Responsive : Mobiles (2 colonnes) */
@media (max-width: 480px) {
    #ingredients-grid,
    #ustensiles-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
}

/* ============================================
   STRUCTURE DES CARTES - IDENTIQUE À THEMES
   ============================================ */

/* S'assurer que toutes les cartes ont la même hauteur */
#ingredientsTable .theme-card,
#ustensilesTable .theme-card,
#ingredients-grid .theme-card,
#ustensiles-grid .theme-card {
    background-color: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    height: 100%;
}

#ingredientsTable .theme-card:hover,
#ustensilesTable .theme-card:hover,
#ingredients-grid .theme-card:hover,
#ustensiles-grid .theme-card:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.dark-mode #ingredientsTable .theme-card,
.dark-mode #ustensilesTable .theme-card,
.dark-mode #ingredients-grid .theme-card,
.dark-mode #ustensiles-grid .theme-card {
    background-color: var(--card-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.dark-mode #ingredientsTable .theme-card:hover,
.dark-mode #ustensilesTable .theme-card:hover,
.dark-mode #ingredients-grid .theme-card:hover,
.dark-mode #ustensiles-grid .theme-card:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

/* ============================================
   IMAGE - FOND BLANC + CENTRAGE
   ============================================ */

/* Container de l'image - DIFFÉRENCE: fond blanc au lieu de cover */
#ingredientsTable .theme-image,
#ustensilesTable .theme-image,
#ingredients-grid .theme-image,
#ustensiles-grid .theme-image {
    height: 280px;
    overflow: hidden;
    position: relative;
    z-index: 10;
    /* SPÉCIFICITÉ INGRÉDIENTS/USTENSILES: fond blanc */
    background-color: #FFF;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Image pleine taille - DIFFÉRENCE: contain au lieu de cover */
#ingredientsTable .theme-image img,
#ustensilesTable .theme-image img,
#ingredients-grid .theme-image img,
#ustensiles-grid .theme-image img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* DIFFÉRENCE: contain au lieu de cover */
    object-position: center;
    transition: var(--transition);
}

#ingredientsTable .theme-card:hover .theme-image img,
#ustensilesTable .theme-card:hover .theme-image img,
#ingredients-grid .theme-card:hover .theme-image img,
#ustensiles-grid .theme-card:hover .theme-image img {
    transform: scale(1.08);
}

/* Mode sombre - GARDER LE FOND BLANC pour ingrédients/ustensiles */
.dark-mode #ingredientsTable .theme-image,
.dark-mode #ustensilesTable .theme-image,
.dark-mode #ingredients-grid .theme-image,
.dark-mode #ustensiles-grid .theme-image {
    background-color: #FFF;
}

/* ============================================
   BADGES - IDENTIQUE À THEMES
   ============================================ */

/* Conteneur des badges - aligné à gauche comme themes.php */
#ingredientsTable .theme-badges,
#ustensilesTable .theme-badges,
#ingredients-grid .theme-badges,
#ustensiles-grid .theme-badges {
    position: absolute !important;
    top: 10px !important;
    left: 10px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 5px !important;
    z-index: 20 !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Badge de date - violet */
#ingredientsTable .theme-badge.date-badge,
#ustensilesTable .theme-badge.date-badge,
#ingredients-grid .theme-badge.date-badge,
#ustensiles-grid .theme-badge.date-badge {
    background-color: rgba(162, 93, 220, 0.95);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
}

/* Badge de tri unifié */
#ingredientsTable .theme-badge.badge-sort,
#ustensilesTable .theme-badge.badge-sort,
#ingredients-grid .theme-badge.badge-sort,
#ustensiles-grid .theme-badge.badge-sort {
    background-color: rgba(162, 93, 220, 0.95) !important;
    padding: 6px 12px !important;
    border-radius: 20px !important;
    color: white !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 10 !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15) !important;
    backdrop-filter: blur(8px) !important;
    position: relative !important;
}

/* Badge compteur de recettes - Vert émeraude */
#ingredientsTable .theme-badge.recipe-count-badge,
#ustensilesTable .theme-badge.recipe-count-badge,
#ingredients-grid .theme-badge.recipe-count-badge,
#ustensiles-grid .theme-badge.recipe-count-badge {
    background-color: rgb(5, 150, 105);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
}

/* Badge de prix - bleu ciel */
#ingredientsTable .theme-badge.price-badge,
#ustensilesTable .theme-badge.price-badge,
#ingredients-grid .theme-badge.price-badge,
#ustensiles-grid .theme-badge.price-badge {
    background-color: rgba(52, 152, 219, 0.95);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
}

/* ============================================
   CONTENU DE LA CARTE - IDENTIQUE À THEMES
   ============================================ */

/* Contenu de la carte */
#ingredientsTable .theme-content,
#ustensilesTable .theme-content,
#ingredients-grid .theme-content,
#ustensiles-grid .theme-content {
    padding: 15px 20px 20px 20px;
    background-color: #1E2A3B;
    color: #ffffff;
    display: flex;
    flex-direction: column;
}

.dark-mode #ingredientsTable .theme-content,
.dark-mode #ustensilesTable .theme-content,
.dark-mode #ingredients-grid .theme-content,
.dark-mode #ustensiles-grid .theme-content {
    background-color: var(--card-bg);
}

/* Titre - IDENTIQUE À THEMES */
#ingredientsTable .theme-content h3,
#ustensilesTable .theme-content h3,
#ingredients-grid .theme-content h3,
#ustensiles-grid .theme-content h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: white;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    min-height: 3rem;
}

.dark-mode #ingredientsTable .theme-card:hover .theme-content h3,
.dark-mode #ustensilesTable .theme-card:hover .theme-content h3,
.dark-mode #ingredients-grid .theme-card:hover .theme-content h3,
.dark-mode #ustensiles-grid .theme-card:hover .theme-content h3 {
    color: var(--primary-color);
}

/* ============================================
   MESSAGES "AUCUN RÉSULTAT"
   ============================================ */

.ingredients-container #no-ingredients-message,
.ustensiles-container #no-ustensiles-message,
.articles-container #no-articles-message,
.recipes-container #no-themes-message,
.ingredients-container .no-recipes-message,
.ustensiles-container .no-recipes-message,
.articles-container .no-recipes-message,
.recipes-container .no-recipes-message {
    text-align: center !important;
    padding: 80px 20px !important;
    color: #666 !important;
    background-color: rgba(0, 0, 0, 0.03) !important;
    border-radius: 8px !important;
    margin: 20px 0 !important;
}

.ingredients-container #no-ingredients-message p,
.ustensiles-container #no-ustensiles-message p,
.articles-container #no-articles-message p,
.recipes-container #no-themes-message p,
.ingredients-container .no-recipes-message p,
.ustensiles-container .no-recipes-message p,
.articles-container .no-recipes-message p,
.recipes-container .no-recipes-message p {
    font-size: 18px !important;
    margin: 0 !important;
}

.dark-mode .ingredients-container #no-ingredients-message,
.dark-mode .ustensiles-container #no-ustensiles-message,
.dark-mode .articles-container #no-articles-message,
.dark-mode .recipes-container #no-themes-message,
.dark-mode .ingredients-container .no-recipes-message,
.dark-mode .ustensiles-container .no-recipes-message,
.dark-mode .articles-container .no-recipes-message,
.dark-mode .recipes-container .no-recipes-message {
    color: #bbb !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
}

/* Masquer complètement les messages DataTables par défaut */
.dataTables_empty {
    display: none !important;
}

/* ============================================
   RESPONSIVE - IDENTIQUE À THEMES
   ============================================ */

/* Tablettes et mobiles (321px à 768px) : 2 colonnes */
@media (max-width: 768px) and (min-width: 321px) {
    #ingredientsTable .theme-image,
    #ustensilesTable .theme-image,
    #ingredients-grid .theme-image,
    #ustensiles-grid .theme-image {
        height: 210px;
    }

    #ingredientsTable .theme-content,
    #ustensilesTable .theme-content,
    #ingredients-grid .theme-content,
    #ustensiles-grid .theme-content {
        padding: 15px;
    }

    #ingredientsTable .theme-content h3,
    #ustensilesTable .theme-content h3,
    #ingredients-grid .theme-content h3,
    #ustensiles-grid .theme-content h3 {
        font-size: 1.05rem;
    }
}

/* Très petits écrans (320px et moins) : 1 colonne */
@media (max-width: 320px) {
    #ingredientsTable .theme-image,
    #ustensilesTable .theme-image,
    #ingredients-grid .theme-image,
    #ustensiles-grid .theme-image {
        height: 180px;
    }

    #ingredientsTable .theme-content,
    #ustensilesTable .theme-content,
    #ingredients-grid .theme-content,
    #ustensiles-grid .theme-content {
        padding: 12px;
    }

    #ingredientsTable .theme-content h3,
    #ustensilesTable .theme-content h3,
    #ingredients-grid .theme-content h3,
    #ustensiles-grid .theme-content h3 {
        font-size: 0.9rem;
    }
}
