/**
 * TLA - KI ChatBot
 *
 * Farben aus der CI (siehe theme/assets/tailwind.config.js):
 *   blue-200  #05405D  - Flaeche Button/Header, Text weiss  -> 11.0:1
 *   gold      #9F8B75  - Akzent
 *   black     #1E1E1E  - Text
 *
 * Bewusst NICHT gold-auf-weiss fuer Text: das ergibt nur 3.3:1 und
 * verfehlt WCAG 2.1 AA (4.5:1).
 */

.tla-chatbot {
    --tla-chatbot-blue: #05405d;
    --tla-chatbot-blue-dark: #053147;
    --tla-chatbot-gold: #9f8b75;
    --tla-chatbot-black: #1e1e1e;
    --tla-chatbot-white: #fff;
    --tla-chatbot-radius: 2px;
    --tla-chatbot-space: 1.5rem;

    /* Vorgaben des Anbieters (siehe SimplyAI Einbindungs-Dokumentation). */
    --tla-chatbot-width: 400px;
    --tla-chatbot-height: 750px;
}

.tla-chatbot[hidden] {
    display: none;
}

/* ---------------------------------------------------------------- Launcher */

.tla-chatbot .tla-chatbot__launcher {
    position: fixed;
    right: var(--tla-chatbot-space);
    bottom: var(--tla-chatbot-space);

    /*
     * Bewusst unter dem Hotelchamp-Popup (z-index 2147473647): der Button
     * bleibt fix in der Ecke stehen. Er wird weder verschoben noch
     * ausgeblendet - wenn das Popup ihn kurzzeitig ueberdeckt, liegt es
     * einfach darueber.
     */
    z-index: 999990;

    display: inline-flex;
    align-items: center;
    gap: 0.75rem;

    margin: 0;
    padding: 1rem 1.5rem;
    border: 0;
    border-radius: var(--tla-chatbot-radius);

    background-color: var(--tla-chatbot-blue);
    color: var(--tla-chatbot-white);

    font-family: 'BrandonGrotesque-medium', 'BrandonGrotesque-regular', sans-serif;
    font-size: 1.0625rem;
    line-height: 1.25;

    cursor: pointer;
    box-shadow: 0 2px 12px rgb(0 0 0 / 25%);
    transition: background-color 0.2s ease;
}

.tla-chatbot .tla-chatbot__launcher:hover,
.tla-chatbot .tla-chatbot__launcher:focus-visible {
    background-color: var(--tla-chatbot-blue-dark);
}

.tla-chatbot .tla-chatbot__launcher-icon {
    display: inline-flex;
}

/* ------------------------------------------------------------------ Dialog */

.tla-chatbot .tla-chatbot__dialog {
    /*
     * Masse laut Anbieter-Doku (400x750), aber gedeckelt: 95vw in der Breite
     * und 100vh-120px in der Hoehe, damit bei gezoomten oder kleinen Screens
     * nichts abgeschnitten wird.
     */
    width: min(var(--tla-chatbot-width), 95vw);
    height: min(var(--tla-chatbot-height), calc(100vh - 120px));
    max-width: none;
    max-height: none;

    /* Verankerung unten rechts, buendig ueber dem Launcher. */
    margin: 0;
    position: fixed;
    inset: auto var(--tla-chatbot-space) var(--tla-chatbot-space) auto;

    padding: 0;
    border: 0;
    border-radius: var(--tla-chatbot-radius);
    overflow: hidden;

    background-color: var(--tla-chatbot-white);
    color: var(--tla-chatbot-black);
    box-shadow: 0 4px 24px rgb(0 0 0 / 30%);
}

.tla-chatbot .tla-chatbot__dialog:not([open]) {
    display: none;
}

/*
 * Dezenter Backdrop: der Dialog ist modal (Fokus bleibt drin, ESC schliesst),
 * die Seite soll aber optisch nicht komplett abgedunkelt werden.
 */
.tla-chatbot .tla-chatbot__dialog::backdrop {
    background-color: rgb(30 30 30 / 25%);
}

.tla-chatbot .tla-chatbot__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;

    padding: 0.875rem 1rem;
    border-bottom: 2px solid var(--tla-chatbot-gold);

    background-color: var(--tla-chatbot-blue);
    color: var(--tla-chatbot-white);
}

.tla-chatbot .tla-chatbot__heading {
    margin: 0;
    font-family: 'BrandonGrotesque-bold', sans-serif;
    font-size: 1.125rem;
    line-height: 1.3;
    color: inherit;
}

.tla-chatbot .tla-chatbot__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    /* 44x44 Zielflaeche - WCAG 2.5.8 */
    width: 44px;
    height: 44px;
    margin: -0.5rem -0.5rem -0.5rem 0;
    padding: 0;
    border: 0;
    border-radius: var(--tla-chatbot-radius);

    background: none;
    color: inherit;
    cursor: pointer;
}

.tla-chatbot .tla-chatbot__close:hover {
    background-color: rgb(255 255 255 / 15%);
}

.tla-chatbot .tla-chatbot__body {
    height: calc(100% - 4.25rem);
}

.tla-chatbot .tla-chatbot__frame {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ------------------------------------------------------------------- Fokus */

.tla-chatbot .tla-chatbot__launcher:focus-visible,
.tla-chatbot .tla-chatbot__close:focus-visible {
    outline: 3px solid var(--tla-chatbot-gold);
    outline-offset: 2px;
}

.tla-chatbot .tla-chatbot__close:focus-visible {
    outline-color: var(--tla-chatbot-white);
}

/* ------------------------------------------------------------------ Mobile */

@media (max-width: 640px) {
    .tla-chatbot .tla-chatbot__launcher {
        right: 1rem;
        bottom: 1rem;
        padding: 0.75rem 1rem;
    }

    /* Vollflaechig - der Chat braucht auf kleinen Screens den ganzen Platz. */
    .tla-chatbot .tla-chatbot__dialog {
        inset: 0;
        width: 100vw;
        height: 100dvh;
        border-radius: 0;
    }
}

/* --------------------------------------------------------- Reduced motion */

@media (prefers-reduced-motion: reduce) {
    .tla-chatbot .tla-chatbot__launcher {
        transition: none;
    }
}

/* ------------------------------------------------------------------- Druck */

@media print {
    .tla-chatbot {
        display: none;
    }
}

/* ------------------------------------------------------------- Kontrast    */

@media (prefers-contrast: more) {
    .tla-chatbot .tla-chatbot__launcher,
    .tla-chatbot .tla-chatbot__dialog {
        border: 2px solid var(--tla-chatbot-black);
    }
}
