/**
 * Telemann Custom Search — Frontend Styles
 *
 * Drei Komponenten:
 *   .tsc-compact-*   Kompakte Such-Box (Startseite, Werkverzeichnis-Page)
 *   .tsp-*           Erweiterte Such-Form (auf /?s=, oder eigene Page)
 *   .tsl-*           Live-Search Dropdown (geteilt von beiden)
 *
 * Brand-Look:
 *   - Avenir Next Cyr Font
 *   - #AF1917 Akzent (Dark Red)
 *   - Pill-Form (border-radius: 999px) für Inputs/Buttons
 *   - Card-Container (border-radius: 8px, dezenter Border)
 */

/* ============================================================
   GEMEINSAM: Live-Search Dropdown
   ============================================================ */
.tsl-wrap {
    position: relative;
}

.tsl-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    max-height: 420px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    font-family: 'Avenir Next Cyr', 'Avenir Next', Arial, sans-serif;
}

.tsl-dropdown.is-open {
    display: block;
}

.tsl-dropdown a.tsl-item,
.tsl-dropdown a.tsl-item:visited {
    display: block;
    padding: 0.7rem 1rem;
    color: #222 !important;
    text-decoration: none !important;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    background: #fff;
}

.tsl-dropdown a.tsl-item:last-child {
    border-bottom: none;
}

.tsl-dropdown a.tsl-item:hover,
.tsl-dropdown a.tsl-item.is-active {
    background: #fff8f7;
    color: #AF1917 !important;
    text-decoration: none !important;
}

.tsl-item-title {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none !important;
}

.tsl-item-meta {
    display: block;
    color: #777;
    font-size: 0.82rem;
    margin-top: 2px;
    text-decoration: none !important;
}

.tsl-dropdown a.tsl-item:hover .tsl-item-meta,
.tsl-dropdown a.tsl-item.is-active .tsl-item-meta {
    color: #b46b69;
}

.tsl-dropdown a.tsl-show-all,
.tsl-dropdown a.tsl-show-all:visited {
    text-decoration: none !important;
}

.tsl-loading,
.tsl-status,
.tsl-empty {
    padding: 0.7rem 1rem;
    color: #777;
    font-size: 0.9rem;
    font-family: 'Avenir Next Cyr', 'Avenir Next', Arial, sans-serif;
}

.tsl-empty {
    text-align: center;
}

.tsl-show-all {
    display: block;
    text-align: center;
    background: #fafafa;
    padding: 0.65rem 1rem;
    color: #AF1917;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    border-top: 1px solid #ececec;
    position: sticky;
    bottom: 0;
}

.tsl-show-all:hover {
    background: #fff8f7;
}

/* ============================================================
   KOMBINIERTE SUCHE (Radio-Bereichswahl + Ergebnis-Bloecke)
   ============================================================ */
.tsc-mode-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.5rem;
    justify-content: center;
    margin-bottom: 0.9rem;
    font-family: 'Avenir Next Cyr', 'Avenir Next', Arial, sans-serif;
}

.tsc-mode-option {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    cursor: pointer;
    font-size: 0.95rem;
    color: #333;
}

.tsc-mode-option input[type="radio"] {
    width: 1.05rem;
    height: 1.05rem;
    accent-color: #AF1917;
    cursor: pointer;
}

/* Datumsfelder der kombinierten Suche: Pill-Optik wie die uebrigen Inputs
   (die Brief-Suche hat ihr Pendant blau-fokussiert in letter_module.css). */
.tsp-wrap--combined .tsp-date-input {
    width: 100%;
    font-family: inherit;
    font-size: 0.95rem;
    color: #222;
    background: #fff;
    border: 1px solid #cfcfcf;
    border-radius: 999px;
    padding: 0.45rem 0.9rem;
    min-height: 38px;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.tsp-wrap--combined .tsp-date-input:focus {
    border-color: #AF1917;
    outline: none;
}

/* Ergebnis-Bloecke der kombinierten erweiterten Suche */
.tsp-combined-section {
    margin-top: 2rem;
}

.tsp-combined-heading {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin: 0 0 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 2px solid #AF1917;
    font-size: 1.15rem;
    font-weight: 600;
    color: #AF1917;
}

/* Brief-Block in Briefedition-Blau — gleiche Farblogik wie die Module. */
.tsp-combined-heading--letters {
    border-bottom-color: #6173AE;
    color: #5F76EA;
}

.tsp-combined-count {
    font-size: 0.9rem;
    font-weight: 400;
    color: #777;
}

.tsp-combined-empty {
    color: #777;
    font-style: italic;
}

/* ============================================================
   KOMPAKTE SUCH-BOX
   1:1 ASP-Optik: ein großzügig dimensioniertes Pill, gerader sehr
   dezenter Border, Lupe rechts als reines Icon (keine Button-Kachel,
   kein Hover-Background). Klick aufs Icon oder Enter triggert Submit.
   ============================================================ */
.tsc-compact {
    font-family: 'Avenir Next Cyr', 'Avenir Next', 'Open Sans', Arial, sans-serif;
    max-width: 1100px;
    margin: 0 auto;
}

.tsc-compact-form {
    display: block;
}

/* Eingebettet (Startseite / Werkverzeichnis): Pille, Schatten und Hoehe
   kommen vom Elementor-Container der Agentur-Vorlage — unsere Box liegt
   randlos darin, wie vorher das Eingabefeld der alten Suche. */
.tsc-compact--embedded {
    max-width: none;
}

.tsc-compact--embedded .tsc-compact-box {
    border: 0;
    background: transparent;
    min-height: 0;
    padding-left: 0.75rem;
}

/* Tab-Zeile im eigenen Elementor-Container unter der Pille: dort sorgt der
   Container fuer den Abstand, nicht unser margin-top. */
.elementor-widget-shortcode > .elementor-widget-container > .tsc-tabs,
.elementor-shortcode > .tsc-tabs {
    margin-top: 0;
    gap: 0.5rem 25px; /* Abstand der frueheren Agentur-Buttons */
}

.tsc-compact-box {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 999px;
    min-height: 64px;
    padding: 0 0.5rem 0 1.75rem;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.tsc-compact-box:focus-within {
    border-color: #cccccc;
}

/* Doppelte Selektoren + !important wegen Theme- und Browser-Defaults,
   die sonst eigene Border/Background durchlassen. */
.tsc-compact-box .tsc-compact-input,
.tsc-compact-box input[type="search"].tsc-compact-input {
    flex: 1 1 auto;
    min-width: 0;
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    font-family: inherit;
    font-size: 1.15rem;
    font-weight: 400;
    color: #222;
    padding: 0.8rem 0.5rem;
    line-height: 1.2;
    height: auto;
    min-height: 0;
    -webkit-appearance: none;
    appearance: none;
}

.tsc-compact-box .tsc-compact-input:focus,
.tsc-compact-box .tsc-compact-input:hover {
    background: transparent !important;
    box-shadow: none !important;
    border: 0 !important;
    outline: none !important;
}

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

.tsc-compact-input::placeholder {
    color: #888;
    font-weight: 400;
}

/* Buttons im Compact-Box brauchen sehr hohe Specificity weil viele
   Themes button-Defaults globaler setzen. Doppelte Klassen + !important. */
.tsc-compact-box button.tsc-compact-clear,
.tsc-compact-box button.tsc-compact-submit {
    flex: 0 0 auto;
    border: 0 !important;
    border-radius: 50% !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    margin: 0;
    text-shadow: none !important;
    box-shadow: none !important;
    font-family: inherit;
    line-height: 1;
}

.tsc-compact-box button.tsc-compact-clear {
    width: 22px;
    height: 22px;
    margin-right: 8px !important;
    color: #fff !important;
    background: #c8c8c8 !important;
    background-color: #c8c8c8 !important;
    background-image: none !important;
    font-size: 11px !important;
    font-weight: normal !important;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.15s, background-color 0.15s;
    text-transform: none !important;
    letter-spacing: 0 !important;
}

.tsc-compact-box button.tsc-compact-clear.is-visible {
    visibility: visible;
    opacity: 1;
}

.tsc-compact-box button.tsc-compact-clear:hover {
    background: #888 !important;
    background-color: #888 !important;
    color: #fff !important;
}

.tsc-compact-box button.tsc-compact-submit {
    width: 44px;
    height: 44px;
    color: #b0b0b0 !important;
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    transition: color 0.15s;
}

.tsc-compact-box button.tsc-compact-submit:hover {
    color: #AF1917 !important;
    background: transparent !important;
    background-color: transparent !important;
}

.tsc-compact-box button.tsc-compact-submit svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
    display: block;
}

/* ============================================================
   TAB-LEISTE UNTER DER COMPACT-BOX
   (Erweiterte Suche / Incipitsuche / Besetzungssuche / Register)
   Aktive Items in Brand-Rot, inaktive in Grau, Icon rechts neben
   dem Label wie bei ASP.
   ============================================================ */
.tsc-tabs {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 2.5rem;
    margin: 1.25rem auto 0;
    padding: 0 1rem;
    font-family: 'Avenir Next Cyr', 'Avenir Next', 'Open Sans', Arial, sans-serif;
    font-size: 1rem;
    font-weight: 500;
}

.tsc-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    text-decoration: none !important;
    line-height: 1.2;
    background: transparent !important;
    border: 0 !important;
    padding: 0.3rem 0;
}

.tsc-tab.is-active {
    color: #AF1917 !important;
}

.tsc-tab.is-active:hover {
    color: #8a1311 !important;
    text-decoration: none !important;
}

.tsc-tab.is-inactive {
    color: #b8b8b8 !important;
    cursor: not-allowed;
}

.tsc-tab-label {
    display: inline-block;
}

.tsc-tab-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
}

.tsc-tab-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
    display: block;
}

@media (max-width: 600px) {
    .tsc-tabs {
        gap: 0.5rem 1.25rem;
        font-size: 0.95rem;
    }
}

/* ============================================================
   ERWEITERTE SUCH-FORM (bereits im Prototype, hierhin extrahiert)
   ============================================================ */
.tsp-wrap {
    font-family: 'Avenir Next Cyr', 'Avenir Next', Arial, sans-serif;
    color: #222;
    max-width: 1100px;
    margin: 0 auto;
}

.tsp-section-title {
    color: #AF1917;
    font-weight: 600;
    font-size: 1.15rem;
    margin: 1.5rem 0 0.75rem;
}

/* Ohne umgebenden Kasten (ADW-Wunsch 28.07., fuer Werke- UND Brief-Suche):
   die Form sitzt direkt im Seitenfluss, wie die oeffentliche Suche. */
.tsp-form {
    background: transparent;
    border: 0;
    padding: 0;
    margin-bottom: 1.5rem;
}

.tsp-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tsp-field-label {
    font-size: 0.78rem;
    color: #555;
    letter-spacing: 0.02em;
}

.tsp-form select,
.tsp-form input[type="text"],
.tsp-form input[type="search"] {
    font-family: inherit;
    font-size: 0.95rem;
    color: #222;
    background: #fff;
    border: 1px solid #cfcfcf;
    border-radius: 999px;
    padding: 0.45rem 0.9rem;
    min-height: 38px;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.tsp-form select:focus,
.tsp-form input:focus {
    outline: none;
    border-color: #AF1917;
}

.tsp-form select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%23555' d='M6 8L0 0h12z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.25rem;
    cursor: pointer;
}

.tsp-search-row {
    margin-bottom: 1rem;
}

.tsp-filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem 1rem;
}

@media (max-width: 1100px) {
    .tsp-filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .tsp-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
    .tsp-filter-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   ADVANCED-FORM: Volltextsuche-Toggle
   Standardmäßig ist die Volltextsuche-Zeile versteckt; ein
   "Volltextsuche einblenden"-Button öffnet sie.
   ============================================================ */
/* Toggle-Button: hoehere Specificity + !important damit Elementor/Theme-
   Default-Buttonstyles nicht in die Hover-Farbe pfuschen. */
button.tsp-fulltext-toggle,
.tsp-form button.tsp-fulltext-toggle {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.4rem !important;
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    border: 1px dashed #cfcfcf !important;
    border-radius: 999px !important;
    padding: 0.35rem 0.9rem !important;
    color: #555 !important;
    font-family: inherit !important;
    font-size: 0.85rem !important;
    cursor: pointer;
    margin-bottom: 1rem;
    transition: border-color 0.15s, color 0.15s, background-color 0.15s;
    text-decoration: none !important;
    text-shadow: none !important;
    box-shadow: none !important;
}

button.tsp-fulltext-toggle:hover,
.tsp-form button.tsp-fulltext-toggle:hover {
    background: #AF1917 !important;
    background-color: #AF1917 !important;
    background-image: none !important;
    border-color: #AF1917 !important;
    border-style: solid !important;
    color: #fff !important;
}

button.tsp-fulltext-toggle:hover .tsp-toggle-icon,
button.tsp-fulltext-toggle:hover span {
    color: #fff !important;
}

.tsp-fulltext-toggle .tsp-toggle-icon {
    transition: transform 0.15s;
    font-size: 0.7rem;
    line-height: 1;
}

.tsp-fulltext-toggle[aria-expanded="true"] .tsp-toggle-icon {
    transform: rotate(180deg);
}

button.tsp-fulltext-toggle[aria-expanded="true"],
.tsp-form button.tsp-fulltext-toggle[aria-expanded="true"] {
    border-style: solid !important;
    border-color: #AF1917 !important;
    color: #AF1917 !important;
}

.tsp-search-row[hidden] {
    display: none;
}

.tsp-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.tsp-btn,
a.tsp-btn,
a.tsp-btn:visited,
button.tsp-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #AF1917 !important;
    background-color: #AF1917 !important;
    background-image: none !important;
    color: #fff !important;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    border: 0 !important;
    border-radius: 999px !important;
    padding: 0.55rem 1.6rem !important;
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none !important;
    text-shadow: none !important;
    box-shadow: none !important;
}

.tsp-btn:hover,
a.tsp-btn:hover,
button.tsp-btn:hover {
    background: #8a1311 !important;
    background-color: #8a1311 !important;
    color: #fff !important;
    text-decoration: none !important;
}

.tsp-btn-reset,
a.tsp-btn-reset,
a.tsp-btn-reset:visited,
button.tsp-btn-reset {
    background: #e74c3c !important;
    background-color: #e74c3c !important;
    color: #fff !important;
    font-weight: 500;
    text-decoration: none !important;
}

.tsp-btn-reset:hover,
a.tsp-btn-reset:hover,
button.tsp-btn-reset:hover {
    background: #c4392b !important;
    background-color: #c4392b !important;
    color: #fff !important;
    text-decoration: none !important;
}

.tsp-btn-reset svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.tsp-reset {
    color: #555;
    text-decoration: underline;
    font-size: 0.9rem;
}

.tsp-reset:hover {
    color: #AF1917;
}

.tsp-results-meta {
    color: #555;
    font-size: 0.95rem;
    margin: 1rem 0;
}

.tsp-results-meta strong {
    color: #AF1917;
}

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

.tsp-result {
    padding: 0.85rem 0;
    border-bottom: 1px solid #ececec;
}

.tsp-result:last-child {
    border-bottom: none;
}

.tsp-result-title {
    color: #AF1917;
    /* !important: klassische WP-Pages (z. B. die _search-Testseiten) drueckten
       ihre a-Styles durch (Unterstreichung, duennes Gewicht); auf den
       Elementor-Seiten trat das nicht auf. Erzwingt konsistent fett + ohne
       Unterstrich, egal auf welchem Seitentyp. Gilt via geteilter Klasse auch
       fuer die Brief-Suche. */
    text-decoration: none !important;
    font-weight: 600 !important;
    font-size: 1rem;
}

.tsp-result-title:hover {
    text-decoration: underline !important;
}

.tsp-result-meta {
    display: block;
    color: #666;
    font-size: 0.85rem;
    margin-top: 2px;
}

.tsp-empty {
    background: #fff8f7;
    border: 1px solid #f1d8d6;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    color: #555;
}

/* Generelle Bodenfreiheit unter dem Results-Block, damit der
   nachfolgende Page-Inhalt (z. B. Feedback-Banner) nicht direkt
   am Empty-State / an der Trefferliste klebt. */
.tsp-results {
    margin-bottom: 3rem;
}

.tsp-pagination {
    margin: 1.5rem 0 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.tsp-pagination a,
.tsp-pagination .tsp-page-current {
    min-width: 32px;
    text-align: center;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    border: 1px solid #ddd;
    color: #555;
    font-size: 0.9rem;
    text-decoration: none;
}

.tsp-pagination a:hover {
    border-color: #AF1917;
    color: #AF1917;
}

.tsp-pagination .tsp-page-current {
    background: #AF1917;
    border-color: #AF1917;
    color: #fff;
    font-weight: 600;
}

/* Zweite Instanz ueber der Trefferliste (Werke- und Brief-Suche): enger an
   die Trefferzeile, Luft zur Liste. */
.tsp-pagination--top {
    margin: 0.25rem 0 1.25rem;
}

.tsp-pagination-gap {
    color: #aaa;
    padding: 0.3rem 0.4rem;
}

/* ============================================================
   FILTER COMBOBOX (Searchable Dropdown, Select2-ähnlich)
   Wichtig: width + min-width Constraints damit lange Werte den
   Grid-Track nicht ausdehnen.
   ============================================================ */
.tsp-filter-grid > .tsp-field {
    min-width: 0; /* Grid-Track darf schrumpfen, default ist min-content */
}

.tsp-combobox {
    position: relative;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.tsp-combobox-display {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    background: #fff !important;
    border: 1px solid #cfcfcf !important;
    border-radius: 999px !important;
    padding: 0.45rem 2.25rem 0.45rem 0.9rem !important;
    min-height: 38px;
    font-family: inherit;
    font-size: 0.95rem;
    color: #222 !important;
    cursor: pointer;
    text-align: left;
    box-shadow: none !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%23555' d='M6 8L0 0h12z'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: right 1rem center !important;
    transition: border-color 0.15s;
    overflow: hidden; /* harter Cut für Inner-Content der nicht truncated */
}

.tsp-combobox-display:hover {
    border-color: #aaa !important;
}

.tsp-combobox.is-open .tsp-combobox-display {
    border-color: #AF1917 !important;
}

.tsp-combobox-label {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    width: 100%;
    min-width: 0;
}

.tsp-combobox-label.is-placeholder {
    color: #888;
}

.tsp-combobox-popup {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    min-width: 280px;
}

.tsp-combobox-filter {
    width: 100%;
    border: 0 !important;
    border-bottom: 1px solid #ececec !important;
    border-radius: 0 !important;
    padding: 0.6rem 0.9rem !important;
    background: #fff !important;
    background-color: #fff !important;
    box-shadow: none !important;
    outline: none !important;
    font-family: inherit;
    font-size: 0.92rem;
    color: #222;
}

.tsp-combobox-filter:focus {
    border-bottom-color: #AF1917 !important;
}

.tsp-combobox-list {
    list-style: none !important;
    margin: 0 !important;
    padding: 0.25rem 0 !important;
    max-height: 320px;
    overflow-y: auto;
}

.tsp-combobox-option,
.tsp-combobox-clear {
    padding: 0.5rem 0.9rem;
    cursor: pointer;
    font-size: 0.92rem;
    line-height: 1.3;
    color: #222;
    border: 0;
    background: transparent;
    list-style: none;
}

.tsp-combobox-option:hover,
.tsp-combobox-option.is-active,
.tsp-combobox-clear:hover,
.tsp-combobox-clear.is-active {
    background: #fff8f7;
    color: #AF1917;
}

.tsp-combobox-clear {
    color: #888;
    font-style: italic;
    font-size: 0.85rem;
    border-bottom: 1px solid #f5f5f5;
}

.tsp-combobox-option mark {
    background: rgba(175, 25, 23, 0.15);
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

.tsp-combobox-empty,
.tsp-combobox-loading {
    padding: 0.7rem 0.9rem;
    color: #888;
    font-size: 0.9rem;
    font-style: italic;
    list-style: none;
}
