/*
 * Portal-Chat im Gastportal: schwebender Knopf, Hinweisblase, Panel (Handy bildschirmfuellend, ab 768 px Seitenpanel).
 * Markup: laravel/resources/views/guest2/portal/guest-chat.blade.php, Verhalten: JS-Bundle guest-chat.
 */
.fwgc {
    --fwgc-primary: var(--brand-primary, #032f5a);
    --fwgc-primary-hover: var(--brand-primary-hover, #043a6f);
    --fwgc-ink: #1b2733;
    --fwgc-muted: #66788a;
    --fwgc-line: #e2e8ef;
    --fwgc-thread: #eef2f6;
    --fwgc-me: #d9f2d6;
    --fwgc-me-ink: #16311c;
    --fwgc-other: #ffffff;
    --fwgc-ai: #eaf1fd;
    --fwgc-ai-line: #cfdcf3;
    --fwgc-companion: #fbf6ea;
    --fwgc-danger: #d93f3f;
    --fwgc-safe-bottom: env(safe-area-inset-bottom, 0px);
    --fwgc-safe-right: env(safe-area-inset-right, 0px);
    font-size: 16px;
    line-height: 1.4;
    color: var(--fwgc-ink);
}

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

.fwgc button {
    font: inherit;
    color: inherit;
    margin: 0;
}

.fwgc .material-symbols-rounded {
    line-height: 1;
}

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

/* ---------------------------------------------------------------- Knopf */

.fwgc-fab {
    position: fixed;
    right: calc(16px + var(--fwgc-safe-right));
    bottom: calc(16px + var(--fwgc-safe-bottom));
    z-index: 36;
    width: 58px;
    height: 58px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--fwgc-primary);
    color: #fff !important;
    box-shadow: 0 8px 22px rgba(3, 47, 90, 0.3), 0 2px 6px rgba(3, 47, 90, 0.18);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.fwgc-fab:hover {
    background: var(--fwgc-primary-hover);
    transform: translateY(-1px);
}

.fwgc-fab:focus-visible {
    outline: 3px solid #8fb8e8;
    outline-offset: 3px;
}

.fwgc-fab .material-symbols-rounded {
    font-size: 28px;
    font-variation-settings: "FILL" 1;
}

.fwgc-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 23px;
    height: 23px;
    padding: 0 6px;
    border-radius: 12px;
    border: 2px solid #fff;
    background: var(--fwgc-danger);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 19px;
    text-align: center;
    box-sizing: border-box;
}

.fwgc--has-unread .fwgc-fab {
    animation: fwgc-pulse 2.4s ease-in-out 2;
}

@keyframes fwgc-pulse {
    0%, 100% { box-shadow: 0 8px 22px rgba(3, 47, 90, 0.3), 0 0 0 0 rgba(3, 47, 90, 0.35); }
    50% { box-shadow: 0 8px 22px rgba(3, 47, 90, 0.3), 0 0 0 10px rgba(3, 47, 90, 0); }
}

/* ---------------------------------------------------------------- Hinweisblase */

.fwgc-peek {
    position: fixed;
    right: calc(16px + var(--fwgc-safe-right));
    bottom: calc(86px + var(--fwgc-safe-bottom));
    z-index: 36;
    display: flex;
    align-items: flex-start;
    max-width: min(320px, calc(100vw - 32px));
    background: #fff;
    border: 1px solid var(--fwgc-line);
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 10px 28px rgba(3, 47, 90, 0.18);
    animation: fwgc-in 0.25s ease-out;
}

.fwgc-peek-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding: 10px 4px 11px 14px;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.fwgc-peek-who {
    font-size: 12px;
    font-weight: 700;
    color: var(--fwgc-primary);
}

.fwgc-peek-text {
    font-size: 14px;
    color: var(--fwgc-ink);
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.fwgc-peek-close {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    margin: 3px 3px 0 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--fwgc-muted) !important;
    cursor: pointer;
}

.fwgc-peek-close .material-symbols-rounded {
    font-size: 18px;
}

.fwgc-peek-close:hover {
    background: #f1f4f8;
}

@keyframes fwgc-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------------- Panel */

.fwgc-panel {
    position: fixed;
    z-index: 39;
    top: 0;
    left: 0;
    right: 0;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: #fff;
    overflow: hidden;
    animation: fwgc-in 0.2s ease-out;
}

html.fwgc-lock,
html.fwgc-lock body {
    overflow: hidden !important;
    overscroll-behavior: none;
}

@media (min-width: 768px) {
    .fwgc-panel {
        top: auto;
        left: auto;
        right: calc(16px + var(--fwgc-safe-right));
        bottom: calc(16px + var(--fwgc-safe-bottom));
        width: 400px;
        height: min(680px, calc(100vh - 32px));
        border-radius: 18px;
        border: 1px solid rgba(3, 47, 90, 0.08);
        box-shadow: 0 22px 60px rgba(3, 47, 90, 0.28), 0 4px 14px rgba(3, 47, 90, 0.12);
    }
}

@media (min-width: 1280px) {
    .fwgc-panel {
        width: 420px;
        height: min(740px, calc(100vh - 32px));
    }
}

.fwgc-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px 10px 14px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    background: var(--fwgc-primary);
    color: #fff;
}

@media (min-width: 768px) {
    .fwgc-head {
        padding-top: 10px;
    }
}

.fwgc-head-icon {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    display: grid;
    place-items: center;
}

.fwgc-head-icon .material-symbols-rounded {
    font-size: 22px;
}

.fwgc-head-text {
    flex: 1 1 auto;
    min-width: 0;
}

.fwgc .fwgc-title {
    margin: 0;
    padding: 0;
    font-family: inherit;
    letter-spacing: normal;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.25;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fwgc .fwgc-sub {
    margin: 1px 0 0;
    font-size: 12.5px;
    line-height: 1.25;
    color: rgba(255, 255, 255, 0.78);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fwgc-close {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #fff !important;
    display: grid;
    place-items: center;
    cursor: pointer;
}

.fwgc-close:hover,
.fwgc-close:focus-visible {
    background: rgba(255, 255, 255, 0.14);
    outline: none;
}

.fwgc-notice {
    flex: 0 0 auto;
    margin: 0;
    padding: 7px 14px;
    font-size: 13px;
    line-height: 1.35;
    background: #fff6e0;
    color: #6b4b00;
    border-bottom: 1px solid #f1e0b3;
}

/* ---------------------------------------------------------------- Verlauf */

.fwgc-thread {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 10px 10px 8px;
    background: var(--fwgc-thread);
}

.fwgc .fwgc-note {
    margin: 2px auto 10px;
    max-width: 330px;
    padding: 7px 12px;
    border-radius: 10px;
    background: #fdf8e6;
    color: #5d5337;
    font-size: 12.5px;
    line-height: 1.4;
    text-align: center;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}

.fwgc-older {
    display: block;
    margin: 0 auto 10px;
    padding: 6px 14px;
    border: 1px solid var(--fwgc-line);
    border-radius: 999px;
    background: #fff;
    color: var(--fwgc-primary) !important;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.fwgc-older:hover {
    background: #f6f9fc;
}

.fwgc .fwgc-empty {
    margin: 24px 12px;
    color: var(--fwgc-muted);
    font-size: 14px;
    text-align: center;
}

.fwgc-day {
    display: flex;
    justify-content: center;
    margin: 12px 0 8px;
}

.fwgc-day span {
    padding: 3px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    color: #55687a;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}

.fwgc-msg {
    display: flex;
    margin-top: 8px;
}

.fwgc-msg--cont {
    margin-top: 2px;
}

.fwgc-msg--me {
    justify-content: flex-end;
}

.fwgc-bubble {
    position: relative;
    max-width: 84%;
    min-width: 64px;
    padding: 6px 9px 4px;
    border-radius: 14px;
    background: var(--fwgc-other);
    color: var(--fwgc-ink);
    box-shadow: 0 1px 1.5px rgba(11, 20, 26, 0.1);
    overflow-wrap: anywhere;
    word-break: break-word;
    font-size: 15px;
    line-height: 1.38;
}

@media (min-width: 768px) {
    .fwgc-bubble {
        max-width: 80%;
    }
}

.fwgc-msg--me .fwgc-bubble {
    background: var(--fwgc-me);
    color: var(--fwgc-me-ink);
}

.fwgc-msg--me:not(.fwgc-msg--cont) .fwgc-bubble {
    border-top-right-radius: 4px;
}

.fwgc-msg--other:not(.fwgc-msg--cont) .fwgc-bubble {
    border-top-left-radius: 4px;
}

.fwgc-msg--ai .fwgc-bubble {
    background: var(--fwgc-ai);
    box-shadow: inset 0 0 0 1px var(--fwgc-ai-line), 0 1px 1.5px rgba(11, 20, 26, 0.08);
}

.fwgc-msg--companion .fwgc-bubble {
    background: var(--fwgc-companion);
}

.fwgc-msg--failed .fwgc-bubble {
    box-shadow: inset 0 0 0 1px #efb4b4;
}

.fwgc-who {
    margin: 0 0 1px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--fwgc-primary);
}

.fwgc-msg--me .fwgc-who {
    color: #2c6a36;
    text-align: right;
}

.fwgc-msg--ai .fwgc-who {
    color: #2754a8;
}

.fwgc-msg--companion .fwgc-who {
    color: #8a5a00;
}

.fwgc-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 1px 0 3px;
}

.fwgc-msg--me .fwgc-tags {
    justify-content: flex-end;
}

.fwgc-tag {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.6);
    color: #3b5a45;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.fwgc-text {
    white-space: pre-wrap;
}

.fwgc-text a,
.fwgc-link {
    color: #0b5cad;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.fwgc-transcript {
    display: flex;
    gap: 7px;
    align-items: flex-start;
    margin: 3px 0 6px;
    padding: 6px 9px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.72);
    border-left: 3px solid #7ea3dc;
}

.fwgc-transcript-icon {
    flex: 0 0 auto;
    font-size: 18px;
    line-height: 1.25;
}

.fwgc-transcript-box {
    min-width: 0;
}

.fwgc-transcript-label {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: #4a6690;
}

.fwgc-transcript-text {
    font-style: italic;
    white-space: pre-wrap;
}

.fwgc-img {
    display: block;
    width: fit-content;
    max-width: 100%;
    margin: 3px 0 4px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.05);
    cursor: zoom-in;
}

.fwgc-img img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 300px;
    min-width: 48px;
    min-height: 48px;
}

.fwgc-chip {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    margin: 2px 0 3px;
    padding: 4px 9px 4px 6px;
    border-radius: 8px;
    background: rgba(3, 47, 90, 0.06);
    color: #334a61;
    font-size: 13.5px;
}

.fwgc-chip .material-symbols-rounded {
    font-size: 18px;
}

.fwgc-chip-hint {
    color: var(--fwgc-muted);
    font-size: 12px;
}

.fwgc-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    margin-top: 1px;
    font-size: 11px;
    line-height: 1.2;
    color: #6f8292;
    white-space: nowrap;
}

.fwgc-tick {
    font-size: 12px;
    color: #3f8a4c;
}

.fwgc-tick--sending {
    color: #8a9aa8;
}

.fwgc-tick--failed {
    color: var(--fwgc-danger);
    font-weight: 700;
}

.fwgc-retry {
    display: block;
    width: 100%;
    margin: 4px 0 2px;
    padding: 4px 0 0;
    border: 0;
    border-top: 1px solid rgba(217, 63, 63, 0.25);
    background: transparent;
    color: var(--fwgc-danger) !important;
    font-size: 12.5px !important;
    text-align: right;
    cursor: pointer;
}

.fwgc-typing {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 2px;
    padding: 7px 12px;
    border-radius: 14px;
    border-top-left-radius: 4px;
    background: var(--fwgc-ai);
    box-shadow: inset 0 0 0 1px var(--fwgc-ai-line);
    color: #2754a8;
    font-size: 13px;
}

.fwgc-typing-dots {
    display: inline-flex;
    gap: 3px;
}

.fwgc-typing-dots i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6d8fce;
    animation: fwgc-dot 1.2s infinite ease-in-out;
}

.fwgc-typing-dots i:nth-child(2) {
    animation-delay: 0.15s;
}

.fwgc-typing-dots i:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes fwgc-dot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

.fwgc-jump {
    position: absolute;
    right: 14px;
    bottom: calc(76px + var(--fwgc-safe-bottom));
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px 6px 12px;
    border: 0;
    border-radius: 999px;
    background: var(--fwgc-primary);
    color: #fff !important;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(3, 47, 90, 0.25);
    cursor: pointer;
}

.fwgc-jump .material-symbols-rounded {
    font-size: 18px;
}

@media (min-width: 768px) {
    .fwgc-jump {
        bottom: 76px;
    }
}

/* ---------------------------------------------------------------- Eingabe */

.fwgc .fwgc-error {
    flex: 0 0 auto;
    margin: 0;
    padding: 7px 14px;
    background: #fdecec;
    color: #8f1f1f;
    font-size: 13px;
    line-height: 1.35;
    border-top: 1px solid #f3caca;
}

.fwgc-error-action {
    padding: 0;
    border: 0;
    background: transparent;
    color: #0b5cad !important;
    text-decoration: underline;
    cursor: pointer;
    font-size: 13px !important;
}

.fwgc-compose {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 6px;
    margin: 0;
    padding: 8px 8px calc(8px + var(--fwgc-safe-bottom));
    background: #f6f8fa;
    border-top: 1px solid var(--fwgc-line);
}

@media (min-width: 768px) {
    .fwgc-compose {
        padding-bottom: 8px;
    }
}

.fwgc-compose-main {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #d3dce6;
    border-radius: 22px;
    overflow: hidden;
}

.fwgc-compose-main:focus-within {
    border-color: #8fb3de;
    box-shadow: 0 0 0 3px rgba(62, 124, 196, 0.15);
}

.fwgc .fwgc-input {
    display: block;
    width: 100%;
    min-height: 44px;
    max-height: 132px;
    margin: 0;
    padding: 11px 14px 10px;
    border: 0;
    border-radius: 0;
    outline: none;
    resize: none;
    background: transparent;
    color: var(--fwgc-ink);
    font: inherit;
    font-size: 16px;
    line-height: 1.4;
    box-shadow: none;
    overflow-y: auto;
}

.fwgc-voice {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 6px 8px 0 10px;
    align-self: flex-start;
    padding: 1px 2px 1px 8px;
    border-radius: 999px;
    background: #eaf1fd;
    color: #2754a8;
    font-size: 12px;
    font-weight: 600;
}

.fwgc-voice-remove {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #2754a8 !important;
    display: grid;
    place-items: center;
    cursor: pointer;
}

.fwgc-voice-remove .material-symbols-rounded {
    font-size: 15px;
}

.fwgc-count {
    align-self: flex-end;
    margin: -4px 12px 5px 0;
    font-size: 11px;
    color: var(--fwgc-muted);
}

.fwgc-mic,
.fwgc-send {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

.fwgc-send {
    background: var(--fwgc-primary);
    color: #fff !important;
}

.fwgc-send:hover {
    background: var(--fwgc-primary-hover);
}

.fwgc-send:active,
.fwgc-mic:active {
    transform: scale(0.94);
}

.fwgc-send .material-symbols-rounded {
    font-size: 22px;
    margin-left: 2px;
}

.fwgc-mic {
    background: #fff;
    color: var(--fwgc-primary) !important;
    box-shadow: inset 0 0 0 1px #d3dce6;
}

.fwgc-mic:hover {
    background: #eef3f9;
}

.fwgc-mic.is-recording {
    background: var(--fwgc-danger);
    color: #fff !important;
    box-shadow: 0 0 0 0 rgba(217, 63, 63, 0.45);
    animation: fwgc-rec 1.4s infinite;
}

.fwgc-mic.is-busy {
    opacity: 0.6;
    cursor: progress;
}

@keyframes fwgc-rec {
    0% { box-shadow: 0 0 0 0 rgba(217, 63, 63, 0.45); }
    70% { box-shadow: 0 0 0 10px rgba(217, 63, 63, 0); }
    100% { box-shadow: 0 0 0 0 rgba(217, 63, 63, 0); }
}

.fwgc-mic:focus-visible,
.fwgc-send:focus-visible,
.fwgc-older:focus-visible,
.fwgc-img:focus-visible {
    outline: 3px solid #8fb8e8;
    outline-offset: 2px;
}

/* ---------------------------------------------------------------- Bild gross */

.fwgc-lightbox {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 56px 12px 12px;
    background: rgba(8, 16, 26, 0.92);
}

.fwgc-lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

.fwgc-lightbox-close {
    position: absolute;
    top: calc(8px + env(safe-area-inset-top, 0px));
    right: 8px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff !important;
    display: grid;
    place-items: center;
    cursor: pointer;
}

@media (min-width: 768px) {
    .fwgc-lightbox-close {
        top: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fwgc-panel,
    .fwgc-peek,
    .fwgc--has-unread .fwgc-fab,
    .fwgc-mic.is-recording,
    .fwgc-typing-dots i {
        animation: none !important;
    }
}

@media print {
    .fwgc {
        display: none !important;
    }
}

.fwgc-reactions {
    margin-right: auto;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 0 1px rgba(3, 47, 90, 0.08);
    font-size: 12px;
    line-height: 1.5;
    color: #34495e;
}

/* Platz unter dem letzten Inhalt, damit der Knopf nichts verdeckt */
body.fwgc-has-fab > main.section {
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}

/* Admin-Einbettung (Tagesansicht, WhatsApp-Chat): gleicher Verlauf, ohne FAB/Panel */
.fwgc--embed {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.fwgc--embed [x-cloak] {
    display: none !important;
}
.fwgc--embed .fwgc-thread {
    max-height: 22rem;
    border-radius: 12px;
}
.fwgc--embed.fwgc--embed-tall .fwgc-thread {
    max-height: none;
    height: calc(100dvh - 22rem);
    min-height: 10rem;
}
.fwgc--embed .fwgc-lightbox {
    position: fixed;
    z-index: 80;
}
.fwgc-msg--pending {
    opacity: 0.7;
}
@media print {
    .fwgc--embed {
        display: flex !important;
    }
}

/* Admin: Nachricht loeschen (Muelleimer neben der Uhrzeit; erscheint beim Ueberfahren der Sprechblase, am Handy immer) */
.fwgc-del { display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; margin-left: .15rem; border: 0; border-radius: .35rem; background: transparent; color: inherit; opacity: .35; cursor: pointer; vertical-align: middle; }
.fwgc-del .material-symbols-rounded { font-size: 1rem; }
.fwgc-bubble:hover .fwgc-del, .fwgc-del:focus-visible { opacity: 1; }
.fwgc-del:hover, .fwgc-del:focus-visible { color: #b91c1c; background: rgb(185 28 28 / .1); }
@media (hover: none) { .fwgc-del { opacity: .7; width: 2rem; height: 2rem; } }
