/* KI-Suche (Startseite): Chat unter der Hero-Suchbox.
   Nutzt die Farbvariablen der Filterseiten. */
:root {
    --dorange: #FFB424;
    --hellblau: #EDF5FF;
    --dunkelblau: #2C5669;
    --mblau: #1A6D93;
    --morange: #FFC85E;
    --horange: #FFEEC4;
    --wblack: #1c1b1b;
}

.ai-search {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    margin: 1.2rem 0 1.5rem;
    text-align: left;
}

.ai-search-msg {
    line-height: 1.55;
}

.ai-search-msg-user {
    align-self: flex-end;
    max-width: min(80%, 640px);
    background: var(--mblau);
    color: #fff;
    font-weight: 600;
    padding: 0.7rem 1.1rem;
    border-radius: 18px 18px 4px 18px;
    overflow-wrap: anywhere;
}

/* Wie im KI-Tab der Filterseiten: die Antwort läuft rahmenlos über die volle
   Breite. Sie enthält Tabellen und Kurskarten, die in einer eingefärbten Blase
   mit Balken eingeschnürt wären. */
.ai-search-msg-ai {
    align-self: stretch;
    color: var(--wblack);
}

.ai-search-loading {
    color: var(--dunkelblau);
    font-style: italic;
}

.ai-search-error {
    color: #b00020;
    font-weight: bold;
    margin: 0;
}

/* ---------------------------------------------------------------------------
   Hero-Suchleiste: Kategorie-Filter + Suchfeld + Such-Button.
   Liegt hier statt in front-page.css, damit auch die Seite /suche/ den
   sichtbaren Button bekommt; die Höhe der Startseiten-Pille (68px) steht in
   front-page.css.
   --------------------------------------------------------------------------- */

.frontsearch-bar {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 12px;
    margin-top: 2rem;
}

/* Das Formular ist die sichtbare Suchpille: Rahmen, Rundung und Schatten sitzen
   hier, Feld und Such-Button liegen darin. */
.frontsearch-form {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 380px;
    min-width: 0;
    min-height: 56px;
    padding: 6px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 20px;
    box-shadow: 0 0.5px 22px 2px rgba(124, 158, 172, 0.5);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.frontsearch-form:focus-within {
    border-color: var(--mblau);
    box-shadow: 0 0 0 2px rgba(26, 109, 147, 0.25),
        0 0.5px 22px 2px rgba(124, 158, 172, 0.5);
}

/* Das Feld selbst ist randlos — die Optik kommt vom Formular. */
.frontsearch-form .frontsearch {
    flex: 1 1 auto;
    align-self: stretch;
    width: auto;
    min-width: 0;
    height: auto;
    margin: 0;
    padding: 0 8px 0 14px;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font-size: 16px;
}

.frontsearch-form .frontsearch:focus {
    outline: none;
}

/* Sitzt innerhalb der Pille und füllt sie bis auf das Innenmaß aus. */
.frontsearch-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 0 0 auto;
    align-self: stretch;
    padding: 0 22px;
    border: none;
    border-radius: 15px;
    background: var(--mblau);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: none;
    transition: background 0.2s ease;
}

.frontsearch-submit:hover:not(:disabled),
.frontsearch-submit:focus-visible:not(:disabled) {
    background: var(--dunkelblau);
    color: #fff;
}

.frontsearch-submit:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Kategorie-Filter */
.kl-catmenu {
    display: flex;
    flex: 0 0 auto;
}

.kl-catmenu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 0 20px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 20px;
    box-shadow: 0 0.5px 22px 2px rgba(124, 158, 172, 0.5);
    color: var(--dunkelblau);
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
}

.kl-catmenu-toggle:hover,
.kl-catmenu-toggle.is-open {
    border-color: var(--mblau);
    color: var(--mblau);
    background: #fff;
}

.kl-catmenu-toggle.is-open {
    box-shadow: 0 0 0 2px rgba(26, 109, 147, 0.25);
}

.kl-catmenu-chevron {
    transition: transform 0.2s ease;
}

.kl-catmenu-toggle.is-open .kl-catmenu-chevron {
    transform: rotate(180deg);
}

.kl-catmenu-panel {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    z-index: 30;
    padding: 26px 28px 20px;
    background: #fff;
    border: 1px solid #E2E8F0;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(44, 86, 105, 0.18);
    /* Das Panel wächst in die Breite (siehe front-page.css) statt zu scrollen;
       der Rahmen greift nur, wenn das Fenster wirklich zu niedrig ist. */
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    overscroll-behavior: contain;
    text-align: left;
}

.kl-catmenu-panel[hidden] {
    display: none;
}

.kl-catmenu-close {
    position: absolute;
    top: 14px;
    right: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    color: var(--wblack);
    cursor: pointer;
}

.kl-catmenu-close:hover {
    border-color: var(--mblau);
    color: var(--mblau);
    background: #fff;
}

/* Drei gleich breite, aber gedeckelte Spalten: sonst zieht es Name und Kurszahl
   auf breiten Schirmen weit auseinander. */
.kl-catmenu-columns {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 330px));
    justify-content: space-between;
    gap: 10px 40px;
    padding-right: 40px;
}

.kl-catmenu-column h3 {
    margin: 0 0 6px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--dorange);
    font-size: 0.8rem;
    font-weight: bold;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--mblau);
}

.kl-catmenu-column ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.kl-catmenu-column li + li {
    border-top: 1px solid #F1F5F9;
}

.kl-catmenu-column a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--wblack);
    font-size: 15px;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.kl-catmenu-column a:hover,
.kl-catmenu-column a:focus-visible {
    background: var(--hellblau);
    color: var(--mblau);
}

/* Der Pfeil rückt beim Überfahren leicht mit — kleiner Hinweis, dass die Zeile
   auf die Kategorieseite führt. */
.kl-catmenu-column a svg {
    transition: transform 0.15s ease, color 0.15s ease;
}

.kl-catmenu-column a:hover svg {
    transform: translateX(3px);
}

.kl-catmenu-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kl-catmenu-count {
    flex: 0 0 auto;
    color: #6B7D88;
    font-size: 14px;
}

.kl-catmenu-column a svg {
    flex: 0 0 auto;
    color: #9BB3C0;
}

.kl-catmenu-column a:hover svg {
    color: var(--mblau);
}

.kl-catmenu-all {
    display: inline-block;
    margin-top: 14px;
    color: var(--mblau);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.kl-catmenu-all:hover {
    color: var(--dunkelblau);
}

@media (max-width: 768px) {
    .frontsearch-bar {
        gap: 10px;
    }

    .kl-catmenu,
    .kl-catmenu-toggle {
        width: 100%;
    }

    .kl-catmenu-toggle {
        justify-content: space-between;
    }

    /* Feld und Button bleiben auch mobil zusammen in einer Pille — nur der
       Kategorie-Button rückt darüber. */
    .frontsearch-form {
        flex: 1 1 100%;
    }

    .frontsearch-form .frontsearch {
        padding-left: 10px;
    }

    .frontsearch-submit {
        padding: 0 14px;
        font-size: 15px;
    }

    .frontsearch-submit svg {
        display: none;
    }

    .kl-catmenu-panel {
        padding: 22px 16px 16px;
    }

    .kl-catmenu-columns {
        grid-template-columns: minmax(0, 1fr);
        gap: 18px;
        padding-right: 30px;
    }
}

/* Tablet: zwei Spalten statt drei sehr schmaler. */
@media (min-width: 769px) and (max-width: 1080px) {
    .kl-catmenu-columns {
        grid-template-columns: repeat(2, minmax(0, 330px));
        gap: 14px 32px;
    }
}

/* Anschlussfragen unter der letzten Antwort: ein Klick stellt die Frage als
   neuen Beitrag, der Verlauf darüber bleibt stehen. */
.ai-search-followups {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
}

.ai-search-followups-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: #94A3B8;
}

.ai-search-followups button {
    background: #F4F8FB;
    color: #42596B;
    border: 1px solid #E4EDF4;
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.ai-search-followups button:hover {
    background: var(--hellblau);
    border-color: #B9D4E6;
    color: var(--dunkelblau);
}
