/* ========================================
 * RECIPE-CARD.CSS
 * Styles centralisés pour les cartes de recettes
 * Utilisé par : page-accueil, page-recette-similar, etc.
 * Version: 1.0
 * ======================================== */

/* ======================================
 * STRUCTURE DE BASE DE LA CARTE
 * ====================================== */

.recipe-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;
    position: relative;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    height: 100%;
}

.recipe-card:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.dark-mode .recipe-card {
    background-color: var(--card-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.dark-mode .recipe-card:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

/* ======================================
 * IMAGE DE LA RECETTE
 * ====================================== */

.recipe-image {
    height: 280px; /* Hauteur par défaut centralisée */
    overflow: hidden;
    position: relative;
    z-index: 10;
}

/* Dégradé sombre sur l'image */
.recipe-image::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0.02) 30%,
        rgba(0, 0, 0, 0.1) 50%,
        rgba(0, 0, 0, 0.3) 70%,
        rgba(0, 0, 0, 0.5) 85%,
        rgba(0, 0, 0, 0.7) 100%
    );
    pointer-events: none;
    z-index: 1;
    transition: opacity 0.3s ease;
}

.recipe-card:hover .recipe-image::after {
    opacity: 0.9;
}

.recipe-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.recipe-card:hover .recipe-image img {
    transform: scale(1.08);
}

/* ======================================
 * TAGS DE RECETTE
 * ====================================== */

.recipe-tags {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 60px; /* Espace pour le bouton favori (40px + 10px margin + 10px sécurité) */
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    z-index: 2;
}

/* Le conteneur des tags reste toujours présent pour simplifier */
/* Il sera visuellement invisible s'il est vide grâce à son positionnement absolu */

.recipe-tag {
    background-color: rgba(107, 212, 182, 1.0);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease;
}

.recipe-card:hover .recipe-tag {
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}

/* ======================================
 * SYSTÈME DE NOTATION SIMPLIFIÉ
 * Format: ★ 3,7 (3 avis)
 * Si la recette n'a aucun avis, on masque complètement le badge.
 * ====================================== */

/* Masquage unifié des badges "0 avis"
   Tous les renderers (PHP helpers + 11 fichiers JS) injectent un
   <span class="rating-value no-rating">(0 avis)</span> quand la recette
   n'a aucune note. Une seule règle :has() cible ce cas partout sans
   avoir à modifier chaque fichier. Compatible Chrome 105+, Safari 15.4+,
   Firefox 121+.
   :empty attrape aussi les wrappers vides (helpers PHP qui retournent ''). */
.recipe-rating:has(.no-rating),
.recipe-rating:empty {
    display: none !important;
}

.recipe-image .recipe-rating {
    position: absolute;
    bottom: 15px;
    left: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 2;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 12px;
    border-radius: 20px;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Icône étoile Font Awesome */
.recipe-rating .star-icon {
    font-size: 18px;
    line-height: 1;
}

.recipe-rating .star-icon.filled {
    color: #FFD700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.recipe-rating .star-icon.empty {
    color: rgba(255, 255, 255, 0.6);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Note numérique */
.recipe-rating .rating-note {
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* Nombre d'avis */
.recipe-rating .rating-value {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.85rem;
    font-weight: 500;
    margin-left: 4px;
}

/* Style pour "(0 avis)" */
.recipe-rating .rating-value.no-rating {
    color: rgba(255, 255, 255, 0.7);
}

/* ======================================
 * CONTENU DE LA CARTE
 * ====================================== */

.recipe-content {
    padding: 0;
    background: #ffffff;
    color: #2d3748;
    height: 100%; /* Force le fond à remplir toute la hauteur de la carte */
    display: flex;
    flex-direction: column;
}

.dark-mode .recipe-content {
    background: linear-gradient(135deg, #1E2A3B 0%, #151d2a 100%);
    color: #ffffff;
}

/* ======================================
 * LISERÉ + DÉGRADÉ COLORÉ PAR CATÉGORIE
 * ====================================== */

.recipe-category-bar {
    height: 5px;
    width: 100%;
    background: linear-gradient(to right, #5a6978, #434d56); /* Default */
}

/* Bleu - Boissons & Cocktails */
.cat-boissons .recipe-category-bar { background: linear-gradient(to right, #4AA0D1, #248ABD); }
.cat-boissons .recipe-content { background: linear-gradient(180deg, rgba(74, 160, 209, 0.10) 0%, rgba(255, 255, 255, 1) 100%); }

/* Orange/Pêche - Apéritifs */
.cat-aperitifs .recipe-category-bar { background: linear-gradient(to right, #F78C50, #FABA50); }
.cat-aperitifs .recipe-content { background: linear-gradient(180deg, rgba(247, 140, 80, 0.10) 0%, rgba(255, 255, 255, 1) 100%); }

/* Rouge Corail - Entrées */
.cat-entrees .recipe-category-bar { background: linear-gradient(to right, #F05B5B, #E87A7A); }
.cat-entrees .recipe-content { background: linear-gradient(180deg, rgba(240, 91, 91, 0.10) 0%, rgba(255, 255, 255, 1) 100%); }

/* Vert Olive - Salades */
.cat-salades .recipe-category-bar { background: linear-gradient(to right, #8DBF58, #6A9E3E); }
.cat-salades .recipe-content { background: linear-gradient(180deg, rgba(141, 191, 88, 0.10) 0%, rgba(255, 255, 255, 1) 100%); }

/* Turquoise - Plats principaux */
.cat-plats .recipe-category-bar { background: linear-gradient(to right, #41B3A9, #1F9088); }
.cat-plats .recipe-content { background: linear-gradient(180deg, rgba(65, 179, 169, 0.10) 0%, rgba(255, 255, 255, 1) 100%); }

/* Vert - Accompagnements */
.cat-accompagnements .recipe-category-bar { background: linear-gradient(to right, #6AAE7B, #4B935B); }
.cat-accompagnements .recipe-content { background: linear-gradient(180deg, rgba(106, 174, 123, 0.10) 0%, rgba(255, 255, 255, 1) 100%); }

/* Jaune/Or - Fast-Food */
.cat-fastfood .recipe-category-bar { background: linear-gradient(to right, #F7C833, #EAA80F); }
.cat-fastfood .recipe-content { background: linear-gradient(180deg, rgba(247, 200, 51, 0.10) 0%, rgba(255, 255, 255, 1) 100%); }

/* Orange Brûlé - Petits-Déjeuners */
.cat-petits-dejeuners .recipe-category-bar { background: linear-gradient(to right, #E88D5A, #D96C3F); }
.cat-petits-dejeuners .recipe-content { background: linear-gradient(180deg, rgba(232, 141, 90, 0.10) 0%, rgba(255, 255, 255, 1) 100%); }

/* Violet/Magenta - Desserts */
.cat-desserts .recipe-category-bar { background: linear-gradient(to right, #B35FBC, #C879C8); }
.cat-desserts .recipe-content { background: linear-gradient(180deg, rgba(179, 95, 188, 0.10) 0%, rgba(255, 255, 255, 1) 100%); }

/* Brun / Terre Cuite - Pâtisseries */
.cat-patisseries .recipe-category-bar { background: linear-gradient(to right, #C97B61, #A65C44); }
.cat-patisseries .recipe-content { background: linear-gradient(180deg, rgba(201, 123, 97, 0.10) 0%, rgba(255, 255, 255, 1) 100%); }

/* Rouge Brique - Sauces */
.cat-sauces .recipe-category-bar { background: linear-gradient(to right, #D9534F, #C9302C); }
.cat-sauces .recipe-content { background: linear-gradient(180deg, rgba(217, 83, 79, 0.10) 0%, rgba(255, 255, 255, 1) 100%); }

/* Gris - Bases */
.cat-bases .recipe-category-bar { background: linear-gradient(to right, #84939E, #6B7A85); }
.cat-bases .recipe-content { background: linear-gradient(180deg, rgba(132, 147, 158, 0.10) 0%, rgba(255, 255, 255, 1) 100%); }

/* Dark mode : fond sombre avec liseré coloré conservé */
.dark-mode .recipe-content { background: linear-gradient(135deg, #1E2A3B 0%, #151d2a 100%); }

/* Dark mode : dégradés subtils avec les couleurs de catégorie */
.dark-mode .cat-boissons .recipe-content { background: linear-gradient(180deg, rgba(74, 160, 209, 0.15) 0%, rgba(30, 42, 59, 1) 100%); }
.dark-mode .cat-aperitifs .recipe-content { background: linear-gradient(180deg, rgba(247, 140, 80, 0.15) 0%, rgba(30, 42, 59, 1) 100%); }
.dark-mode .cat-entrees .recipe-content { background: linear-gradient(180deg, rgba(240, 91, 91, 0.15) 0%, rgba(30, 42, 59, 1) 100%); }
.dark-mode .cat-salades .recipe-content { background: linear-gradient(180deg, rgba(141, 191, 88, 0.15) 0%, rgba(30, 42, 59, 1) 100%); }
.dark-mode .cat-plats .recipe-content { background: linear-gradient(180deg, rgba(65, 179, 169, 0.15) 0%, rgba(30, 42, 59, 1) 100%); }
.dark-mode .cat-accompagnements .recipe-content { background: linear-gradient(180deg, rgba(106, 174, 123, 0.15) 0%, rgba(30, 42, 59, 1) 100%); }
.dark-mode .cat-fastfood .recipe-content { background: linear-gradient(180deg, rgba(247, 200, 51, 0.15) 0%, rgba(30, 42, 59, 1) 100%); }
.dark-mode .cat-petits-dejeuners .recipe-content { background: linear-gradient(180deg, rgba(232, 141, 90, 0.15) 0%, rgba(30, 42, 59, 1) 100%); }
.dark-mode .cat-desserts .recipe-content { background: linear-gradient(180deg, rgba(179, 95, 188, 0.15) 0%, rgba(30, 42, 59, 1) 100%); }
.dark-mode .cat-patisseries .recipe-content { background: linear-gradient(180deg, rgba(201, 123, 97, 0.15) 0%, rgba(30, 42, 59, 1) 100%); }
.dark-mode .cat-sauces .recipe-content { background: linear-gradient(180deg, rgba(217, 83, 79, 0.15) 0%, rgba(30, 42, 59, 1) 100%); }
.dark-mode .cat-bases .recipe-content { background: linear-gradient(180deg, rgba(132, 147, 158, 0.15) 0%, rgba(30, 42, 59, 1) 100%); }
.dark-mode .cat-default .recipe-content { background: linear-gradient(135deg, #1E2A3B 0%, #151d2a 100%); }

.recipe-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 15px 20px 20px 20px;
    min-height: 0px; /* Cartes simplifiées - la hauteur est gérée par .recipe-content */
}

.recipe-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-color);
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 3rem; /* Hauteur fixe pour 2 lignes - ajusté pour uniformiser */
}

/* ======================================
 * INFORMATIONS (TEMPS & DIFFICULTÉ)
 * SECTION DÉSACTIVÉE - Cartes simplifiées
 * ====================================== */

/* Section supprimée - recipe-info désactivée */
/*
.recipe-info {
    display: flex;
    justify-content: space-between;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: auto;
    padding: 0;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 15px 20px;
    color: #e0e2e5;
    font-size: 0.9rem;
}

.info-item:first-child {
    margin-right: auto;
    justify-content: flex-start;
}

.info-item:last-child {
    margin-left: auto;
    justify-content: flex-end;
}

.info-item svg,
.icon_time, .icon_category, .icon_level {
    width: 18px;
    height: 18px;
    position: relative;
    margin-right: 4px;
    flex-shrink: 0;
}

.info-item svg.icon_time path,
.icon_time path {
    fill: #FF3C3C;
}

.dark-mode .info-item svg.icon_time path,
.dark-mode .icon_time path {
    fill: #FF6B6B;
}

.info-item svg[fill="#009900"] path:first-child {
}

.info-item svg[fill="#FF8C00"] path:first-child {
}

.info-item svg[fill="#DC143C"] path:first-child {
}
*/

/* ======================================
 * MEDIA QUERIES - DESKTOP LARGE
 * Au-dessus de 1200px : 280px
 * ====================================== */

@media (min-width: 1201px) {
    .recipe-image {
        height: 280px;
    }
}

/* ======================================
 * MEDIA QUERIES - DESKTOP STANDARD
 * 1025px - 1200px : 280px
 * ====================================== */

@media (max-width: 1200px) and (min-width: 1025px) {
    .recipe-image {
        height: 280px;
    }
    
    .recipe-rating .star,
    .recipe-rating .star.partial {
        font-size: 20px;
        width: 20px;
        height: 20px;
        margin: 0 !important;
    }


    .recipe-rating .rating-value {
        font-size: 0.9rem;
        padding: 2px 7px;
    }
}

/* ======================================
 * MEDIA QUERIES - TABLETTE LARGE
 * 769px - 1024px : 280px
 * ====================================== */

@media (max-width: 1024px) and (min-width: 769px) {
    .recipe-image {
        height: 280px;
    }
    
    .recipe-rating .star,
    .recipe-rating .star.partial {
        font-size: 19px;
        width: 19px;
        height: 19px;
        margin: 0 !important;
    }

    .recipe-rating .stars {
        gap: 2px;
    }
    
    .recipe-rating .rating-value {
        font-size: 0.9rem;
        padding: 2px 7px;
    }
}

/* ======================================
 * MEDIA QUERIES - TABLETTE
 * 481px - 768px : 280px
 * ====================================== */

@media (max-width: 768px) and (min-width: 481px) {
    .recipe-image {
        height: 280px;
    }

    /* Styles .info-item supprimés (section désactivée) */

    .recipe-rating .star,
    .recipe-rating .star.partial {
        font-size: 18px;
        width: 18px;
        height: 18px;
        margin: 0 !important;
    }


    .recipe-rating .stars {
        gap: 1px;
    }

    .recipe-rating .rating-value {
        font-size: 0.85rem;
        padding: 1px 6px;
    }
}

/* ======================================
 * MEDIA QUERIES - MOBILE
 * ====================================== */

@media (max-width: 480px) and (min-width: 321px) {
    .recipe-image {
        height: 210px;
    }

    .recipe-tags {
        top: 8px;
        left: 8px;
        gap: 4px;
    }

    .recipe-tag {
        padding: 3px 8px;
        font-size: 0.7rem;
    }

    .recipe-header {
        padding: 8px 10px;
        min-height: 55px;
    }

    .recipe-title {
        font-size: 0.9rem;
    }

    /* Styles .recipe-info et .info-item supprimés (section désactivée) */

    /* Système d'étoiles */
    .recipe-image .recipe-rating {
        bottom: 10px;
        left: 10px;
        gap: 4px;
    }

    .recipe-rating .stars {
        gap: 1px;
    }

    .recipe-rating .star,
    .recipe-rating .star.partial {
        font-size: 17px;
        width: 17px;
        height: 17px;
        margin: 0 !important;
    }



    .recipe-rating .rating-value {
        font-size: 0.85rem;
        padding: 1px 6px;
    }
}

/* ======================================
 * MEDIA QUERIES - TRÈS PETIT MOBILE
 * 0px - 320px : 210px
 * ====================================== */

@media (max-width: 320px) {
    .recipe-image {
        height: 210px;
    }

    .recipe-header {
        padding: 15px 20px 10px 20px;
    }

    /* Styles .recipe-info et .info-item supprimés (section désactivée) */

    .recipe-title {
        font-size: 1.05rem;
    }

    .recipe-tag {
        padding: 5px 12px;
        font-size: 0.8rem;
    }

    .recipe-rating .star,
    .recipe-rating .star.partial {
        font-size: 19px;
        width: 19px;
        height: 19px;
        margin: 0 !important;
    }

    .recipe-rating .stars {
        gap: 2px;
    }

    .recipe-rating .rating-value {
        font-size: 0.9rem;
        padding: 2px 6px;
    }
}

/* ============================================
   PLACEHOLDERS POUR CHARGEMENT AJAX
============================================ */

/* Animation de shimmer */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.recipe-card-placeholder,
.ingredient-card-placeholder {
    pointer-events: none;
}

/* Structure spécifique pour les placeholders dans la section similaires */
.recette-similar-section .recipe-card-placeholder .recipe-card-link {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.recipe-card-placeholder .placeholder-image,
.ingredient-card-placeholder .placeholder-image {
    width: 100%;
    height: 100%;
    min-height: 200px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.dark-mode .recipe-card-placeholder .placeholder-image,
.dark-mode .ingredient-card-placeholder .placeholder-image {
    background: linear-gradient(90deg, #3a3a3a 25%, #4a4a4a 50%, #3a3a3a 75%);
    background-size: 200% 100%;
}

.recipe-card-placeholder .placeholder-rating {
    width: 100px;
    height: 28px;
    background: linear-gradient(90deg, rgba(255,255,255,0.3) 25%, rgba(255,255,255,0.5) 50%, rgba(255,255,255,0.3) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 20px;
}

.recipe-card-placeholder .placeholder-title {
    width: 80%;
    height: 48px; /* Même min-height que .recipe-title (3rem ≈ 48px) */
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin: 0;
}

.dark-mode .recipe-card-placeholder .placeholder-title {
    background: linear-gradient(90deg, #3a3a3a 25%, #4a4a4a 50%, #3a3a3a 75%);
    background-size: 200% 100%;
}

.ingredient-card-placeholder .placeholder-text {
    width: 70%;
    height: 16px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin: 0 auto;
}

.dark-mode .ingredient-card-placeholder .placeholder-text {
    background: linear-gradient(90deg, #3a3a3a 25%, #4a4a4a 50%, #3a3a3a 75%);
    background-size: 200% 100%;
}

/* Structure des placeholders */
.recipe-card-placeholder .recipe-image {
    position: relative;
    height: 280px; /* Même hauteur que les vraies cartes */
}

.recipe-card-placeholder .recipe-rating {
    position: absolute;
    bottom: 15px;
    left: 15px;
}

.recipe-card-placeholder .recipe-content {
    padding: 15px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
}

.dark-mode .recipe-card-placeholder .recipe-content {
    background: linear-gradient(135deg, #1E2A3B 0%, #151d2a 100%);
}

.recipe-card-placeholder .recipe-header {
    padding: 15px 20px 20px 20px;
}

/* Responsive placeholders - même breakpoints que les vraies cartes */
@media (max-width: 480px) {
    .recipe-card-placeholder .recipe-image {
        height: 210px;
    }
    
    .recipe-card-placeholder .recipe-header {
        padding: 8px 10px;
    }
}

.ingredient-card-placeholder .ingredient-img {
    height: 155px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ingredient-card-placeholder .ingredient-name {
    padding: 15px 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ======================================
 * BOUTON FAVORI (CŒUR) SUR LES CARTES
 * Position : haut droite de l'image
 * Toujours visible, ne masque pas les tags
 * ====================================== */

.recipe-card .btn-favorite {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(45, 55, 72, 0.7);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15; /* Au-dessus de .recipe-image (z-index: 10) */
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
}

/* Hover du bouton */
.recipe-card .btn-favorite:hover {
    background: rgba(45, 55, 72, 0.9);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Icône cœur - état non liké */
.recipe-card .btn-favorite .heart-icon {
    font-size: 20px;
    color: rgba(255, 255, 255, 0.9);
    transition: all 0.2s ease;
    margin-top: 1px;
}

/* Icône cœur - état liké */
.recipe-card .btn-favorite.is-liked .heart-icon {
    color: #ff6b6b;
}

/* Animation au clic */
.recipe-card .btn-favorite:active {
    transform: scale(0.95);
}

/* Animation de pulsation quand on like */
@keyframes heartPulse {
    0% { transform: scale(1); }
    25% { transform: scale(1.3); }
    50% { transform: scale(1); }
    75% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.recipe-card .btn-favorite.just-liked .heart-icon {
    animation: heartPulse 0.4s ease;
}

/* Mobile : bouton légèrement plus petit */
@media (max-width: 480px) {
    .recipe-card .btn-favorite {
        width: 36px;
        height: 36px;
    }
    
    .recipe-card .btn-favorite .heart-icon {
        font-size: 18px;
    }
}
