/* 首页和工具页共用的菜单搜索组件 */
.search-index {
    position: relative;
    z-index: 230;
}

.search-index > [data-search-results] {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 10px);
    z-index: 9999;
    margin: 0;
    padding: 0;
    overflow: hidden auto;
    max-height: min(60vh, 560px);
    list-style: none;
    text-align: left;
    border: 0;
    border-radius: 18px;
    background: var(--tmx-surface-strong, var(--bs-body-bg, #fff));
    box-shadow: 0 18px 50px rgba(22, 35, 31, 0.12);
}

.search-index > [data-search-results] li {
    display: flex;
    align-items: stretch;
    min-height: 46px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.search-index > [data-search-results] .item {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 9px;
    min-width: 0;
    min-height: 46px;
    padding: 8px 16px;
    color: var(--tmx-text, var(--bs-index-text-color, #1a2a2a));
    text-decoration: none;
    border-bottom: 1px solid rgba(16, 24, 40, 0.06);
    transition: background-color 0.18s ease, color 0.18s ease;
}

.search-index > [data-search-results] li:last-child .item {
    border-bottom: 0;
}

.search-index > [data-search-results] li:hover .item,
.search-index > [data-search-results] li.search-result-active .item {
    background: linear-gradient(90deg, rgba(31, 157, 116, 0.14), rgba(31, 157, 116, 0.06));
    color: var(--tmx-accent-deep, var(--theme-color, #127056));
}

.search-result-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.98rem;
    font-weight: 600;
}

.search-result-separator {
    flex: 0 0 auto;
    color: var(--tmx-muted, #6c7a7a);
    font-size: 1rem;
    line-height: 1;
}

.search-category {
    flex: 0 0 auto;
    max-width: 38%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0.22rem 0.58rem;
    border: 1px solid rgba(31, 157, 116, 0.12);
    border-radius: 999px;
    background: var(--tmx-accent-soft, rgba(31, 157, 116, 0.12));
    color: var(--tmx-accent-deep, var(--theme-color, #127056));
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.2;
}

.search-empty,
.search-history-label {
    display: block;
    padding: 12px 16px;
    color: var(--tmx-muted, #6c7a7a);
    font-size: 0.88rem;
}

.search-history-label {
    flex: 0 0 auto;
    margin-left: auto;
    padding-left: 8px;
    padding-right: 0;
    font-size: 0.76rem;
}

.search-history-delete,
.search-history-clear {
    border: 0;
    background: transparent;
    color: var(--tmx-muted, #6c7a7a);
    cursor: pointer;
    font-size: 0.76rem;
}

.search-history-delete {
    flex: 0 0 auto;
    padding: 0 12px;
}

.search-history-delete:hover,
.search-history-clear:hover {
    color: var(--theme-color, #1f9d74);
}

.search-history-clear-row {
    justify-content: flex-end;
    padding: 6px 12px;
    border-top: 1px solid rgba(16, 24, 40, 0.06);
}

.search-history-clear {
    padding: 4px;
}

.sidebar .search-index {
    position: sticky;
    top: 0;
    width: auto;
    height: auto;
}

.sidebar .search-index > .input-wrap {
    width: 100%;
}

.sidebar .search-index input {
    width: 100%;
    min-width: 0;
}

.sidebar .search-index > [data-search-results] {
    top: calc(100% + 8px);
    max-height: min(60vh, 520px);
    border-radius: 14px;
}

.sidebar .search-index > [data-search-results] .item {
    min-height: 40px;
    padding: 7px 10px;
    font-size: 13px;
}

.sidebar .search-index > [data-search-results] .search-result-name {
    font-size: 13px;
}

@media (max-width: 576px) {
    .search-index > [data-search-results] .item {
        gap: 7px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .search-category {
        max-width: 42%;
    }
}
