/**
 * autocomplete.css
 * Styles for the search suggestion dropdown on OnlyTop.ai.
 * Uses the project design-system CSS custom properties.
 */

/* ================================================
   DROPDOWN CONTAINER
   The .search-bar parent already has position:relative
   added via the companion rule below.
   ================================================ */

/* Ensure the search-bar can anchor the absolutely-positioned dropdown */
.search-bar {
    position: relative;
}

.autocomplete-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);   /* 6px gap below the search bar */
    left: 0;
    right: 0;
    z-index: 1000;

    background: var(--bg-white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);

    max-height: 320px;
    overflow-y: auto;
    overflow-x: hidden;

    /* Smooth entrance */
    animation: autocomplete-fade-in 0.12s ease-out both;
}

.autocomplete-dropdown.show {
    display: block;
}

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

/* Custom scrollbar to match the clean aesthetic */
.autocomplete-dropdown::-webkit-scrollbar {
    width: 4px;
}

.autocomplete-dropdown::-webkit-scrollbar-track {
    background: var(--border-light);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-sm);
}

.autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* ================================================
   CATEGORY HEADER LABELS
   ================================================ */

.autocomplete-category {
    padding: 6px 16px 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    /* Subtle separator from items above */
    border-top: 1px solid var(--border-light);
    user-select: none;
    pointer-events: none;
}

/* No top border on the very first category label */
.autocomplete-dropdown .autocomplete-category:first-child {
    border-top: none;
}

/* ================================================
   SUGGESTION ITEMS
   ================================================ */

.autocomplete-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.1s ease;
    /* Prevent text from wrapping awkwardly */
    white-space: nowrap;
    overflow: hidden;
}

/* Remove border on the last item */
.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background: var(--primary-bg);
    color: var(--primary);
}

.autocomplete-item:hover .autocomplete-item-text,
.autocomplete-item.active .autocomplete-item-text {
    color: var(--primary);
}

/* ================================================
   ITEM TEXT
   ================================================ */

.autocomplete-item-text {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.1s ease;
}

/* Highlighted (matched) portion */
.autocomplete-highlight {
    font-weight: 700;
    /* Inherit color so it brightens with hover state */
    color: inherit;
    background: transparent;
}

/* ================================================
   CATEGORY ICONS
   ================================================ */

.autocomplete-item-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.1s ease;
}

.autocomplete-item:hover .autocomplete-item-icon,
.autocomplete-item.active .autocomplete-item-icon {
    opacity: 1;
}

/* Recent: muted teal */
.autocomplete-icon-recent {
    color: #0D9488;    /* teal-600 */
    stroke: currentColor;
}

/* Conference: primary purple */
.autocomplete-icon-conference {
    color: var(--primary);
    stroke: currentColor;
}

/* Area: amber */
.autocomplete-icon-area {
    color: #D97706;    /* amber-600 */
    stroke: currentColor;
}

/* Keyword: slate/default search colour */
.autocomplete-icon-keyword {
    color: var(--text-secondary);
    stroke: currentColor;
}

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

@media (max-width: 768px) {
    .autocomplete-dropdown {
        /* On small screens, stretch to the full width of the search bar,
           which is itself full-width at mobile breakpoints. */
        left: 0;
        right: 0;
        border-radius: var(--radius-sm);
        max-height: 260px;
    }

    .autocomplete-item {
        padding: 11px 14px;
    }

    .autocomplete-item-text {
        font-size: 13px;
    }

    .autocomplete-category {
        padding: 5px 14px 3px;
        font-size: 10px;
    }
}
