/**
 * TableSearch — стили компонента поиска с автокомплитом для рейтинговых таблиц.
 */

/* Обёртка поиска */
.table-search {
    position: relative;
    max-width: 360px;
    margin: 0 0 12px 0;
}

/* Строка с инпутом */
.table-search__input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

/* Иконка лупы */
.table-search__icon {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: #94a3b8;
    pointer-events: none;
    flex-shrink: 0;
    transition: color 0.15s;
}

.table-search__input-wrap:focus-within .table-search__icon {
    color: var(--color-primary, #7c3aed);
}

/* Поле ввода */
.ts-input {
    width: 100%;
    padding: 8px 34px 8px 36px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 13px;
    color: #1e293b;
    background: #fff;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    min-width: 0;
}

.ts-input::placeholder {
    color: #94a3b8;
}

.ts-input:focus {
    border-color: var(--color-primary, #7c3aed);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

/* Кнопка очистки */
.ts-clear {
    position: absolute;
    right: 8px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    cursor: pointer;
    color: #94a3b8;
    font-size: 16px;
    line-height: 1;
    border-radius: 50%;
    padding: 0;
    transition: color 0.15s, background 0.15s;
}

.ts-clear:hover {
    color: #64748b;
    background: #f1f5f9;
}

/* Дропдаун */
.ts-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    overflow: hidden;
}

.ts-dropdown--visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Список подсказок */
.ts-dropdown__list {
    max-height: 320px;
    overflow-y: auto;
    padding: 6px;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.ts-dropdown__list::-webkit-scrollbar {
    width: 5px;
}

.ts-dropdown__list::-webkit-scrollbar-track {
    background: transparent;
}

.ts-dropdown__list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* Сообщение «ничего не найдено» */
.ts-dropdown__empty {
    padding: 14px 12px;
    text-align: center;
    font-size: 13px;
    color: #94a3b8;
}

/* Элемент подсказки */
.ts-suggestion {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s;
    user-select: none;
}

.ts-suggestion:hover,
.ts-suggestion--active {
    background: #f1f5f9;
}

/* Аватар / обложка */
.ts-suggestion__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #e2e8f0;
}

.ts-suggestion__avatar--course {
    border-radius: 6px;
    width: 48px;
    height: 32px;
}

.ts-suggestion__avatar--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
}

.ts-suggestion__avatar--placeholder.ts-suggestion__avatar--course {
    font-size: 16px;
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    color: #64748b;
}

/* Имя */
.ts-suggestion__name {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Подзаголовок (ID badge) */
.ts-suggestion__subtitle {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    color: #7c3aed;
    background: #ede9fe;
    border-radius: 5px;
    padding: 2px 6px;
    letter-spacing: 0.02em;
}

/* Подсветка совпадения внутри бейджа ID */
.ts-suggestion__subtitle .ts-highlight {
    background: #7c3aed;
    color: #fff;
    border-radius: 2px;
    padding: 0 1px;
}

/* Подсветка совпадения в имени */
.ts-highlight {
    background: #ede9fe;
    color: #5b21b6;
    font-weight: 700;
    border-radius: 2px;
    padding: 0 1px;
}

/* Сентинел для инфинити-скролла */
.ts-sentinel {
    height: 1px;
    flex-shrink: 0;
}

/* Индикатор загрузки следующей страницы */
.ts-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
}

.ts-loading .spinner {
    width: 28px;
    height: 28px;
}

.ts-loading .spinner-dot {
    width: 5px;
    height: 5px;
}

/* Строка «Найти ...» (поиск по таблице) */
.ts-search-action {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.12s;
    user-select: none;
}

.ts-search-action:hover {
    background: #f5f3ff;
}

.ts-search-action__icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--color-primary, #7c3aed);
}

.ts-search-action__text {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ts-search-action__text strong {
    color: var(--color-primary, #7c3aed);
    font-weight: 600;
}

.ts-search-action__arrow {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: #94a3b8;
    transition: transform 0.15s;
}

.ts-search-action:hover .ts-search-action__arrow {
    transform: translateX(2px);
    color: var(--color-primary, #7c3aed);
}

/* === Подсказка-автор в автокомплите === */
.ts-suggestion--author {
    border-top: 1px solid #f1f5f9;
    margin-top: 2px;
}
.ts-suggestion--author:first-child {
    border-top: none;
    margin-top: 0;
}
.ts-suggestion__avatar--author {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.ts-suggestion__body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 1px;
}


/* Адаптив */
@media (max-width: 600px) {
    .table-search {
        max-width: 100%;
        margin: 0 0 10px 0;
    }

    .ts-input {
        font-size: 14px;
    }
}
