/* ============================================================
   CookQuick - autocomplete.css
   Styles pour la barre de recherche avec auto-complétion.
   À inclure dans le bundle CSS après site.css.
   ============================================================ */

.header-search .autocomplete {
    position: relative;
    flex: 1;
    min-width: 0;
}

.header-search .autocomplete > input[type="search"] {
    width: 100%;
    border-radius: 6px 0 0 6px;
}

/* Quand le dropdown est ouvert : aplatir le bas droit de l'input */
.header-search .autocomplete.is-open > input[type="search"] {
    border-bottom-left-radius: 0;
}

/* ----- Liste de suggestions ----- */
.autocomplete-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    list-style: none;
    margin: 0;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    max-height: 70vh;
    overflow-y: auto;
    z-index: 200;
}

.autocomplete-list[hidden] {
    display: none;
}

.autocomplete-item {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: background-color .12s var(--ease);
    line-height: 1.3;
}

.autocomplete-item:hover,
.autocomplete-item.is-active {
    background: var(--surface-2);
}

.autocomplete-item-title {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.autocomplete-item-title mark {
    background: transparent;
    color: var(--accent);
    font-weight: 700;
    padding: 0;
}

.autocomplete-item-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.autocomplete-item-cat {
    color: var(--accent);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 1.5px;
    font-weight: 600;
}

.autocomplete-empty,
.autocomplete-loading {
    padding: 14px 12px;
    color: var(--text-muted);
    font-size: 14px;
    font-style: italic;
    text-align: center;
}

.autocomplete-loading::before {
    content: "";
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 8px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: ac-spin 0.7s linear infinite;
    vertical-align: -2px;
}

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

/* Responsive : sur mobile, le dropdown prend toute la largeur du header */
@media (max-width: 768px) {
    .autocomplete-list {
        max-height: 60vh;
    }
    .autocomplete-item-title { font-size: 14px; }
}

/* Réduire les animations si demandé */
@media (prefers-reduced-motion: reduce) {
    .autocomplete-loading::before { animation: none; }
    .autocomplete-item { transition: none; }
}
