/*
 * Chat-Widget Anouk (dieVorturner)
 * Alle Selektoren hängen an .anouk bzw. tragen das Präfix anouk-, damit das
 * Widget auf der Live-Website nicht mit deren Styles kollidiert.
 *
 * Übernommen aus dem Prototyp (chatbot/online/styles.css), ergänzt um die
 * Zustimmungsansicht (.anouk-zustimmung) und ihren Hinweis. Gehört zu public/js/anouk.js und
 * resources/views/partials/_anouk.blade.php – siehe docs/CHATBOT_ANOUK.md.
 */
.anouk {
    --anouk-primaer: #009ab1;
    --anouk-primaer-dunkel: #007f92;
    --anouk-primaer-hell: #e0f3f6;
    --anouk-text: #191e23;
    --anouk-text-sekundaer: #555d66;
    --anouk-linie: #e2e4e7;
    --anouk-weiss: #ffffff;
    --anouk-nutzer: #f1f2f4;

    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 2147483000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    color: var(--anouk-text);
}

.anouk *,
.anouk *::before,
.anouk *::after {
    box-sizing: border-box;
}

.anouk button,
.anouk input {
    font: inherit;
    margin: 0;
    float: none;
    box-shadow: none;
}

.anouk [hidden] {
    display: none !important;
}

/* Öffnen-Button */
.anouk-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--anouk-primaer);
    color: var(--anouk-weiss);
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(25, 30, 35, 0.25) !important;
    transition: background-color 0.2s, transform 0.2s;
}

.anouk-toggle:hover {
    background: var(--anouk-primaer-dunkel);
    transform: scale(1.05);
}

.anouk-toggle:focus-visible,
.anouk-icon-button:focus-visible,
.anouk-send:focus-visible,
.anouk-beispiel:focus-visible {
    outline: 3px solid var(--anouk-text);
    outline-offset: 2px;
}

.anouk-toggle svg {
    width: 30px;
    height: 30px;
}

.anouk-toggle .anouk-icon-schliessen {
    display: none;
}

.anouk.is-open .anouk-toggle .anouk-icon-chat {
    display: none;
}

.anouk.is-open .anouk-toggle .anouk-icon-schliessen {
    display: block;
}

/* Panel */
.anouk-panel {
    position: absolute;
    left: 0;
    bottom: 76px;
    display: flex;
    flex-direction: column;
    width: 380px;
    height: 560px;
    max-height: calc(100vh - 116px);
    overflow: hidden;
    background: var(--anouk-weiss);
    border: 1px solid var(--anouk-linie);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(25, 30, 35, 0.22);
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px) scale(0.98);
    transform-origin: bottom left;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
}

.anouk.is-open .anouk-panel {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s;
}

/* Kopfzeile */
.anouk-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 12px 14px 16px;
    background: var(--anouk-primaer);
    color: var(--anouk-weiss);
}

.anouk-avatar {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--anouk-weiss);
    color: var(--anouk-primaer);
    font-weight: 700;
    font-size: 17px;
}

.anouk-titel {
    flex: 1 1 auto;
    min-width: 0;
}

.anouk-name {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.2;
    color: inherit;
}

.anouk-untertitel {
    margin: 2px 0 0;
    font-size: 13px;
    opacity: 0.9;
}

.anouk-icon-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.anouk-icon-button:hover {
    background: rgba(255, 255, 255, 0.18);
}

.anouk-icon-button svg {
    width: 20px;
    height: 20px;
}

/* Nachrichten */
.anouk-nachrichten {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    background: var(--anouk-weiss);
    overscroll-behavior: contain;
}

.anouk-nachricht {
    max-width: 85%;
    margin: 0 0 10px;
    padding: 9px 13px;
    border-radius: 14px;
    overflow-wrap: anywhere;
    white-space: normal;
}

.anouk-nachricht--bot {
    margin-right: auto;
    background: var(--anouk-primaer-hell);
    border-bottom-left-radius: 4px;
}

/* Kurslinks: Türkis auf weißem Grund statt auf der hellen Blase (Kontrast 3,4:1
   statt 2,9:1), dazu fett und unterstrichen. */
.anouk-nachricht--bot a {
    padding: 0 3px;
    border-radius: 3px;
    background: var(--anouk-weiss);
    color: var(--anouk-primaer);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.anouk-nachricht--bot a:hover,
.anouk-nachricht--bot a:focus-visible {
    color: var(--anouk-primaer-dunkel);
}

.anouk-nachricht--bot a:focus-visible {
    outline: 2px solid var(--anouk-text);
    outline-offset: 1px;
}

.anouk-nachricht--nutzer {
    margin-left: auto;
    background: var(--anouk-nutzer);
    border: 1px solid var(--anouk-linie);
    border-bottom-right-radius: 4px;
    white-space: pre-wrap;
}

.anouk-nachricht--fehler {
    color: var(--anouk-text);
    border-left: 3px solid var(--anouk-primaer);
}

/* Beispielfragen */
.anouk-beispiele {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 12px;
}

.anouk-beispiel {
    padding: 7px 12px;
    border: 1px solid var(--anouk-primaer);
    border-radius: 999px;
    background: var(--anouk-weiss);
    color: var(--anouk-primaer-dunkel);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.anouk-beispiel:hover {
    background: var(--anouk-primaer);
    color: var(--anouk-weiss);
}

.anouk-beispiel:disabled {
    opacity: 0.5;
    cursor: default;
}

/* Tipp-Anzeige */
.anouk-tippt {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 12px 14px;
}

.anouk-tippt span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--anouk-primaer);
    animation: anouk-punkt 1.2s infinite ease-in-out;
}

.anouk-tippt span:nth-child(2) {
    animation-delay: 0.15s;
}

.anouk-tippt span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes anouk-punkt {
    0%, 60%, 100% {
        opacity: 0.35;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-4px);
    }
}

/* Eingabezeile */
.anouk-eingabe {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--anouk-linie);
    background: var(--anouk-weiss);
}

.anouk-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--anouk-linie);
    border-radius: 10px;
    background: var(--anouk-weiss);
    color: var(--anouk-text);
    font-size: 16px; /* verhindert Auto-Zoom auf iOS */
}

.anouk-input::placeholder {
    color: var(--anouk-text-sekundaer);
}

.anouk-input:focus {
    outline: none;
    border-color: var(--anouk-primaer);
    box-shadow: 0 0 0 3px rgba(0, 154, 177, 0.2);
}

.anouk-send {
    flex: 0 0 auto;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    background: var(--anouk-primaer);
    color: var(--anouk-weiss);
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s;
}

.anouk-send:hover {
    background: var(--anouk-primaer-dunkel);
}

.anouk-send:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Fußzeile */
.anouk-fusszeile {
    margin: 0;
    padding: 8px 14px 10px;
    background: var(--anouk-weiss);
    color: var(--anouk-text-sekundaer);
    font-size: 12px;
    line-height: 1.35;
    text-align: center;
}

.anouk-sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Zustimmungsansicht: steht anstelle von Nachrichten und Eingabe, solange im
   Consent-Tool nicht zugestimmt wurde. */
.anouk-zustimmung {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: center;
    padding: 20px 18px;
    overflow-y: auto;
    background: var(--anouk-weiss);
}

.anouk-zustimmung p {
    margin: 0;
    color: var(--anouk-text);
}

.anouk-zustimmung a {
    color: var(--anouk-primaer-dunkel);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.anouk-zustimmung-knopf {
    align-self: flex-start;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    background: var(--anouk-primaer);
    color: var(--anouk-weiss);
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s;
}

.anouk-zustimmung-knopf:hover {
    background: var(--anouk-primaer-dunkel);
}

.anouk-zustimmung-knopf:focus-visible {
    outline: 3px solid var(--anouk-text);
    outline-offset: 2px;
}

/* Hinweis unter dem Chat, wenn der Browser die Zustimmung nicht speichern kann. */
.anouk-zustimmung-hinweis {
    margin: 0;
    padding: 8px 14px 0;
    background: var(--anouk-weiss);
    color: var(--anouk-text-sekundaer);
    font-size: 13px;
    line-height: 1.35;
    text-align: center;
}

/* Der Chat sitzt links unten: rechts unten liegen das Trusted-Shops-Siegel und
   das Google-Bewertungs-Badge, mit denen er sonst kollidiert. */
@media (max-width: 768px) {
    .anouk-panel {
        max-height: calc(100vh - 116px);
    }
}

/* Handy: Panel füllt den Bildschirm */
@media (max-width: 479.98px) {
    .anouk {
        left: 16px;
        bottom: 16px;
    }

    .anouk-panel {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        max-height: none;
        border: none;
        border-radius: 0;
    }

    .anouk.is-open .anouk-toggle {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .anouk-panel,
    .anouk.is-open .anouk-panel,
    .anouk-toggle {
        transition: none;
    }

    .anouk-tippt span {
        animation: none;
        opacity: 0.7;
    }
}
