/**
 * Hero Search Modes - Onglets Rechercher / Cuisiner les restes
 * 
 * @version 1.7.0
 * @date 2026-01-23
 */

/* ============================================
   VARIABLES CSS - MODE RESTES (ANTI-GASPI)
   ============================================ */
:root {
    --color-restes: #7cb083;
    --color-restes-hover: #6a9a70;
    --color-restes-light: rgba(124, 176, 131, 0.15);
    --hero-search-box-height: 300px;
}

/* ============================================
   HERO SEARCH BOX - HAUTEUR FIXE
   ============================================ */
.hero-search-box {
    height: var(--hero-search-box-height);
    display: flex;
    flex-direction: column;
}

/* En mode restes, hauteur auto pour s'adapter au contenu */
.hero-search-box.mode-restes {
    height: auto;
    min-height: var(--hero-search-box-height);
}

/* ============================================
   ONGLETS DE MODE (HERO)
   ============================================ */
.hero-mode-tabs {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: 20px;
}

.hero-mode-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    font-weight: 600;
    color: #888;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    border-bottom: 3px solid transparent;
}

.dark-mode .hero-mode-tab {
    color: #999;
}

.hero-mode-tab:hover {
    color: #555;
}

.dark-mode .hero-mode-tab:hover {
    color: #ccc;
}

/* Onglet actif - Mode classique */
.hero-mode-tab.active[data-mode="classique"] {
    color: var(--primary-color, #FF6B6B);
    border-bottom-color: var(--primary-color, #FF6B6B);
}

/* Onglet actif - Mode restes */
.hero-mode-tab.active[data-mode="restes"] {
    color: var(--color-restes);
    border-bottom-color: var(--color-restes);
}

.hero-mode-tab i {
    font-size: 1rem;
    transition: transform 0.2s ease;
}

.hero-mode-tab:hover i {
    transform: scale(1.1);
}

/* Séparateur entre les onglets */
.hero-mode-separator {
    width: 1px;
    height: 24px;
    background: #ddd;
    margin: 0 5px;
    align-self: center;
}

.dark-mode .hero-mode-separator {
    background: #555;
}

/* ============================================
   HERO SEARCH BOX - MODE RESTES
   Bordure verte seulement quand focus
   ============================================ */

.hero-search-box.mode-restes .hero-search-input-wrapper:focus-within {
    border-color: var(--color-restes);
    box-shadow: 0 4px 16px rgba(124, 176, 131, 0.35);
}

/* IMPORTANT: permettre le débordement du dropdown d'autocomplétion */
.hero-search-box.mode-restes .hero-search-input-wrapper {
    overflow: visible;
}

/* Bouton recherche en mode restes - vert */
.hero-search-box.mode-restes .hero-search-btn {
    background: linear-gradient(135deg, var(--color-restes) 0%, var(--color-restes-hover) 100%);
    box-shadow: 0 4px 12px rgba(124, 176, 131, 0.3);
}

.hero-search-box.mode-restes .hero-search-btn:hover {
    box-shadow: 0 6px 20px rgba(124, 176, 131, 0.45);
}

/* ============================================
   ZONES INTERCHANGEABLES
   ============================================ */

/* Zone filtres (mode classique) */
.hero-filters-container {
    margin-top: 20px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.hero-search-box.mode-restes .hero-filters-container {
    display: none;
}

/* Zone exemples (mode restes) */
.hero-restes-zone {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: 700px;
    margin: 20px auto 0;
}

.hero-search-box.mode-restes .hero-restes-zone {
    display: flex;
}

/* ============================================
   ZONE EXEMPLES (MODE RESTES)
   ============================================ */

.hero-restes-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    width: 100%;
    max-width: 700px;
}

.hero-restes-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #f0f0f0;
    border: 2px solid transparent;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dark-mode .hero-restes-chip {
    background: #3a4550;
    color: #bbb;
}

.hero-restes-chip:hover {
    background: var(--color-restes-light);
    border-color: var(--color-restes);
    color: var(--color-restes-hover);
}

.dark-mode .hero-restes-chip:hover {
    background: rgba(124, 176, 131, 0.2);
    border-color: var(--color-restes);
    color: var(--color-restes);
}

.hero-restes-chip .chip-emoji {
    font-size: 1rem;
}

/* ============================================
   HEADER - TOGGLE BISTABLE (SEEDLING)
   ============================================ */

.header-mode-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.25s ease;
    color: #888;
    margin-left: 5px;
    margin-right: 5px;
}

.dark-mode .header-mode-toggle-btn {
    color: #888;
}

.header-mode-toggle-btn:hover {
    color: var(--color-restes);
    background: var(--color-restes-light);
}

/* État actif - Mode restes (même style que hover) */
.header-mode-toggle-btn.active {
    color: var(--color-restes);
    background: var(--color-restes-light);
}

.header-mode-toggle-btn.active:hover {
    background: rgba(124, 176, 131, 0.25);
}

.header-mode-toggle-btn i {
    font-size: 1rem;
}

/* ============================================
   HEADER SEARCH - MODE RESTES
   Bordure verte seulement quand focus
   ============================================ */

.header-search[data-mode="restes"]:focus-within {
    border-color: var(--color-restes) !important;
    box-shadow: 0 4px 16px rgba(124, 176, 131, 0.35) !important;
}

.header-search[data-mode="restes"] .search-btn {
    background: linear-gradient(135deg, var(--color-restes) 0%, var(--color-restes-hover) 100%) !important;
}

/* ============================================
   MOBILE SEARCH - TOGGLE BISTABLE
   ============================================ */

.search-input-wrapper .header-mode-toggle-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    margin-right: 8px;
}

/* Mode restes sur mobile - bordure verte seulement au focus */
.search-dropdown[data-mode="restes"] .search-input-wrapper:focus-within {
    border-color: var(--color-restes);
}

.search-dropdown[data-mode="restes"] .search-btn {
    background: linear-gradient(135deg, var(--color-restes) 0%, var(--color-restes-hover) 100%) !important;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    :root {
        --hero-search-box-height: 280px;
    }
    
    .hero-mode-tabs {
        gap: 0;
        margin-bottom: 15px;
    }
    
    .hero-mode-tab {
        padding: 10px 16px;
        font-size: 0.85rem;
    }
    
    .hero-mode-tab span {
        display: none;
    }
    
    .hero-mode-tab i {
        font-size: 1.1rem;
    }
    
    .hero-filters-container,
    .hero-restes-zone {
        margin-top: 15px;
    }
    
    .hero-restes-examples {
        gap: 8px;
    }
    
    .hero-restes-chip {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    /* Header toggle */
    .header-mode-toggle-btn {
        width: 34px;
        height: 34px;
        min-width: 34px;
        margin-right: 8px;
    }
    
    .header-mode-toggle-btn i {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    :root {
        --hero-search-box-height: 320px;
    }
    
    .hero-mode-tab {
        padding: 8px 12px;
    }
    
    .hero-restes-chip {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
    
    .hero-restes-chip .chip-emoji {
        font-size: 0.9rem;
    }
}

/* ============================================
   HERO MODE RESTES - TAGS D'INGRÉDIENTS
   ============================================ */

/* Zone des tags (remplace les chips quand ingrédients sélectionnés) */
.hero-restes-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    width: 100%;
    max-width: 700px;
}

/* Tag d'ingrédient */
.hero-restes-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(42, 53, 64, 0.9);
    border: 2px solid var(--color-restes);
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #fff;
    transition: all 0.2s ease;
}

.hero-restes-tag:hover {
    background: rgba(42, 53, 64, 1);
}

.hero-restes-tag-remove {
    background: none;
    border: none;
    padding: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hero-restes-tag-remove:hover {
    background: rgba(255, 107, 107, 0.3);
    color: #ff6b6b;
}

/* Zone d'ajout d'ingrédient */
.hero-restes-add-wrapper {
    display: flex;
    gap: 10px;
    position: relative;
}

.hero-restes-add-input {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 30px;
    font-size: 1rem;
    outline: none;
    background: rgba(42, 53, 64, 0.8);
    color: #fff;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.hero-restes-add-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.hero-restes-add-input:focus {
    border-color: var(--color-restes);
    background: rgba(42, 53, 64, 0.95);
}

.hero-restes-add-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: var(--color-restes);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.hero-restes-add-btn:hover {
    background: var(--color-restes-hover);
    transform: scale(1.05);
}

/* Bouton rechercher dans la zone ingrédients */
.hero-restes-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 24px;
    margin-top: 15px;
    border: none;
    border-radius: 30px;
    background: linear-gradient(135deg, var(--color-restes) 0%, var(--color-restes-hover) 100%);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(124, 176, 131, 0.3);
}

.hero-restes-search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 176, 131, 0.45);
}

.hero-restes-search-btn i {
    font-size: 1.1rem;
}

/* ============================================
   HERO AUTOCOMPLETE DROPDOWN (MODE RESTES)
   ============================================ */

.hero-autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: rgba(42, 53, 64, 0.98);
    backdrop-filter: blur(10px);
    border: 2px solid var(--color-restes);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    max-height: 280px;
    overflow-y: auto;
}

/* Dans la zone d'ajout, laisser de l'espace pour le bouton + */
.hero-restes-add-wrapper .hero-autocomplete-dropdown {
    right: 58px;
}

/* Dans la barre principale, laisser de l'espace pour le bouton recherche */
.hero-search-input-wrapper .hero-autocomplete-dropdown {
    right: 60px;
}

.hero-autocomplete-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.hero-autocomplete-item:last-child {
    border-bottom: none;
}

.hero-autocomplete-item:first-child {
    border-radius: 14px 14px 0 0;
}

.hero-autocomplete-item:last-child {
    border-radius: 0 0 14px 14px;
}

.hero-autocomplete-item:only-child {
    border-radius: 14px;
}

.hero-autocomplete-item:hover,
.hero-autocomplete-item.selected {
    background: rgba(124, 176, 131, 0.25);
}

.hero-autocomplete-item i {
    color: var(--color-restes);
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.hero-autocomplete-item span {
    flex: 1;
    font-size: 1rem;
    color: #eee;
    font-weight: 500;
    text-align: left;
}

.hero-autocomplete-item span strong {
    color: var(--color-restes);
    font-weight: 700;
}

/* Scrollbar personnalisée */
.hero-autocomplete-dropdown::-webkit-scrollbar {
    width: 6px;
}

.hero-autocomplete-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.hero-autocomplete-dropdown::-webkit-scrollbar-thumb {
    background: var(--color-restes);
    border-radius: 3px;
}

.hero-autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
    background: var(--color-restes-hover);
}

/* Responsive */
@media (max-width: 768px) {
    .hero-restes-ingredients-zone {
        padding: 15px;
    }
    
    .hero-restes-tag {
        padding: 6px 10px;
        font-size: 0.85rem;
    }
    
    .hero-restes-add-input {
        padding: 10px 14px;
        font-size: 0.95rem;
    }
    
    .hero-restes-add-btn {
        width: 44px;
        height: 44px;
    }
    
    .hero-autocomplete-dropdown {
        right: 54px;
        max-height: 220px;
    }
    
    .hero-autocomplete-item {
        padding: 12px 14px;
        gap: 12px;
    }
    
    .hero-autocomplete-item span {
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .hero-restes-ingredients-zone {
        padding: 12px;
    }
    
    .hero-restes-tags-list {
        gap: 6px;
    }
    
    .hero-restes-tag {
        padding: 5px 8px;
        font-size: 0.8rem;
    }
    
    .hero-restes-add-input {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    .hero-restes-add-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .hero-autocomplete-dropdown {
        right: 50px;
        max-height: 200px;
    }
    
    .hero-autocomplete-item {
        padding: 10px 12px;
        gap: 10px;
    }
    
    .hero-autocomplete-item i {
        font-size: 1rem;
    }
    
    .hero-autocomplete-item span {
        font-size: 0.9rem;
    }
}
