/**
 * Frontend styles for the Typesense Advanced Search block.
 * Uses tas__ prefix to avoid conflicts with the autocomplete search block.
 */

:root {
    --tas-input-bg: #fff;
    --tas-input-border: #ddd;
    --tas-input-border-focus: #0073aa;
    --tas-input-radius: 4px;
    --tas-filter-bg: #f9f9f9;
    --tas-card-bg: #fff;
    --tas-card-border: #eee;
    --tas-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --tas-card-radius: 6px;
    --tas-chip-bg: #e8f4fc;
    --tas-chip-color: #0073aa;
    --tas-chip-query-bg: #fff3e2;
    --tas-chip-query-color: #a87c2f;
    --tas-highlight-bg: mark;
    --tas-page-btn-active-bg: #0073aa;
    --tas-page-btn-active-color: #fff;
    --tas-sidebar-width: 280px;
    --tas-search-btn-bg: #0073aa;
    --tas-search-btn-bg-hover: #005a87;
    --tas-search-btn-color: #fff;
    --tas-spinner-color: var(--tas-input-border-focus);
}

/* ========== Search Bar Label ========== */
.tas__search-bar-label {
    display: block;
    margin-bottom: 8px;
    font-size: var(--tas-search-bar-label-size, 14px);
    font-weight: var(--tas-search-bar-label-weight, 500);
    color: var(--tas-search-bar-label-color, #333);
}

/* ========== Search Bar ========== */
.tas__search-bar {
    margin-bottom: 20px;
    position: relative;
}

.tas__search-input-wrapper {
    display: flex;
    position: relative;
}

.tas__search-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    font-family: inherit;
    background: var(--tas-input-bg);
    border: 1px solid var(--tas-input-border);
    border-radius: var(--tas-input-radius);
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

/* When search button is present, adjust input border radius */
.tas__search-input-wrapper--with-button .tas__search-input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

.tas__search-input:focus {
    border-color: var(--tas-input-border-focus);
    box-shadow: 0 0 0 1px var(--tas-input-border-focus);
}

.tas__search-input::-webkit-search-cancel-button,
.tas__search-input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

/* Search input icon */
.tas__search-input-container {
    position: relative;
    flex: 1;
}

.tas__search-input-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tas-search-input-icon-color, #666);
    pointer-events: none;
    z-index: 1;
}

.tas__search-input-icon svg {
    display: block;
    width: var(--tas-search-input-icon-size, 20px);
    height: var(--tas-search-input-icon-size, 20px);
}

/* Icon on left */
.tas__search-input-wrapper--icon-left .tas__search-input-icon {
    left: 12px;
}

.tas__search-input-wrapper--icon-left .tas__search-input {
    padding-left: calc(12px + var(--tas-search-input-icon-size, 20px) + 8px);
}

/* Icon on right */
.tas__search-input-wrapper--icon-right .tas__search-input-icon {
    right: 12px;
}

.tas__search-input-wrapper--icon-right .tas__search-input {
    padding-right: calc(12px + var(--tas-search-input-icon-size, 20px) + 8px);
}

/* Search button */
.tas__search-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    background: var(--tas-search-btn-bg);
    color: var(--tas-search-btn-color);
    border: 1px solid var(--tas-search-btn-bg);
    border-radius: 0 var(--tas-input-radius) var(--tas-input-radius) 0;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    flex-shrink: 0;
}

.tas__search-button:hover {
    background: var(--tas-search-btn-bg-hover);
    border-color: var(--tas-search-btn-bg-hover);
}

.tas__search-button:focus-visible {
    outline: revert;
}

.tas__search-button-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.tas__search-button-icon svg {
    display: block;
}

.tas__search-button-text {
    white-space: nowrap;
}

.tas__search-button--icon-right {
    flex-direction: row-reverse;
}

/* Internal button (inside input) */
.tas__search-button--internal {
    position: absolute;
    right: var(--tas-internal-btn-offset, 6px);
    top: 50%;
    transform: translateY(-50%);
    padding: var(--tas-internal-btn-padding, 10px);
    border-radius: var(--tas-internal-btn-radius, 50%);
    z-index: 2;
}

.tas__search-input-wrapper--with-internal-button .tas__search-input {
    padding-right: calc(var(--tas-internal-btn-offset, 6px) + var(--tas-internal-btn-size, 42px) + 8px);
}

/* When both internal button and right icon exist, adjust icon position */
.tas__search-input-wrapper--with-internal-button.tas__search-input-wrapper--icon-right .tas__search-input-icon {
    right: calc(var(--tas-internal-btn-offset, 6px) + var(--tas-internal-btn-size, 42px) + 12px);
}

.tas__search-input-wrapper--with-internal-button.tas__search-input-wrapper--icon-right .tas__search-input {
    padding-right: calc(var(--tas-internal-btn-offset, 6px) + var(--tas-internal-btn-size, 42px) + var(--tas-search-input-icon-size, 20px) + 20px);
}

/* ========== Suggestions Dropdown ========== */
.tas__suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    max-height: 400px;
    overflow-y: auto;
    background: var(--tas-card-bg);
    border: 1px solid var(--tas-input-border);
    border-top: none;
    border-radius: 0 0 var(--tas-card-radius) var(--tas-card-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tas__suggestions--hidden {
    display: none;
}

.tas__suggestions-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tas__suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--tas-card-border);
    transition: background-color 0.1s ease;
}

.tas__suggestion-item:last-child {
    border-bottom: none;
}

.tas__suggestion-item:hover,
.tas__suggestion-item--selected {
    background: #f5f5f5;
}

.tas__suggestion-item--selected {
    background: var(--tas-chip-bg);
}

.tas__suggestion-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.tas__suggestion-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.tas__suggestion-title {
    font-weight: 600;
    font-size: 14px;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tas__suggestion-type {
    flex-shrink: 0;
    padding: 1px 6px;
    font-size: 0.65em;
    font-weight: 500;
    text-transform: uppercase;
    background: #e0e0e0;
    color: #555;
    border-radius: 3px;
}

.tas__suggestion-snippet {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tas__suggestion-snippet mark {
    background: var(--tas-highlight-bg);
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

.tas__suggestion-document {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    padding-top: 4px;
    font-size: 12px;
    color: #888;
    border-top: 1px dashed #eee;
}

.tas__suggestion-document-icon {
    flex-shrink: 0;
}

.tas__suggestion-document-filename {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.tas__suggestion-document-page {
    flex-shrink: 0;
    color: #fff;
    background: #888;
    padding: 0 4px;
    border-radius: 3px;
    font-size: 0.9em;
}

.tas__suggestion-document-snippet {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tas__suggestions-empty {
    padding: 16px;
    text-align: center;
    color: #888;
    font-size: 14px;
}

.tas__suggestions-loading {
    padding: 16px;
    text-align: center;
    color: #888;
    font-size: 14px;
}

/* ========== Body Layout ========== */

/* Vertical: sidebar left, results right */
.tas__body--vertical {
    display: grid;
    grid-template-columns: var(--tas-sidebar-width) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

/* Horizontal: filters as top bar, results below */
.tas__body--horizontal {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tas__body--horizontal .tas__filters-content {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.tas__body--horizontal .tas__filter-group {
    flex: 1;
    min-width: 180px;
}

/* ========== Filters Sidebar ========== */
.tas__filters-content {
    padding: 0;
}

.tas__body--vertical .tas__filters-content {
    padding: 16px;
    background: var(--tas-filter-bg);
    border-radius: var(--tas-card-radius);
}

.tas__filters-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--tas-text-color);
    margin: 0 0 16px 0;
    padding: 0;
}

.tas__filter-group {
    margin-bottom: 16px;
}

.tas__filter-group:last-child {
    margin-bottom: 0;
}

.tas__filter-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #555;
}

/* ========== Icons ========== */
.tas__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}

.tas__icon svg {
    width: 1em;
    height: 1em;
}

.tas__filter-label-icon {
    font-size: 1.1em;
}

.tas__filter-term-icon {
    margin-right: 2px;
    font-size: 1em;
}

.tas__field-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
}

.tas__field-icon svg {
    width: 1em;
    height: 1em;
}

/* ========== Slots ========== */
.tas__slot {
    /* Base slot styles - can be customized by theme */
}

.tas__slot--before-search,
.tas__slot--after-search {
    margin-bottom: 16px;
}

.tas__slot--before-filters {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--tas-input-border);
}

.tas__slot--after-filters {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--tas-input-border);
}

.tas__slot--before-results {
    margin-bottom: 16px;
}

.tas__slot--after-results {
    margin-top: 16px;
}

/* Select filters */
.tas__filter-select {
    width: 100%;
    padding: 8px 30px 8px 10px;
    font-size: 14px;
    font-family: inherit;
    background: var(--tas-input-bg);
    border: 1px solid var(--tas-input-border);
    border-radius: var(--tas-input-radius);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23555' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
    box-sizing: border-box;
}

.tas__filter-select:focus {
    border-color: var(--tas-input-border-focus);
    outline: none;
    box-shadow: 0 0 0 1px var(--tas-input-border-focus);
}

/* Checkbox & radio filters */
.tas__filter-options {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tas__filter-option {
    margin-bottom: 4px;
}

.tas__filter-option label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 0;
}

.tas__filter-option label .tas__filter-term-label {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
}

.tas__filter-option input[type="checkbox"],
.tas__filter-option input[type="radio"] {
    margin: 0;
    flex-shrink: 0;
}

.tas__filter-count {
    color: #999;
    font-size: 12px;
    margin-left: auto;
}

.tas__filter-count:empty {
    display: none;
}

.tas__filter-option--disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* Hidden filter (depends_on not met) */
.tas__filter-group--hidden {
    display: none;
}

/* ========== Date Filter ========== */
.tas__filter-group--date {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tas__filter-date-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
    color: #333;
}

.tas__filter-date-input {
    padding: 8px 10px;
    font-size: 14px;
    font-family: inherit;
    background: var(--tas-input-bg);
    border: 1px solid var(--tas-input-border);
    border-radius: var(--tas-input-radius);
    outline: none;
    width: 100%;
    box-sizing: border-box;
}

.tas__filter-date-input:focus {
    border-color: var(--tas-input-border-focus);
}

.tas__filter-alt-dates-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    margin-top: 4px;
}

.tas__filter-alt-dates-checkbox {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
}

/* ========== Group Filters ========== */
.tas__filter-group--group {
    /* Inherits base filter-group styles */
}

/* Collapsible header */
.tas__filter-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0;
    margin-bottom: 12px;
    font-family: inherit;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
}

.tas__filter-group-header .tas__filter-label {
    margin-bottom: 0;
}

.tas__filter-collapse-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--tas-collapse-icon-color, #666);
    transition: transform 0.2s ease;
    transform: rotate(var(--tas-collapse-icon-expanded, 0deg));
}

.tas__filter-collapse-icon svg {
    display: block;
    width: 1em;
    height: 1em;
}

.tas__filter-group-header[aria-expanded="false"] .tas__filter-collapse-icon {
    transform: rotate(var(--tas-collapse-icon-collapsed, -90deg));
}

/* Collapsible content */
.tas__filter-group-content {
    /* default visible */
}

.tas__filter-group-content--collapsed {
    display: none;
}

/* Grid layout for fields */
.tas__field-group {
    display: grid;
    grid-template-columns: repeat(var(--columns, 2), 1fr);
    gap: var(--gap, 12px);
}

.tas__field-group-field {
    grid-column: var(--column, auto);
    grid-row: var(--row, auto);
}

.tas__field-group-field--full-width {
    grid-column: 1 / -1;
}

/* Field label */
.tas__field-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
    color: #333;
}

/* Field inputs */
.tas__field-input {
    padding: 8px 10px;
    font-size: 14px;
    font-family: inherit;
    background: var(--tas-input-bg);
    border: 1px solid var(--tas-input-border);
    border-radius: var(--tas-input-radius);
    outline: none;
    width: 100%;
    box-sizing: border-box;
}

.tas__field-input:focus {
    border-color: var(--tas-input-border-focus);
    box-shadow: 0 0 0 1px var(--tas-input-border-focus);
}

.tas__field-input--select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23555' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
    cursor: pointer;
}

/* Checkbox field */
.tas__field-group-field--checkbox {
    display: flex;
    align-items: center;
}

.tas__field-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
}

.tas__field-checkbox {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
}

.tas__field-checkbox-text {
    flex: 1;
}

/* Tooltip */
.tas__field-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    border: 1px solid currentColor;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
}

.tas__field-tooltip:hover,
.tas__field-tooltip:focus {
    color: #333;
}

.tas__field-tooltip:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.tas__field-tooltip-text {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
    padding: 8px 12px;
    border-radius: 6px;
    white-space: normal;
    width: max-content;
    max-width: 250px;
    text-align: left;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.tas__field-tooltip-text::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #333;
}

.tas__field-tooltip--active .tas__field-tooltip-text,
.tas__field-tooltip:hover .tas__field-tooltip-text {
    display: block;
}

/* Radio group */
.tas__field-radio-group {
    border: none;
    margin: 0;
    padding: 0;
}

.tas__field-radio-group legend {
    margin-bottom: 6px;
}

.tas__field-radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 0;
}

.tas__field-radio {
    margin: 0;
    cursor: pointer;
}

/* ========== Active Filter Chips ========== */
.tas__active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
    align-items: center;
}

.tas__active-filters--hidden {
    display: none;
}

.tas__active-filters-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--tas-text-color);
    margin-right: 4px;
}

.tas__chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 13px;
    background: var(--tas-chip-bg);
    color: var(--tas-chip-color);
    border-radius: 20px;
    white-space: nowrap;
    border: 1px solid var(--tas-chip-color);
}

.tas__chip--query {
    background: var(--tas-chip-query-bg);
    color: var(--tas-chip-query-color);
    font-style: italic;
    border-color: var(--tas-chip-query-color);
}

.tas__chip button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    font-size: 14px;
    line-height: 1;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.7;
    border-radius: 50%;
}

.tas__chip button:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.1);
}

.tas__clear-all {
    padding: 4px 10px;
    font-size: 13px;
    font-family: inherit;
    background: none;
    border: 1px solid var(--tas-input-border);
    border-radius: 20px;
    cursor: pointer;
    color: #666;
}

.tas__clear-all:hover {
    background: #f5f5f5;
    color: #333;
}

/* ========== Results Header ========== */
.tas__results-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    flex-wrap: wrap;
}

.tas__results-header--hidden {
    display: none;
}

.tas__results-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
}

.tas__results-count {
    font-weight: 400;
    color: #888;
}

/* ========== Header Filters ========== */
.tas__header-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.tas__header-filter {
    position: relative;
}

.tas__header-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    background: var(--tas-card-bg);
    border: 1px solid var(--tas-input-border);
    border-radius: var(--tas-input-radius);
    cursor: pointer;
    color: #333;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tas__header-filter-btn:hover {
    background: #f5f5f5;
    border-color: #bbb;
}

.tas__header-filter-btn[aria-expanded="true"] {
    border-color: var(--tas-input-border-focus);
    box-shadow: 0 0 0 1px var(--tas-input-border-focus);
}

/* Status dot (left) — neutral by default, themeable to a brand colour when a
   refinement is active via the `--active` modifier. */
.tas__header-filter-dot,
.tas__header-filter-icon {
    display: inline-flex;
    flex-shrink: 0;
    line-height: 0;
}

.tas__header-filter-dot {
    color: #bbb;
}

.tas__header-filter--active .tas__header-filter-dot {
    color: currentColor;
}

.tas__header-filter-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Disabled: the post type is selected but the chosen type has no sub-types. */
.tas__header-filter--disabled .tas__header-filter-btn {
    opacity: 0.5;
    cursor: not-allowed;
}

.tas__header-filter-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 100;
    min-width: 180px;
    max-width: 280px;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 4px;
    background: var(--tas-card-bg);
    border: 1px solid var(--tas-input-border);
    border-radius: var(--tas-card-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.tas__header-filter-dropdown[hidden] {
    display: none;
}

.tas__header-filter-list {
    list-style: none;
    margin: 0;
    padding: 4px 0;
}

.tas__header-filter-item {
    margin: 0;
}

.tas__header-filter-item label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.tas__header-filter-item label:hover {
    background: #f5f5f5;
}

.tas__header-filter-item input[type="checkbox"] {
    margin: 0;
    flex-shrink: 0;
}

.tas__header-filter-item span {
    flex: 1;
    min-width: 0;
}

/* ========== Results ========== */
.tas__results {
    position: relative;
    min-height: 100px;
    min-width: 0;
    overflow: hidden;
}

.tas__results--loading {
    opacity: 0.5;
    pointer-events: none;
}

.tas__loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.tas__spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--tas-input-border);
    border-top-color: var(--tas-spinner-color);
    border-radius: 50%;
    animation: tas-spin 0.7s linear infinite;
}

/* Smaller spinner used inside the suggestions dropdown. */
.tas__spinner--sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

/* Loading row shown in the suggestions dropdown while a fetch is in flight. */
.tas__suggestions-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
}

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

@media (prefers-reduced-motion: reduce) {
    .tas__spinner {
        animation-duration: 1.5s;
    }
}

/* Result card */
.tas__result-card {
    padding: 16px;
    margin-bottom: 12px;
    background: var(--tas-card-bg);
    border: 1px solid var(--tas-card-border);
    border-radius: var(--tas-card-radius);
    overflow: hidden;
    min-width: 0;
    box-shadow: var(--tas-card-shadow);
}

.tas__result-card:last-child {
    margin-bottom: 0;
}

.tas__result-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.tas__result-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    flex: 1;
    min-width: 0;
}

.tas__result-title a {
    color: inherit;
    text-decoration: none;
}

.tas__result-title a:hover {
    text-decoration: underline;
}

.tas__result-type {
    flex-shrink: 0;
    padding: 1px 6px;
    font-size: 0.7em;
    font-weight: 500;
    text-transform: uppercase;
    background: #e0e0e0;
    color: #555;
    border-radius: 3px;
}

.tas__result-snippet {
    margin: 0 0 6px;
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

.tas__result-snippet mark,
.tas__result-card mark {
    background: var(--tas-highlight-bg);
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

.tas__result-documents {
    margin-top: 6px;
    min-width: 0;
    overflow: hidden;
    padding: 4px;
}

.tas__result-document {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
    font-size: 13px;
    color: #666;
    border-top: 1px dashed #eee;
    min-width: 0;
}

.tas__result-document-icon {
    flex-shrink: 0;
}

.tas__result-document-filename {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.tas__result-document-page {
    flex-shrink: 0;
    color: #fff;
    background: #888;
    padding: 0 4px;
    border-radius: 3px;
    font-size: 0.9em;
}

.tas__result-document-snippet {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Document matches toggle */
.tas__result-documents-hidden[hidden] {
    display: none;
}

.tas__result-documents-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding: 4px 0;
    font-size: 13px;
    font-family: inherit;
    color: var(--tas-chip-color);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
}

.tas__result-documents-toggle:hover {
    color: #005a87;
}

/* Clickable document links */
a.tas__result-document--clickable {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

a.tas__result-document--clickable:hover {
    background-color: #f0f7fc;
}

a.tas__result-document--clickable:hover .tas__result-document-filename {
    color: #0073aa;
    text-decoration: underline;
}

.tas__result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.tas__result-badge {
    padding: 1px 6px;
    font-size: 0.7em;
    font-weight: 500;
    border-radius: 3px;
    white-space: nowrap;
}

/* Card footer info */
.tas__card-footer-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* No results */
.tas__no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 15px;
}

/* ========== Pagination ========== */
.tas__pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.tas__page-prev,
.tas__page-next,
.tas__page-num {
    padding: 6px 12px;
    font-size: 14px;
    font-family: inherit;
    background: var(--tas-card-bg);
    border: 1px solid var(--tas-input-border);
    border-radius: var(--tas-input-radius);
    cursor: pointer;
    color: inherit;
    transition: background-color 0.15s ease;
}

.tas__page-prev:hover,
.tas__page-next:hover,
.tas__page-num:hover {
    background: #f5f5f5;
}

.tas__page-num[aria-current="page"] {
    background: var(--tas-page-btn-active-bg);
    color: var(--tas-page-btn-active-color);
    border-color: var(--tas-page-btn-active-bg);
}

.tas__page-prev:disabled,
.tas__page-next:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tas__page-ellipsis {
    padding: 6px 4px;
    color: #999;
}

/* ========== Responsive: compact mode (tablet / mobile) ========== */
/*
 * Below the JS breakpoint (1024px) the widget container receives the
 * `.tas--mobile` class and JS relocates the sidebar into a modal and the
 * "refine" dropdown into a bottom-sheet. Everything here is functional layout
 * only — the theme supplies the visual design (colours, typography, pill
 * buttons, icons, open/close animation).
 */

/* Compact search button (inside the input) + mobile toolbar are hidden until
   compact mode kicks in. */
.tas__search-button--compact,
.tas__mobile-bar {
    display: none;
}

/* Transparent wrapper so relocating the "refine" filters does not disturb the
   flex layout of the results header (keeps .tas__header-filters right-aligned). */
.tas__header-filters-host {
    display: contents;
}

/* The modal and the sheet backdrop stay out of the flow until JS opens them.
   These win over the base `display` rules below because [hidden] is matched
   with equal-or-higher specificity here. */
.tas__filters-modal[hidden],
.tas__sheet-backdrop[hidden] {
    display: none;
}

/* Scroll lock applied to <body> while a modal / sheet is open. */
.tas-no-scroll {
    overflow: hidden;
}

/* Filters modal — full-screen overlay. Opens with a fade-in. */
.tas__filters-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.tas__filters-modal--open {
    opacity: 1;
}

.tas__filters-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
}

.tas__filters-modal__dialog {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: #fff;
    overflow: hidden;
}

.tas__filters-modal__header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: none;
}

.tas__filters-modal__title {
    flex: 1 1 auto;
    margin: 0;
}

.tas__filters-modal__body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.tas__filters-modal__footer {
    flex: none;
}

.tas__filters-modal-close,
.tas__filters-reset,
.tas__apply-filters {
    cursor: pointer;
    font-family: inherit;
}

.tas__apply-filters,
.tas__sheet-apply {
    display: block;
    width: 100%;
}

/* Refine bottom-sheet backdrop (shared, toggled by JS). */
.tas__sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.4);
}

/* The sheet "apply" button + title only exist in compact mode. */
.tas__sheet-apply {
    display: none;
    cursor: pointer;
    font-family: inherit;
}

.tas__sheet-title {
    display: none;
}

.tas--mobile .tas__sheet-title {
    display: block;
}

/* ---------- Compact-mode reflow (root class toggled by JS) ---------- */
.tas--mobile .tas__body--vertical {
    grid-template-columns: 1fr; /* single column — one card per row */
}

/* Sidebar is hidden; its content is relocated into the modal by JS. */
.tas--mobile .tas__filters {
    display: none;
}

/* Swap the external search button for the compact in-input one. */
.tas--mobile .tas__search-button:not(.tas__search-button--compact) {
    display: none;
}

.tas--mobile .tas__search-button--compact {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    cursor: pointer;
}

/* Leave room for the compact button so the query text doesn't slide under it. */
.tas--mobile .tas__search-input {
    padding-right: 48px;
}

/* Mobile toolbar: Filters (left) + refine (right). */
.tas--mobile .tas__mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.tas--mobile .tas__filters-modal-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-family: inherit;
}

/* Present the refine dropdown as a bottom-sheet that slides up from the bottom.
   The `tas--sheet-open` class is added one frame after the panel is shown (JS),
   so the transform transition runs. */
.tas--mobile .tas__header-filter-dropdown {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 1000000;
    min-width: 0;
    max-width: none;
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.tas--mobile.tas--sheet-open .tas__header-filter-dropdown {
    transform: translateY(0);
}

.tas--mobile .tas__sheet-apply {
    display: block;
}

/* ========== Search Bar Wrapper (for custom backgrounds) ========== */
.tas__search-bar-wrapper {
    /* Override in theme for custom background/padding */
}

.tas__search-input-container {
    display: flex;
    position: relative;
    flex-grow: 1;
}