/* ====================================================================== */
/* GLOBAL FONT & RESET                                                    */
/* ====================================================================== */
#flussfahrer-chat-window,
#flussfahrer-chat-window * {
    color: #2d3748; /* dunkles Grau */
    text-align: left;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Header bleibt weiß */
.chat-header,
.chat-header *,
.chat-header button {
    color: #ffffff !important;
}

/* User & Bot Messages */
.msg.user { color: #2d3748; }
.msg.bot  { color: #2d3748; }

/* Disclaimer Farbe */
#chat-disclaimer-text {
    color: #999 !important;
}

/* ====================================================================== */
/* FLOATING CONTAINER                                                     */
/* ====================================================================== */
#flussfahrer-floating-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    transition: bottom 0.3s ease-in-out;
}

/* ====================================================================== */
/* TRIGGER BUTTON                                                         */
/* ====================================================================== */
#chat-trigger-btn {
    width: 70px;
    height: 70px;
    background: white;
    border-radius: 50%;
    border: 2px solid #0073aa;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s;
    position: relative;
}
#chat-trigger-btn:hover { transform: scale(1.05); }

.avatar-wrapper { width: 100%; height: 100%; border-radius: 50%; overflow: hidden; }
.avatar-wrapper img { width: 100%; height: 100%; object-fit: cover; }

/* AI Badge */
.ai-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: #0073aa;
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 5px;
    border-radius: 8px;
    border: 2px solid white;
}

/* Dismiss Icon */
#chat-dismiss-icon {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 24px;
    height: 24px;
    background: #666;
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ====================================================================== */
/* CHAT WINDOW (Floating + Embedded)                                      */
/* ====================================================================== */
#flussfahrer-chat-window {
    width: 360px;
    height: 550px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    bottom: 85px;
    right: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

/* Sichtbar-Schalten */
#flussfahrer-chat-window.chat-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* ====================================================================== */
/* HEADER                                                                 */
/* ====================================================================== */
.chat-header {
    background: #0073aa;
    color: white;
    padding: 12px 15px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.header-controls { display: flex; gap: 15px; }
.ctrl-btn { background: transparent; border: none; cursor: pointer; color: white; padding: 4px; }
.ctrl-btn:hover { background: rgba(255,255,255,0.2); border-radius: 4px; }

/* ====================================================================== */
/* CONSENT LAYER                                                          */
/* ====================================================================== */
#chat-consent-layer {
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    padding: 30px;
    height: 100%;
}
.consent-btn {
    background: #0073aa;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    margin-top: 15px;
    width: 100%;
}

/* ====================================================================== */
/* CHAT INTERFACE LAYER (Wrapper)                                         */
/* ====================================================================== */
#chat-interface-layer {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    /* kein height hier im Default-Floating-Modus */
}

/* Verlauf nimmt den ganzen übrigen Platz ein */
#chat-history-display {
    flex: 1 1 auto;
    padding: 15px;
    overflow-y: auto;
    background: #f9f9f9;
    font-size: 0.95em;
}

/* Disclaimer & Footer bleiben sichtbar am unteren Rand */
#chat-disclaimer-text {
    flex: 0 0 auto;
    padding: 6px 10px;
    font-size: 11px;
    line-height: 1.4;
    text-align: center;
    background: #fff;
    white-space: normal;
}

.chat-footer-links {
    flex: 0 0 auto;
    padding: 6px 10px;
    background: #f0f0f0;
    text-align: center;
    font-size: 0.9em;
}

.chat-footer-links .chat-reset-btn {
    background: transparent;
    border: none;
    color: #2d3748 !important;
    cursor: pointer;
    text-decoration: underline;
}

/* ====================================================================== */
/* CHAT HISTORY DISPLAY (Duplicate block – harmless, aber gelassen)       */
/* ====================================================================== */
#chat-history-display {
    flex: 1 1 auto;
    padding: 15px;
    overflow-y: auto;
    background: #f9f9f9;
    font-size: 0.95em;
}

/* ====================================================================== */
/* MESSAGES                                                               */
/* ====================================================================== */
.msg {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    line-height: 1.5;
    max-width: 85%;
    word-wrap: break-word;
}
.msg.user {
    background: #e1f0ff;
    align-self: flex-end;
    margin-left: 15%;
    border-bottom-right-radius: 2px;
}
.msg.bot {
    background: #ffffff;
    border: 1px solid #eee;
    align-self: flex-start;
    margin-right: 15%;
    border-bottom-left-radius: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.msg.bot a {
    color: #0073aa !important;
    font-weight: 600;
    text-decoration: none;
}
.msg.bot a:hover { text-decoration: underline; }

/* ====================================================================== */
/* INPUT AREA                                                             */
/* ====================================================================== */
.chat-input-area {
    padding: 12px;
    border-top: 1px solid #eee;
    display: flex;
    background: white;
}

#chat-input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 20px;
    color: #2d3748 !important;
    background: #ffffff !important;
}
#chat-input::placeholder {
    color: #a0aec0 !important;
}

#send-btn {
    background: none;
    border: none;
    color: #0073aa;
    font-size: 1.2em;
    margin-left: 8px;
    cursor: pointer;
}

/* ====================================================================== */
/* SUGGESTION CHIPS                                                       */
/* ====================================================================== */
#chat-suggestions {
    padding: 5px 15px 10px;
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    background: #f9f9f9;
}
#chat-suggestions button {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 15px;
    padding: 5px 10px;
    font-size: 0.8em;
    cursor: pointer;
    color: #555;
}
#chat-suggestions button:hover {
    background: #0073aa;
    color: white;
    border-color: #0073aa;
}

/* ====================================================================== */
/* DISCLAIMER + FOOTER LINKS                                              */
/* ====================================================================== */
#chat-disclaimer-text {
    flex: 0 0 auto;
    padding: 6px 10px;
    font-size: 11px;
    line-height: 1.4;
    text-align: center;
    background: #fff;
    white-space: normal;
}

.chat-footer-links {
    flex: 0 0 auto;
    padding: 6px 10px;
    background: #f0f0f0;
    text-align: center;
    font-size: 0.9em;
}

.chat-footer-links .chat-reset-btn {
    background: transparent;
    border: none;
    color: #2d3748 !important;
    cursor: pointer;
    text-decoration: underline;
}
.chat-footer-links .chat-reset-btn:hover {
    text-decoration: underline;
}

/* ====================================================================== */
/* TOAST                                                                  */
/* ====================================================================== */
#flussfahrer-toast {
    visibility: hidden;
    min-width: 250px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 12px 20px;
    position: fixed;
    z-index: 10000;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.5s, bottom 0.5s;
}
#flussfahrer-toast.show {
    visibility: visible;
    opacity: 1;
    bottom: 60px;
}

/* ====================================================================== */
/* FOOTER LINK MINI-BAR                                                   */
/* ====================================================================== */
#flussfahrer-footer-link {
    position: fixed;
    bottom: 0;
    right: 20px;
    background: #333;
    color: white;
    padding: 6px 15px 4px;
    border-radius: 8px 8px 0 0;
    z-index: 9998;
    font-size: 0.85em;
}
#flussfahrer-footer-link a {
    color: white;
    text-decoration: none;
}

/* ====================================================================== */
/* MOBILE FULLSCREEN (nur Floating!)                                      */
/* ====================================================================== */

/* OPTIONALER FIX: Sicherstellen, dass hidden wirklich weg ist */
#flussfahrer-chat-window.chat-hidden {
    display: none !important; /* Sicherheitshalber */
}
#flussfahrer-chat-window.chat-visible {
    display: flex !important;
}

@media (max-width: 480px) {
    #flussfahrer-chat-window {
        width: 100% !important;
        height: 100% !important;
        position: fixed !important;
        top: 0; left: 0; right: 0; bottom: 0;
        border-radius: 0 !important;
        z-index: 100000;
    }
    #chat-interface-layer {
        height: 100%;
    }
    .chat-header { padding-top: 10px; }
}

/* ====================================================================== */
/* TYPING ANIMATION                                                       */
/* ====================================================================== */
.typing-dots span {
    animation: typing 1.4s infinite ease-in-out both;
    font-size: 1.5em;
    margin: 0 1px;
    display: inline-block;
}
.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ====================================================================== */
/* MANUAL TRIGGER BUTTON (Shortcode)                                      */
/* ====================================================================== */
.ff-manual-trigger-btn::before {
    content: "💬";
    font-size: 1.1em;
}

/* ====================================================================== */
/* EMBEDDED MODE                                                          */
/* ====================================================================== */

#flussfahrer-chat-wrapper.is-embedded {
    max-width: 900px;
    margin: 0 auto;
}

/* Chat-Fenster im Embedded-Mode: Karte mit fixer Höhe + Scroll-Inhalt */
#flussfahrer-chat-wrapper.is-embedded #flussfahrer-chat-window {
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;

    height: 800px !important;       /* bei Bedarf anpassen */
    max-height: 75vh !important;

    margin: 0 auto;
    box-shadow: none !important;
    bottom: auto !important;
    right: auto !important;
    left: auto !important;
}

/* Innerer Bereich soll die Höhe nutzen */
#flussfahrer-chat-wrapper.is-embedded #chat-interface-layer {
    display: flex;
    flex-direction: column;
    height: calc(100% - 52px);  /* ca. Höhe Header; bei Bedarf feintunen */
}

/* Nur der Verlauf scrollt */
#flussfahrer-chat-wrapper.is-embedded #chat-history-display {
    flex: 1 1 auto;
    overflow-y: auto;
}

/* Mobile: eher hoch, aber nicht fullscreen-fixed */
@media (max-width: 480px) {
    #flussfahrer-chat-wrapper.is-embedded #flussfahrer-chat-window {
        position: static !important;
        width: 100% !important;
        height: 70vh !important;
        max-height: 70vh !important;
        top: auto !important;
        bottom: auto !important;
        right: auto !important;
        left: auto !important;
        border-radius: 12px !important;
    }

    #flussfahrer-chat-wrapper.is-embedded #chat-interface-layer {
        height: calc(100% - 52px);
    }
}
