/*! Fast RAGbot++ | GPL-2.0-or-later | frgbpp-ui */
/* Chat Widget Styles */
.rag-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2147483000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.rag-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--ragbot-primary, #007cba);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.rag-chat-button:hover {
    background: var(--ragbot-primary-hover, #005a87);
    transform: scale(1.05);
}

.rag-chat-button svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.rag-chat-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    z-index: 2147483002;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

/* Flip panel to the right when the launcher button is on the left side */
.rag-chat-widget.position-left .rag-chat-panel {
    right: auto;
    left: 0;
}

.rag-chat-panel.open {
    display: flex;
}

.rag-chat-header {
    background: var(--ragbot-header-bg, var(--ragbot-primary, #007cba));
    color: white;
    padding: 16px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--ragbot-header-bg, var(--ragbot-primary, #007cba));
}

.rag-chat-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    width: 24px;
    height: 24px;
}

.rag-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: var(--ragbot-font-size, 14px);
}

.rag-chat-message {
    max-width: 80%;
    padding: 12px;
    border-radius: 12px;
    word-wrap: break-word;
}

.rag-chat-message.user {
    background: var(--ragbot-user-bubble, #007cba);
    color: var(--ragbot-user-text, #ffffff);
    align-self: flex-end;
    margin-left: auto;
}

.rag-chat-message.bot {
    background: var(--ragbot-bot-bubble, #f1f1f1);
    color: var(--ragbot-bot-text, #333);
    align-self: flex-start;
}

/* Rendered markdown inside bot bubbles — compact, chat-friendly spacing */
.rag-chat-message.bot p              { margin: 0 0 4px; }
.rag-chat-message.bot p:last-child   { margin-bottom: 0; }
.rag-chat-message.bot h1,
.rag-chat-message.bot h2,
.rag-chat-message.bot h3             { margin: 4px 0 2px; font-size: inherit; font-weight: 600; }
.rag-chat-message.bot ul,
.rag-chat-message.bot ol             { margin: 4px 0; padding-left: 20px; }
.rag-chat-message.bot li             { margin-bottom: 2px; }
.rag-chat-message.bot pre            { background: rgba(0,0,0,0.05); padding: 8px; border-radius: 4px; overflow-x: auto; font-size: 12px; margin: 4px 0; }
.rag-chat-message.bot code           { background: rgba(0,0,0,0.07); padding: 1px 4px; border-radius: 3px; font-size: 0.88em; }
.rag-chat-message.bot pre code       { background: none; padding: 0; }

/* PRD-53 — Thinking-status phrase shown while server is retrieving / thinking. */
.fg-thinking-status {
    font-style: italic;
    color: #999;
    font-size: 0.88em;
    margin: 0;
    padding: 0;
    line-height: 1.4;
}

.rag-chat-sources {
    margin-top: 8px;
    font-size: calc( var(--ragbot-font-size, 14px) * 0.78 );
    color: #666;
}

.rag-chat-sources a {
    color: var(--ragbot-primary, #007cba);
    text-decoration: none;
    display: block;
    margin-top: 4px;
}

.rag-chat-sources a:hover {
    text-decoration: underline;
}

.rag-chat-input-area {
    padding: 16px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
}

.rag-chat-input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 24px;
    outline: none;
    font-size: var(--ragbot-font-size, 14px);
}

.rag-chat-input:focus {
    border-color: var(--ragbot-input-focus, var(--ragbot-primary, #007cba));
}

.rag-chat-send {
    padding: 12px 16px;
    background: var(--ragbot-primary, #007cba);
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-size: var(--ragbot-font-size, 14px);
    transition: background 0.2s;
}

.rag-chat-send:hover:not(:disabled) {
    background: var(--ragbot-primary-hover, #005a87);
}

.rag-chat-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Typing indicator — spinning circle */
.rag-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--ragbot-bot-bubble, #f1f1f1);
    border-radius: 12px;
    align-self: flex-start;
}

/* Spinning circle: used in the typing bubble and as a streaming cursor */
.fg-spin-cursor {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0, 0, 0, 0.15);
    border-top-color: var(--ragbot-primary, #007cba);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    flex-shrink: 0;
    vertical-align: middle;
}

/* Phrase-based typing indicator variant (.fg-typing-phrase) */
.rag-typing.fg-typing-phrase {
    gap: 6px;
}
.fg-typing-phrase .fg-phrase-label {
    font-size: 13px;
    font-style: italic;
    color: #777;
}

/* Spinning cursor shown BEFORE streamed text (left side) */
.rag-chat-message.bot.is-streaming::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(0, 0, 0, 0.12);
    border-top-color: var(--ragbot-primary, #007cba);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

.rag-chat-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
    font-style: italic;
    background: transparent !important;
}

.rag-chat-loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top: 2px solid var(--ragbot-primary, #007cba);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.ragbot-admin-loader {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top: 3px solid var(--ragbot-primary, #007cba);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    vertical-align: middle;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.rag-prechat-form {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rag-prechat-form p {
    margin: 0 0 8px 0;
    font-weight: 600;
    color: #333;
}

.rag-prechat-form input {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.rag-prechat-form input:focus {
    outline: none;
    border-color: var(--ragbot-primary, #007cba);
}

.rag-start-chat {
    padding: 12px;
    background: var(--ragbot-primary, #007cba);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.rag-start-chat:hover {
    background: #005a87;
}

.rag-prechat-form .rg-lead-skip {
    align-self: center;
    text-align: center;
}

.rag-follow-ups {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.rag-follow-ups small {
    color: #666;
    font-size: 11px;
}

.rag-follow-up-btn {
    background: white;
    border: 1px solid var(--ragbot-primary, #007cba);
    color: var(--ragbot-primary, #007cba);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    text-align: left;
    transition: all 0.2s;
}

.rag-follow-up-btn:hover {
    background: var(--ragbot-primary, #007cba);
    color: white;
}

.rag-chat-panel.theme-styled {
    font-family: inherit;
}

.rag-chat-panel.theme-styled .rag-chat-message {
    font-family: inherit;
}

.rag-chat-panel.theme-styled .rag-chat-input,
.rag-chat-panel.theme-styled .rag-prechat-form input {
    font-family: inherit;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .rag-chat-widget {
        bottom: 10px;
        right: 10px;
    }

    /* Switch to fixed positioning so we can set an explicit top boundary
       that clears sticky site headers (typically 50-60 px tall).
       Use .rag-chat-widget prefix for specificity over position variants. */
    .rag-chat-widget .rag-chat-panel {
        position: fixed;
        top:    60px;                   /* stay below sticky nav / header */
        bottom: 80px;                   /* stay above the chat button     */
        left:   10px;
        right:  10px;
        width:  auto;
        height: auto;
        z-index: 2147483002;           /* stay above high-z sticky headers */
    }
}

/* -------------------------------------------------------------------------
   DSGVO / GDPR Consent Banner
   --------------------------------------------------------------------- */
.rag-consent-overlay {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 16px;
    background: #f9f9f9;
    border-radius: 0 0 8px 8px;
    flex: 1;
    overflow-y: auto;
}

.rag-consent-text {
    font-size: 13px;
    line-height: 1.6;
    color: #333;
    margin: 0;
}

.rag-consent-link-wrap {
    margin: 0;
}

.rag-consent-link-wrap a {
    font-size: 13px;
    color: var(--ragbot-primary, #007cba);
    text-decoration: underline;
}

.rag-consent-accept {
    align-self: flex-start;
    padding: 8px 20px;
    background: var(--ragbot-primary, #007cba);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.rag-consent-accept:hover {
    background: #005a8e;
}
/* -------------------------------------------------------------------------
   Lead Capture Overlay (PRD-37)
   --------------------------------------------------------------------- */
.rg-lead-overlay {
    padding: 16px;
    background: #ffffff;
    border-top: 2px solid var(--ragbot-primary, #007cba);
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* animate in from below */
    animation: rg-lead-slide-in 0.2s ease-out;
}

@keyframes rg-lead-slide-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.rg-lead-title {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin: 0 0 2px;
}

.rg-lead-overlay input[type="text"],
.rg-lead-overlay input[type="email"] {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s;
}

.rg-lead-overlay input[type="text"]:focus,
.rg-lead-overlay input[type="email"]:focus {
    border-color: var(--ragbot-primary, #007cba);
}

.rg-lead-gdpr {
    font-size: 12px;
    color: #555;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    cursor: pointer;
}

.rg-lead-gdpr input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
}

.rg-lead-gdpr a {
    color: var(--ragbot-primary, #007cba);
    text-decoration: underline;
}

.rg-lead-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.rg-lead-submit {
    padding: 7px 16px;
    background: var(--ragbot-primary, #007cba);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.rg-lead-submit:hover:not(:disabled) {
    background: var(--ragbot-primary-hover, #005a8e);
}

.rg-lead-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.rg-lead-skip {
    background: none;
    border: none;
    font-size: 12px;
    color: #888;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.rg-lead-skip:hover {
    color: #555;
}

.rg-lead-msg {
    font-size: 12px;
    color: #c00;
    margin: 0;
    display: none;
}

/* -------------------------------------------------------------------------
   Feedback buttons (thumbs up / down) — PRD-36
   ------------------------------------------------------------------------- */

.rg-feedback {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.rg-fb-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px 7px;
    opacity: 0.6;
    transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}

.rg-fb-btn:hover {
    background: #f0f0f0;
    opacity: 1;
}

.rg-fb-btn--active {
    background: #e8f4fc;
    border-color: #2271b1;
    opacity: 1;
}

.rg-feedback--rated .rg-fb-btn {
    cursor: default;
    pointer-events: none;
}

.rg-feedback--rated .rg-fb-btn:not(.rg-fb-btn--active) {
    opacity: 0.3;
}

/* ─── Follow-up suggestion chips ──────────────────────────────────────────── */

.rg-followup-chips {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.rg-followup-label {
    font-size: 0.78em;
    color: #888;
    width: 100%;
    margin-bottom: 2px;
}

.rg-followup-chip {
    display: inline-block;
    padding: 4px 10px;
    font-size: 0.82em;
    line-height: 1.4;
    border: 1px solid var(--ragbot-primary, #007cba);
    border-radius: 12px;
    background: transparent;
    color: var(--ragbot-primary, #007cba);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    max-width: 100%;
    white-space: normal;
    text-align: left;
}

.rg-followup-chip:hover,
.rg-followup-chip:focus {
    background: var(--ragbot-primary, #007cba);
    color: #fff;
    outline: none;
}

/* ==========================================================================
   Widget Position Variants (PRD-58 §7)
   ========================================================================== */

/* Bottom-left (legacy + new class) */
.rag-chat-widget.position-bottom-left,
.rag-chat-widget.position-left {
    bottom: 20px;
    right: auto;
    left: 20px;
}
.rag-chat-widget.position-bottom-left .rag-chat-panel,
.rag-chat-widget.position-left .rag-chat-panel {
    right: auto;
    left: 0;
}

/* Bottom-center */
.rag-chat-widget.position-bottom-center {
    bottom: 20px;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
}
.rag-chat-widget.position-bottom-center .rag-chat-panel {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
}

/* Top-right */
.rag-chat-widget.position-top-right {
    bottom: auto;
    top: 20px;
    right: 20px;
}
.rag-chat-widget.position-top-right .rag-chat-panel {
    bottom: auto;
    top: 80px;
}

/* Top-left */
.rag-chat-widget.position-top-left {
    bottom: auto;
    top: 20px;
    right: auto;
    left: 20px;
}
.rag-chat-widget.position-top-left .rag-chat-panel {
    bottom: auto;
    top: 80px;
    right: auto;
    left: 0;
}

/* Top-center */
.rag-chat-widget.position-top-center {
    bottom: auto;
    top: 20px;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
}
.rag-chat-widget.position-top-center .rag-chat-panel {
    bottom: auto;
    top: 80px;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
}

/* Middle-right */
.rag-chat-widget.position-middle-right {
    bottom: auto;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
}
.rag-chat-widget.position-middle-right .rag-chat-panel {
    bottom: auto;
    top: 0;
    right: 80px;
    left: auto;
}

/* Middle-left */
.rag-chat-widget.position-middle-left {
    bottom: auto;
    top: 50%;
    right: auto;
    left: 20px;
    transform: translateY(-50%);
}
.rag-chat-widget.position-middle-left .rag-chat-panel {
    bottom: auto;
    top: 0;
    left: 80px;
    right: auto;
}

/* ==========================================================================
   Powered By Footer (PRD-58 §5)
   ========================================================================== */

.rg-powered-by {
    text-align: center;
    padding: 4px 8px 6px;
    font-size: 10px;
    line-height: 1.4;
    color: #aaa;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

.rg-powered-by a,
.rg-powered-by span {
    color: inherit;
    text-decoration: none;
}

.rg-powered-by a:hover {
    text-decoration: underline;
    color: var(--ragbot-primary, #007cba);
}

.rg-bot-disclaimer {
    text-align: center;
    padding: 4px 10px 5px;
    font-size: 10px;
    font-style: italic;
    line-height: 1.4;
    color: #999;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

/* ==========================================================================
   Proactive Chat Bubble (PRD-58 §1)
   ========================================================================== */

.rg-proactive-bubble {
    position: absolute;
    bottom: 72px;
    right: 0;
    max-width: 240px;
    background: #fff;
    color: #333;
    font-size: 13px;
    line-height: 1.45;
    padding: 10px 14px;
    border-radius: 12px 12px 0 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
    cursor: pointer;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 10000;
    pointer-events: auto;
    white-space: normal;
    word-break: break-word;
}

/* Left-side widget — bubble opens to the right */
.rag-chat-widget.position-left .rg-proactive-bubble,
.rag-chat-widget.position-bottom-left .rg-proactive-bubble,
.rag-chat-widget.position-top-left .rg-proactive-bubble,
.rag-chat-widget.position-middle-left .rg-proactive-bubble {
    right: auto;
    left: 0;
    border-radius: 12px 12px 12px 0;
}

.rg-proactive-bubble--visible {
    opacity: 1;
    transform: translateY(0);
}

/* Decorative tail */
.rg-proactive-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 14px;
    width: 12px;
    height: 12px;
    background: #fff;
    clip-path: polygon(0 0, 100% 0, 100% 100%);
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.08);
}

.rag-chat-widget.position-left .rg-proactive-bubble::after,
.rag-chat-widget.position-bottom-left .rg-proactive-bubble::after,
.rag-chat-widget.position-top-left .rg-proactive-bubble::after,
.rag-chat-widget.position-middle-left .rg-proactive-bubble::after {
    right: auto;
    left: 14px;
    clip-path: polygon(0 0, 100% 0, 0 100%);
}

/* frgbpp — internal layout sentinel, do not remove */
.frgbpp::before {
    content: 'frgbpp';
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
    font-size: 0;
    line-height: 0;
}