/**
 * Styles pour la modale de filtres par ingrédients (page d'accueil)
 * Permet d'inclure ou exclure des ingrédients de la recherche
 */

/* ============================================
   MODALE INGRÉDIENTS - Structure générale
============================================ */

.ingredients-modal {
    max-width: 600px;
}

.ingredients-modal .modal-body {
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* ============================================
   BARRE DE RECHERCHE D'INGRÉDIENTS
============================================ */

.ingredients-search-container {
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
    flex-shrink: 0;
}

.dark-mode .ingredients-search-container {
    background: #2a2a2a;
    border-bottom-color: #444;
}

.ingredients-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    padding: 0 15px;
    transition: all 0.2s ease;
}

.dark-mode .ingredients-search-wrapper {
    background: #3a3a3a;
    border-color: #555;
}

.ingredients-search-wrapper:focus-within {
    border-color: var(--primary-color, #FF6B6B);
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.15);
}

.ingredients-search-icon {
    color: #999;
    font-size: 1rem;
    flex-shrink: 0;
}

.dark-mode .ingredients-search-icon {
    color: #888;
}

.ingredients-search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 10px;
    font-size: 1rem;
    outline: none;
    color: #333;
}

.dark-mode .ingredients-search-input {
    color: #f0f0f0;
}

.ingredients-search-input::placeholder {
    color: #999;
}

.dark-mode .ingredients-search-input::placeholder {
    color: #777;
}

.ingredients-search-clear {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.ingredients-search-clear:hover {
    color: var(--primary-color, #FF6B6B);
}

/* ============================================
   RÉSULTATS DE RECHERCHE
============================================ */

.ingredients-search-results {
    padding: 15px 20px;
    min-height: 120px;
    max-height: 250px;
    overflow-y: auto;
    border-bottom: 1px solid #eee;
}

.dark-mode .ingredients-search-results {
    border-bottom-color: #444;
}

.ingredients-search-hint {
    color: #999;
    text-align: center;
    font-size: 0.9rem;
    margin: 30px 0;
}

.dark-mode .ingredients-search-hint {
    color: #777;
}

/* Loader de recherche */
.ingredients-search-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    gap: 10px;
    color: #999;
}

.ingredients-search-loader .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 107, 107, 0.2);
    border-top-color: var(--primary-color, #FF6B6B);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Résultat d'ingrédient individuel */
.ingredient-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    margin: 8px 0;
    background: #f5f5f5;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.dark-mode .ingredient-result-item {
    background: #3a3a3a;
}

.ingredient-result-item:hover {
    background: #eee;
}

.dark-mode .ingredient-result-item:hover {
    background: #444;
}

.ingredient-result-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.ingredient-result-image {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    background: white;
    flex-shrink: 0;
}

.dark-mode .ingredient-result-image {
    background: #2a2a2a;
}

.ingredient-result-name {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dark-mode .ingredient-result-name {
    color: #f0f0f0;
}

.ingredient-result-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Boutons Inclure/Exclure */
.btn-include-ingredient,
.btn-exclude-ingredient {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border: none;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-include-ingredient {
    background: rgba(76, 175, 80, 0.15);
    color: #4CAF50;
}

.btn-include-ingredient:hover {
    background: #4CAF50;
    color: white;
}

.btn-exclude-ingredient {
    background: rgba(244, 67, 54, 0.15);
    color: #F44336;
}

.btn-exclude-ingredient:hover {
    background: #F44336;
    color: white;
}

/* État désactivé (déjà sélectionné) */
.btn-include-ingredient.disabled,
.btn-exclude-ingredient.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ============================================
   SECTIONS INGRÉDIENTS SÉLECTIONNÉS
============================================ */

.ingredients-selected-container {
    padding: 15px 20px;
    flex: 1;
    overflow-y: auto;
}

.ingredients-selected-section {
    margin-bottom: 20px;
}

.ingredients-selected-section:last-child {
    margin-bottom: 0;
}

.ingredients-selected-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid;
}

.ingredients-include-section .ingredients-selected-title {
    color: #4CAF50;
    border-color: rgba(76, 175, 80, 0.3);
}

.ingredients-exclude-section .ingredients-selected-title {
    color: #F44336;
    border-color: rgba(244, 67, 54, 0.3);
}

.ingredients-selected-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: 11px;
    margin-left: auto;
}

.ingredients-include-section .ingredients-selected-count {
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
}

.ingredients-exclude-section .ingredients-selected-count {
    background: rgba(244, 67, 54, 0.2);
    color: #F44336;
}

.ingredients-selected-count:empty {
    display: none;
}

.ingredients-selected-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 40px;
}

.ingredients-empty-hint {
    color: #999;
    font-size: 0.85rem;
    font-style: italic;
    width: 100%;
    text-align: center;
    margin: 10px 0;
}

.dark-mode .ingredients-empty-hint {
    color: #777;
}

.badge-include-hint {
    color: #4CAF50;
    font-weight: 600;
    font-style: normal;
}

.badge-exclude-hint {
    color: #F44336;
    font-weight: 600;
    font-style: normal;
}

/* Tags d'ingrédients sélectionnés */
.ingredient-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    animation: tagAppear 0.2s ease;
}

@keyframes tagAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.ingredient-tag.include-tag {
    background: rgba(76, 175, 80, 0.15);
    color: #4CAF50;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.ingredient-tag.exclude-tag {
    background: rgba(244, 67, 54, 0.15);
    color: #F44336;
    border: 1px solid rgba(244, 67, 54, 0.3);
}

.ingredient-tag-remove {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.ingredient-tag-remove:hover {
    opacity: 1;
}

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

.ingredients-no-results {
    text-align: center;
    padding: 30px 20px;
    color: #999;
}

.dark-mode .ingredients-no-results {
    color: #777;
}

.ingredients-no-results i {
    font-size: 2rem;
    margin-bottom: 10px;
    display: block;
    opacity: 0.5;
}

/* ============================================
   RESPONSIVE
============================================ */

@media (max-width: 480px) {
    .ingredients-modal {
        max-width: 100%;
    }
    
    .ingredients-search-container {
        padding: 15px;
    }
    
    .ingredients-search-results {
        padding: 10px 15px;
        max-height: 200px;
    }
    
    .ingredients-selected-container {
        padding: 10px 15px;
    }
    
    .ingredient-result-item {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .ingredient-result-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .btn-include-ingredient,
    .btn-exclude-ingredient {
        flex: 1;
        justify-content: center;
    }
}

/* ============================================
   SCROLLBAR PERSONNALISÉE
============================================ */

.ingredients-search-results::-webkit-scrollbar,
.ingredients-selected-container::-webkit-scrollbar {
    width: 6px;
}

.ingredients-search-results::-webkit-scrollbar-track,
.ingredients-selected-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.dark-mode .ingredients-search-results::-webkit-scrollbar-track,
.dark-mode .ingredients-selected-container::-webkit-scrollbar-track {
    background: #2a2a2a;
}

.ingredients-search-results::-webkit-scrollbar-thumb,
.ingredients-selected-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.dark-mode .ingredients-search-results::-webkit-scrollbar-thumb,
.dark-mode .ingredients-selected-container::-webkit-scrollbar-thumb {
    background: #555;
}

.ingredients-search-results::-webkit-scrollbar-thumb:hover,
.ingredients-selected-container::-webkit-scrollbar-thumb:hover {
    background: #999;
}
