/**
 * Custom CSS pour la recherche intelligente
 * Style pour les suggestions de pages et la navigation
 */

/* ================================================
   SEARCH RESULTS DROPDOWN
   ================================================ */

.search-results-dropdown {
    display: none;
    max-height: 400px;
    overflow-y: auto;
    margin-top: 10px;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #dee2e6;
}

/* Afficher le dropdown quand il contient du contenu */
.search-results-dropdown:not(:empty) {
    display: block !important;
}

/* Scrollbar personnalisée pour les résultats */
.search-results-dropdown::-webkit-scrollbar {
    width: 6px;
}

.search-results-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.search-results-dropdown::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.search-results-dropdown::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Firefox */
.search-results-dropdown {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

/* ================================================
   SEARCH RESULT ITEMS
   ================================================ */

.search-result-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.2s ease;
    cursor: pointer;
    background-color: #fff;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover,
.search-result-item.active {
    background-color: var(--primary01, rgba(0, 147, 213, 0.1));
    border-left: 3px solid var(--primary, #0093D5);
    padding-left: 13px;
}

/* Icône du résultat */
.search-result-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary01, rgba(0, 147, 213, 0.1));
    border-radius: 8px;
    flex-shrink: 0;
}

.search-result-icon i {
    font-size: 20px;
    color: var(--primary, #0093D5);
}

/* Titre du résultat */
.search-result-title {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 2px;
}

/* Catégorie du résultat */
.search-result-category {
    font-size: 12px;
    color: #6c757d;
}

/* Flèche de navigation */
.search-result-arrow {
    margin-left: auto;
    flex-shrink: 0;
}

.search-result-arrow i {
    font-size: 16px;
    transition: transform 0.2s ease;
}

.search-result-item:hover .search-result-arrow i {
    transform: translateX(3px);
}

/* ================================================
   NO RESULTS MESSAGE
   ================================================ */

.search-no-results {
    padding: 20px;
    text-align: center;
    color: #6c757d;
}

.search-no-results i {
    font-size: 32px;
    opacity: 0.5;
    display: block;
    margin-bottom: 10px;
}

/* ================================================
   SEARCH INPUT ENHANCEMENTS
   ================================================ */

/* Style amélioré pour les inputs de recherche */
#desktopSearchInput,
#modalSearchInput {
    border-radius: 6px 0 0 6px;
    border: 1px solid #dee2e6;
    padding: 8px 12px;
    font-size: 14px;
    transition: all 0.3s ease;
}

#desktopSearchInput:focus,
#modalSearchInput:focus {
    border-color: var(--primary, #0093D5);
    box-shadow: 0 0 0 0.2rem rgba(0, 147, 213, 0.15);
}

/* Style pour le grand input de la modale */
#modalSearchInput {
    font-size: 16px;
    padding: 12px 16px;
}

/* Bouton de recherche */
.header-search .input-group-text {
    border-radius: 0 6px 6px 0;
    border: 1px solid var(--primary, #0093D5);
    background-color: var(--primary, #0093D5);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.header-search .input-group-text:hover {
    background-color: var(--primary-bg-hover, #007AB1);
    border-color: var(--primary-bg-hover, #007AB1);
}

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

/* Mobile */
@media (max-width: 991px) {
    .search-results-dropdown {
        max-height: 300px;
    }

    .search-result-item {
        padding: 10px 12px;
    }

    .search-result-icon {
        width: 35px;
        height: 35px;
    }

    .search-result-icon i {
        font-size: 18px;
    }

    .search-result-title {
        font-size: 13px;
    }

    .search-result-category {
        font-size: 11px;
    }
}

/* ================================================
   ANIMATIONS
   ================================================ */

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-results-dropdown[style*="display: block"] {
    animation: slideDown 0.3s ease;
}

/* ================================================
   DARK MODE SUPPORT (si applicable)
   ================================================ */

@media (prefers-color-scheme: dark) {
    .search-results-dropdown {
        background: #2d3748;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .search-result-item {
        border-bottom-color: #4a5568;
        background-color: #2d3748;
    }

    .search-result-item:hover,
    .search-result-item.active {
        background-color: rgba(0, 147, 213, 0.2);
    }

    .search-result-title {
        color: #e2e8f0;
    }

    .search-result-category {
        color: #a0aec0;
    }

    .search-no-results {
        color: #a0aec0;
    }

    #desktopSearchInput,
    #mobileSearchInput {
        background-color: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }

    #desktopSearchInput::placeholder,
    #modalSearchInput::placeholder {
        color: #a0aec0;
    }
}

/* ================================================
   SEARCH MODAL SPECIFIC STYLES
   ================================================ */

#searchModal .modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    position: relative;
}

#searchModal .modal-header {
    padding: 1.5rem 1.5rem 0.5rem;
}

#searchModal .modal-body {
    padding: 1rem 1.5rem 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}

#searchModal .modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary, #0093D5);
}

/* Style pour les résultats dans la modale */
#searchModal .search-results-dropdown {
    margin-top: 0;
    border: none;
    box-shadow: none;
    max-height: 50vh;
}

/* Positionnement centré pour la modale de recherche */
@media (min-width: 992px) {
    #searchModal.show {
        display: block !important;
    }

    /* #searchModal .modal-dialog {
        position: fixed !important;
        top: 77px !important;
        right: 25px !important;
        left: auto !important;
        margin: 0 !important;
        transform: none !important;
        max-width: 450px;
        z-index: 9999 !important;
    } */

    #searchModal .modal-content {
        z-index: 10000 !important;
    }
}

/* Sur mobile, garder le comportement centré */
@media (max-width: 991px) {
    #searchModal .modal-dialog {
        margin: 1.75rem auto;
    }
}

/* Icône de recherche mobile visible à côté des autres icônes */
#mobileSearchToggle {
    cursor: pointer;
    transition: all 0.3s ease;
}

#mobileSearchToggle:hover {
    background-color: rgba(0, 147, 213, 0.1);
    border-radius: 6px;
}

#mobileSearchToggle i {
    font-size: 18px;
}

/* Animation d'entrée de la modale */
#searchModal.fade .modal-dialog {
    transition: transform 0.3s ease-out;
}

#searchModal.show .modal-dialog {
    transform: none;
}

/* ================================================
   RESPONSIVE 640px - ICÔNES DANS DROPDOWN
   ================================================ */

/* Au-dessus de 640px : afficher les icônes directement et cacher le menu dropdown */
@media (min-width: 640px) {
    .header-right-icons .show-above-640,
    .header-right-icons div.show-above-640,
    .d-flex.show-above-640 {
        display: flex !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    .header-right-icons .show-below-640,
    .navbar.show-below-640,
    div.show-below-640,
    button.show-below-640,
    .navbar-toggler.show-below-640 {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}

/* En dessous de 640px : cacher les icônes directes et afficher le bouton 3 points + dropdown */
@media (max-width: 639px) {
    .header-right-icons .show-above-640,
    .header-right-icons div.show-above-640,
    .d-flex.show-above-640 {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    .header-right-icons .show-below-640,
    button.show-below-640,
    .navbar-toggler.show-below-640 {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    .navbar.show-below-640 {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    /* Override style.css rules that hide fullscreen and theme icons */
    .responsive-navbar .full-screen-link,
    .responsive-navbar.show-below-640 .full-screen-link {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .responsive-navbar .theme-layout.nav-link-bg.layout-setting,
    .responsive-navbar.show-below-640 .theme-layout.nav-link-bg.layout-setting {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}
