/**
 * Styles pour la recherche globale - Style Spotlight (macOS / VS Code)
 *
 * Fichier: /static/css/atoms/global-search.css
 */

/* =====================================================
   CONTENEUR PRINCIPAL - SPOTLIGHT
   ===================================================== */
.spotlight-search {
    position: relative;
    width: 100%;
    max-width: 480px;
}

.spotlight-search-inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid transparent;
    border-radius: 50px;
    transition: all 0.2s ease;
}

/* Hover */
.spotlight-search-inner:hover {
    background: rgba(0, 0, 0, 0.06);
}

/* Focus */
.spotlight-search:focus-within .spotlight-search-inner {
    background: #fff;
    border-color: #2270b2;
    box-shadow: 0 0 0 3px rgba(34, 112, 178, 0.15),
                0 4px 12px rgba(0, 0, 0, 0.08);
}

/* =====================================================
   ICONE
   ===================================================== */
.spotlight-icon {
    color: #6c757d;
    font-size: 0.875rem;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

.spotlight-search:focus-within .spotlight-icon {
    color: #2270b2;
}

/* =====================================================
   INPUT
   ===================================================== */
.spotlight-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.875rem;
    color: #212529;
    min-width: 0;
}

.spotlight-input::placeholder {
    color: #868e96;
}

/* =====================================================
   RACCOURCI CLAVIER
   ===================================================== */
.spotlight-shortcut {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.spotlight-search:focus-within .spotlight-shortcut {
    opacity: 0;
    pointer-events: none;
}

.spotlight-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    font-size: 0.65rem;
    font-weight: 500;
    color: #495057;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

/* =====================================================
   DROPDOWN DES RESULTATS
   ===================================================== */
.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: -40px;
    right: -40px;
    min-width: 450px;
    z-index: 1055;
    background: var(--bs-white, #fff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 12px;
    margin-top: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

.search-results-dropdown.show {
    display: block;
    animation: searchDropdownFadeIn 0.15s ease-out;
}

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

/* =====================================================
   GROUPES DE RESULTATS
   ===================================================== */
.search-result-group {
    border-bottom: 1px solid var(--bs-gray-200, #e9ecef);
}

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

.search-result-group-header {
    font-size: 0.75rem;
    color: var(--bs-dark, #212529);
    background-color: var(--bs-gray-100, #f8f9fa) !important;
    position: sticky;
    top: 0;
    z-index: 1;
}

.search-result-group-header:first-child {
    border-radius: 12px 12px 0 0;
}

.search-result-group-header i {
    color: #2270b2;
}

/* =====================================================
   ITEMS DE RESULTAT
   ===================================================== */
.search-result-item {
    border-bottom: 1px solid var(--bs-gray-100, #f8f9fa);
    transition: background-color 0.1s ease;
    color: var(--bs-dark, #212529);
}

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

.search-result-item:hover,
.search-result-item.selected {
    background-color: rgba(34, 112, 178, 0.08);
    text-decoration: none;
}

.search-result-item:focus {
    outline: none;
    background-color: rgba(34, 112, 178, 0.08);
    box-shadow: inset 0 0 0 2px #2270b2;
}

.search-result-item.selected {
    background-color: rgba(34, 112, 178, 0.12);
}

/* Icone du resultat */
.search-result-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bs-gray-100, #f8f9fa);
    border-radius: 8px;
    color: var(--bs-secondary, #6c757d);
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.search-result-item:hover .search-result-icon,
.search-result-item.selected .search-result-icon {
    background-color: #2270b2;
    color: var(--bs-white, #fff);
}

/* Contenu du resultat */
.search-result-title {
    font-size: 0.875rem;
    line-height: 1.3;
}

.search-result-subtitle {
    font-size: 0.75rem;
    max-width: 320px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Pour FAQ, Liens, URLs, etc. : afficher plus de texte sur 2 lignes */
.search-result-item[data-type="FAQ"] .search-result-subtitle,
.search-result-item[data-type="LIEN_UTILE"] .search-result-subtitle,
.search-result-item[data-type="URL"] .search-result-subtitle,
.search-result-item[data-type="VM"] .search-result-subtitle,
.search-result-item[data-type="BDD"] .search-result-subtitle,
.search-result-item[data-type="NAS"] .search-result-subtitle,
.search-result-item[data-type="TACHE"] .search-result-subtitle,
.search-result-subtitle.multiline {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 100%;
}

/* Badges */
.search-result-badges .badge {
    font-size: 0.625rem;
    font-weight: 500;
    padding: 0.2em 0.45em;
}

/* =====================================================
   ETATS
   ===================================================== */

/* Chargement */
.search-loading {
    color: var(--bs-secondary, #6c757d);
}

/* Aucun resultat */
.search-no-results {
    color: var(--bs-secondary, #6c757d);
}

/* Erreur */
.search-error {
    color: var(--bs-danger, #dc3545);
}

/* =====================================================
   SCROLLBAR PERSONNALISEE
   ===================================================== */
.search-results-dropdown::-webkit-scrollbar {
    width: 6px;
}

.search-results-dropdown::-webkit-scrollbar-track {
    background: var(--bs-gray-100, #f8f9fa);
    border-radius: 3px;
}

.search-results-dropdown::-webkit-scrollbar-thumb {
    background: var(--bs-gray-400, #ced4da);
    border-radius: 3px;
}

.search-results-dropdown::-webkit-scrollbar-thumb:hover {
    background: var(--bs-gray-500, #adb5bd);
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 991.98px) {
    .spotlight-search {
        max-width: 100%;
    }
}

@media (max-width: 576px) {
    .spotlight-search-inner {
        padding: 0.4rem 0.6rem;
    }

    .search-results-dropdown {
        max-height: 300px;
        position: fixed;
        left: 0.5rem;
        right: 0.5rem;
        width: auto;
    }

    .search-result-subtitle {
        max-width: 200px;
    }
}

/* =====================================================
   ACCESSIBILITE RGAA
   ===================================================== */
.spotlight-search:focus-within .spotlight-search-inner {
    outline: none;
}

.spotlight-input:focus-visible {
    outline: none;
}

/* Support navigateurs anciens */
@supports not (selector(:focus-visible)) {
    .spotlight-input:focus {
        outline: none;
    }
}
