/* ── Tool Search Component ─────────────────────────────────────────────────── */

.ts-section {
    padding: 2.5rem 0 1.5rem;
    background: var(--surface-2, #F9FAFB);
    border-top: 1px solid var(--border, #E5E7EB);
    border-bottom: 1px solid var(--border, #E5E7EB);
}

.ts-heading {
    text-align: center;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text, #111827);
    margin: 0 0 0.5rem;
}

.ts-subhead {
    text-align: center;
    font-size: 0.92rem;
    color: var(--text-muted, #6B7280);
    margin: 0 0 1.25rem;
}

/* ── Search box wrapper ─────────────────────────────────────────────────────── */

.ts-search-wrap {
    position: relative;
    max-width: 560px;
    margin: 0 auto;
}

.ts-input-row {
    display: flex;
    align-items: center;
    background: var(--surface, #FFFFFF);
    border: 2px solid var(--border, #E5E7EB);
    border-radius: var(--radius, 16px);
    padding: 0 1rem;
    transition: border-color 0.18s, box-shadow 0.18s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.ts-input-row:focus-within {
    border-color: var(--brand, #FF7A00);
    box-shadow: 0 0 0 3px rgba(255,122,0,0.15);
}

.ts-search-icon {
    font-size: 1.1rem;
    color: var(--text-muted, #6B7280);
    flex-shrink: 0;
    margin-right: 0.5rem;
    line-height: 1;
    pointer-events: none;
}

.ts-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 1rem;
    color: var(--text, #111827);
    padding: 0.75rem 0;
    min-width: 0;
}

.ts-input::placeholder {
    color: var(--text-muted, #6B7280);
}

.ts-clear-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted, #6B7280);
    padding: 0.25rem;
    font-size: 1rem;
    line-height: 1;
    border-radius: 50%;
    display: none;
    transition: color 0.15s, background 0.15s;
}

.ts-clear-btn:hover {
    color: var(--text, #111827);
    background: var(--border, #E5E7EB);
}

.ts-input:not(:placeholder-shown) ~ .ts-clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Results dropdown ───────────────────────────────────────────────────────── */

.ts-results-box {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--surface, #FFFFFF);
    border: 1px solid var(--border, #E5E7EB);
    border-radius: var(--radius, 16px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    z-index: 1050;
    max-height: 420px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding: 4px;
}

.ts-results-list {
    list-style: none;
    margin: 0;
    padding: 0.375rem;
}

/* ── Result item ────────────────────────────────────────────────────────────── */

.ts-result-item {
    display: grid;
    grid-template-columns: 2.5rem 1fr;
    grid-template-rows: auto auto;
    column-gap: 0.75rem;
    row-gap: 0.1rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm, 10px);
    cursor: pointer;
    transition: background 0.12s;
    text-decoration: none;
    color: inherit;
    align-items: start;
}

.ts-result-item:hover,
.ts-result-item.ts-active {
    background: rgba(255,122,0,0.07);
}

.ts-result-icon {
    grid-row: 1 / 3;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding-top: 0.1rem;
}

.ts-result-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ts-result-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text, #111827);
}

.ts-result-cat {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--brand, #FF7A00);
    background: rgba(255,122,0,0.10);
    padding: 0.1em 0.55em;
    border-radius: 20px;
    white-space: nowrap;
}

.ts-result-desc {
    font-size: 0.8rem;
    color: var(--text-muted, #6B7280);
    line-height: 1.35;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}

/* ── No results ─────────────────────────────────────────────────────────────── */

.ts-no-results {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 1rem 1.25rem;
    color: var(--text-muted, #6B7280);
    font-size: 0.9rem;
    cursor: default;
}

.ts-no-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* ── View all ───────────────────────────────────────────────────────────────── */

.ts-view-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem;
    border-top: 1px solid var(--border, #E5E7EB);
    margin-top: 0.25rem;
    cursor: pointer;
    border-radius: 0 0 var(--radius-sm, 10px) var(--radius-sm, 10px);
    transition: background 0.12s;
    color: var(--brand, #FF7A00);
    font-size: 0.875rem;
    font-weight: 600;
}

.ts-view-all:hover,
.ts-view-all.ts-active {
    background: rgba(255,122,0,0.07);
}

.ts-view-all-arrow {
    font-size: 0.65rem;
    line-height: 1;
}

/* ── Popular chips ──────────────────────────────────────────────────────────── */

.ts-chips-wrap {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.875rem;
    padding: 0 0.5rem;
}

.ts-chips-label {
    font-size: 0.8rem;
    color: var(--text-muted, #6B7280);
    align-self: center;
    flex-shrink: 0;
}

.ts-chip {
    background: var(--surface, #FFFFFF);
    border: 1px solid var(--border, #E5E7EB);
    border-radius: 20px;
    padding: 0.3rem 0.85rem;
    font-size: 0.8rem;
    color: var(--text, #111827);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    white-space: nowrap;
    line-height: 1.4;
}

.ts-chip:hover,
.ts-chip:focus {
    border-color: var(--brand, #FF7A00);
    background: rgba(255,122,0,0.06);
    color: var(--brand-dark, #D96300);
    outline: none;
}

.ts-chip:focus-visible {
    box-shadow: 0 0 0 3px rgba(255,122,0,0.20);
}

/* ── Scrollbar ──────────────────────────────────────────────────────────────── */

.ts-results-box::-webkit-scrollbar {
    width: 6px;
}

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

.ts-results-box::-webkit-scrollbar-thumb {
    background: var(--border, #E5E7EB);
    border-radius: 3px;
}

/* ── Reduced motion ─────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .ts-input-row,
    .ts-result-item,
    .ts-chip,
    .ts-view-all,
    .ts-clear-btn {
        transition: none;
    }
}

/* ── Mobile ─────────────────────────────────────────────────────────────────── */

@media (max-width: 576px) {
    .ts-heading {
        font-size: 1.15rem;
    }

    .ts-result-desc {
        display: none;
    }

    .ts-result-item {
        grid-template-rows: auto;
        align-items: center;
    }

    .ts-results-box {
        max-height: 320px;
    }
}
