/* CSS */
:root {
    /*--bg-color-overlay: rgba(255, 255, 255, .5);*/
    --bg-color-overlay: rgba(34, 35, 35, .98);
    --bg-color: rgba(34, 35, 35, 1);
    --color: #fff;
    --chat-background-image: url("https://ai.uniquo-coaching.de/themes/source/wa-background.png");
    --chat-background-color: rgba(34, 35, 35, 0.7);
    --message-border-radius: 13px;
    --message-user-background-color: #144D37; /* WhatsApp-Grün */
    --message-user-color: #fff;
    --message-user-border-color: #144D37;
    --message-assistant-background-color: #363838;
    --message-assistant-color: #fff;
    --message-assistant-border-color: #ddd;
    --message-error-background-color: #f8d7da; /* dezentes Warning-Rot (Bootstrap danger background) */
    --message-error-color: #842029;
    --message-error-border-color: #f5c2c7; /* leichtes rotes Rand */
    --message-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --message-thinking-dots-background-color: #6b7280;
}

.chat-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background-color: var(--chat-background-color);
    background-image: var(--chat-background-image);
    background-repeat: repeat;
    background-position: 0 0;
    background-attachment: fixed;
}

.chat-wrapper-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color-overlay);
    pointer-events: none;
}

.chat-wrapper-no-active-thread {
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    z-index: 2;
    pointer-events: none;
}

.chat-header {
    position: relative;
    height: 53px;
    padding: 10px;
    background-color: var(--bg-color); /* deine gewünschte Farbe-Variable */
    color: var(--color);
}

.chat-header .message-thread-title {
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--color);
    margin: 0;
    padding: 0;
    vertical-align: middle;
}

.chat-header .chat-assistant-audio {
    border-radius: 26px;
    border: 0;
    padding: 6px 20px 6px 20px;
}
.chat-header .chat-assistant-audio:empty {
    border-radius: 0;
    border: 0;
    padding: 0;
}
.chat-header .chat-assistant-audio .btn-audio-assistant {
    /*font-size: 11px;*/
    padding: 0 5px 0 5px !important;
    border-radius: 50%;
    /*color: #FF6302;*/
    /*background-color: transparent;*/
    border: 0;
}
.chat-body {
    flex: 1 1 auto !important;
    display: flex;
    flex-direction: column;
    padding: 20px 10px;
    gap: 10px;
    overflow-y: auto;
}

/* Chat-Footer: nur eine Background-Farbe (und über dem Wrapper-Overlay platzieren) */
.chat-footer {
    /*height: 53px;*/
    border-radius: 26px;
    border: 1px solid gray;
    margin: 20px 10px;
    padding: 10px;
    position: relative; /* erzeugt neues Stacking-Context für z-index */
    z-index: 2; /* liegt über dem .chat-wrapper::before (z-index:0) */
    /*background-image: none !important; !* sicherstellen, dass kein Bild durchkommt *!*/
    background-color: var(--bg-color); /* deine gewünschte Farbe-Variable */
    color: var(--color);
    /* Optional: wenn Footer abgerundete Ecken oder andere Stile braucht */
    /* border-radius: 8px; */
}

.chat-footer-input {
    resize: none;
    background-color: transparent !important;
    border: none;
    outline: none;
    color: var(--color);
    width: 100%;
    /*font-size: 14px;*/
    /*line-height: 1.4;*/
    padding: 4px;
    margin: 0;
    box-sizing: border-box;
    overflow-wrap: break-word;
}


.message {
    /*padding: 5px 0;*/
    display: flex;
    flex-direction: column;
    animation: fadeIn 400ms ease-in-out;
}

.message-inner {
    display: flex;
    flex-wrap: nowrap;
    align-items: end;
    width: 100%;
}

.message .message-inner .message-time {
    font-size: 11px;
    margin-left: 5px;
    color: rgba(255, 255, 255, 0.6);
}

.message-highlight {
    background-color: #f4de5f;
    color: #000000;
    border-radius: 4px;
    padding: 0.2em 0.4em;
    margin: 0;
}

.message p:last-of-type {
    /* trifft das letzte <p> innerhalb von .message, egal ob noch andere Nicht-p-Elemente folgen */
    margin-bottom: 0;
}

.message-start,
.message-end {
    max-width: 70%; /* Textblöcke sollen nicht zu breit sein */
    padding: 10px 15px;
    border-radius: var(--message-border-radius);;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    position: relative;
}

/* Zustand: "thinking" (drei Punkte) */
.message-thinking {
    width: 70px !important;
    text-align: center;
}

/* Zustand: Fehleranzeige */
.message-error {
    width: 70% !important;
    text-align: center;
}

/* Fehler-Bubble innerhalb von message-error */
.message-error .message-start {
    background-color: var(--message-error-background-color);
    color: var(--message-error-color);
    border: 1px solid var(--message-error-border-color);
    /* Linke obere Ecke abflachen */
    border-top-left-radius: 0
}

/* Letztes Paragraph-Element nicht extra Abstand geben */
.message p:last-child {
    margin-bottom: 0 !important;
}

/** ---- BUBBLES ------ */

/* Stil für eingehende Nachrichten (linksbündig) */
.message-start {
    align-self: flex-start;
    background-color: var(--message-assistant-background-color);
    color: var(--message-assistant-color);
    /*border: 0px solid var(--message-assistant-border-color); !* Leichte Umrandung *!*/
    border-top-left-radius: 0; /* Linke obere Ecke abflachen */
    box-shadow: var(--message-shadow);
    position: relative; /* für pseudo-elemente */
    margin-left: 13px; /* Platz schaffen, damit das Dreieck komplett sichtbar ist + 2-3px Abstand */
}

.message-start::before {
    content: "";
    position: absolute;
    top: 0;
    left: -13px;
    width: 13px;
    height: 26px; /* Höhe passend zur Tail-Form */
    pointer-events: none;
    z-index: 8;

    background-color: var(--message-assistant-background-color);
    -webkit-mask-image: url("https://ai.uniquo-coaching.de/themes/source/tail-in.svg");
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: 0 0;
    -webkit-mask-size: contain;

    mask-image: url("https://ai.uniquo-coaching.de/themes/source/tail-in.svg");
    mask-repeat: no-repeat;
    mask-position: 0 0;
    mask-size: contain;
}

/* Stil für ausgehende Nachrichten (rechtsbündig) */
.message-end {
    align-self: flex-end;
    background-color: var(--message-user-background-color); /* WhatsApp-Grün */
    color: var(--message-user-color);
    /*border: 1px solid var(--message-user-border-color); !* Grüne Umrandung *!*/
    border-top-right-radius: 0; /* Rechte obere Ecke abflachen */
    box-shadow: var(--message-shadow);
    position: relative; /* für pseudo-elemente */
    margin-right: 13px; /* Platz schaffen, damit das Dreieck komplett sichtbar ist + 2-3px Abstand */
}

.message-end::before {
    content: "";
    position: absolute;
    top: 0;
    right: -13px; /* passt zu bisherigen Notch-Abständen */
    width: 13px; /* Breite des Mask-Containers (Rand-Dreieck) */
    height: 26px; /* Höhe passend zur Tail-Form */
    pointer-events: none;
    z-index: 8;

    background-color: var(--message-user-background-color);
    -webkit-mask-image: url("https://ai.uniquo-coaching.de/themes/source/tail-out.svg");
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: 0 0;
    -webkit-mask-size: contain;

    mask-image: url("https://ai.uniquo-coaching.de/themes/source/tail-out.svg");
    mask-repeat: no-repeat;
    mask-position: 0 0;
    mask-size: contain;
}


/** ---- END BUBBLES ------ */

/* drei Punkte (thinking) */
.message-thinking .dots {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    height: 1em; /* passt sich an Textgröße an */
}

.message-thinking .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--message-thinking-dots-background-color);
    display: inline-block;
    opacity: 0.25;
    transform: translateY(0);
    animation: thinking-dot 1s infinite ease-in-out;
}


/* versetzte Startzeiten für die drei Punkte */
.message-thinking .dot:nth-child(1) {
    animation-delay: 0s;
}

.message-thinking .dot:nth-child(2) {
    animation-delay: 0.15s;
}

.message-thinking .dot:nth-child(3) {
    animation-delay: 0.30s;
}

/* Optional: Animationen für Bubbles */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes thinking-dot {
    0% {
        opacity: 0.25;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-3px);
    }
    80% {
        opacity: 0.25;
        transform: translateY(0);
    }
    100% {
        opacity: 0.25;
        transform: translateY(0);
    }
}
