﻿/* =========================================================
   FBT Shop – KI-Shopberater (Chat-Widget)
   Dunkles Shop-Design (Akzent var(--accent)).
   Desktop: schwebendes Fenster unten rechts
   Mobil (< 640px): Vollbild
   ========================================================= */

.fbt-chat-launcher {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1000;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 54px;
    padding: 0 20px 0 8px;
    border: 1px solid rgba(0, 0, 0, 0.25);
    border-radius: 999px;
    background: var(--accent, #f5a623);
    color: #0a0a0a;
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

    .fbt-chat-launcher:hover {
        background: var(--accent-hover, #e09015);
        transform: translateY(-2px);
        box-shadow: 0 14px 32px rgba(var(--accent-rgb, 245, 166, 35), 0.35);
    }

    .fbt-chat-launcher:focus-visible {
        outline: 3px solid #fff;
        outline-offset: 3px;
    }

    .fbt-chat-launcher[aria-expanded="true"] {
        opacity: 0;
        pointer-events: none;
    }

.fbt-chat-launcher__icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #0a0a0a;
    color: var(--accent, #f5a623);
    font-size: 1.15rem;
}

.fbt-chat-launcher__text strong {
    font-weight: 800;
}

/* ---------- Fenster ---------- */
.fbt-chat {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 10001;
    width: 410px;
    max-width: calc(100vw - 32px);
    height: 650px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-light, #333);
    border-radius: 14px;
    background: var(--bg-card, #141414);
    color: var(--text-primary, #fff);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 0.95rem;
    line-height: 1.5;
    animation: fbtChatIn 0.22s ease-out;
}

    .fbt-chat[hidden] {
        display: none;
    }

@keyframes fbtChatIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.fbt-chat .visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.fbt-chat__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 10px 12px 14px;
    background: #000;
    border-bottom: 2px solid var(--accent, #f5a623);
    flex-shrink: 0;
}

.fbt-chat__avatar {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--accent, #f5a623);
    color: #0a0a0a;
    font-size: 1.2rem;
}

.fbt-chat__heading {
    flex: 1;
    min-width: 0;
}

.fbt-chat__title {
    margin: 0;
    font-family: var(--font-heading, 'Oswald', sans-serif);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #fff;
    line-height: 1.2;
}

.fbt-chat__subtitle {
    margin: 2px 0 0;
    font-size: 0.76rem;
    color: var(--text-secondary, #b0b0b0);
    display: flex;
    align-items: center;
    gap: 6px;
}

.fbt-chat__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success, #27ae60);
    box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.3);
}

.fbt-chat__icon-btn {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

    .fbt-chat__icon-btn:hover {
        background: var(--bg-surface-light, #252525);
        color: var(--accent, #f5a623);
    }

    .fbt-chat__icon-btn:focus-visible {
        outline: 2px solid var(--accent, #f5a623);
        outline-offset: 1px;
    }

/* ---------- Einwilligung ---------- */
.fbt-chat__consent {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 18px 0;
    text-align: center;
    background: var(--bg-dark, #0a0a0a);
    overscroll-behavior: contain;
}

    .fbt-chat__consent[hidden] {
        display: none;
    }

    .fbt-chat__consent h3 {
        margin: 10px 0 4px;
        font-family: var(--font-heading, 'Oswald', sans-serif);
        font-size: 1.1rem;
        line-height: 1.3;
        font-weight: 700;
        letter-spacing: 0.3px;
        text-transform: none;
        color: #fff;
    }

    .fbt-chat__consent p {
        margin: 0 0 12px;
        color: var(--text-secondary, #b0b0b0);
        font-size: 0.9rem;
    }

.fbt-chat__consent-icon {
    width: 50px;
    height: 50px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--accent, #f5a623);
    color: #0a0a0a;
    font-size: 1.35rem;
}

.fbt-chat__consent-list {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
    text-align: left;
}

    .fbt-chat__consent-list li {
        display: flex;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 8px;
        padding: 9px 12px;
        border-radius: 10px;
        background: var(--bg-card, #141414);
        border: 1px solid var(--border, #2a2a2a);
        font-size: 0.85rem;
        color: #e5e5e5;
    }

    .fbt-chat__consent-list i {
        flex: 0 0 16px;
        margin-top: 2px;
        text-align: center;
        color: var(--accent, #f5a623);
    }

    /* Text als EIN Block, damit <strong> nicht als eigene Spalte umbricht */
    .fbt-chat__consent-list li > span {
        flex: 1 1 auto;
        min-width: 0;
        line-height: 1.45;
    }

/* Startknopf bleibt beim Scrollen immer sichtbar */
.fbt-chat__consent .fbt-chat__primary {
    position: sticky;
    bottom: 0;
    box-shadow: 0 -12px 16px var(--bg-dark, #0a0a0a);
}

.fbt-chat__primary {
    width: 100%;
    padding: 13px 18px;
    border: 0;
    border-radius: 8px;
    background: var(--accent, #f5a623);
    color: #0a0a0a;
    font-family: var(--font-heading, 'Oswald', sans-serif);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s ease;
}

    .fbt-chat__primary:hover {
        background: var(--accent-hover, #e09015);
    }

    .fbt-chat__primary:focus-visible {
        outline: 3px solid #fff;
        outline-offset: 2px;
    }

.fbt-chat__consent-links {
    margin: 10px 0 0 !important;
    padding-bottom: 14px;
    font-size: 0.8rem !important;
}

    .fbt-chat__consent-links a {
        white-space: nowrap;
    }

.fbt-chat a {
    color: var(--accent, #f5a623);
    text-decoration: underline;
    text-underline-offset: 2px;
}

    .fbt-chat a:hover {
        color: var(--accent-hover, #e09015);
    }

/* ---------- Verlauf ---------- */
.fbt-chat__body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark, #0a0a0a);
}

    .fbt-chat__body[hidden] {
        display: none;
    }

.fbt-chat__log {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overscroll-behavior: contain;
    scrollbar-color: var(--border-light, #333) transparent;
}

    .fbt-chat__log:focus-visible {
        outline: 2px solid var(--accent, #f5a623);
        outline-offset: -2px;
    }

.fbt-chat__msg {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 14px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.fbt-chat__msg--assistant {
    align-self: flex-start;
    background: var(--bg-surface, #1e1e1e);
    border: 1px solid var(--border, #2a2a2a);
    border-bottom-left-radius: 4px;
    color: #f2f2f2;
}

.fbt-chat__msg--user {
    align-self: flex-end;
    background: var(--accent, #f5a623);
    color: #0a0a0a;
    border-bottom-right-radius: 4px;
    white-space: pre-wrap;
    font-weight: 500;
}

.fbt-chat__msg--error {
    align-self: stretch;
    max-width: none;
    background: rgba(233, 69, 96, 0.12);
    border: 1px solid rgba(233, 69, 96, 0.5);
    color: #ffb3c0;
    font-size: 0.88rem;
}

.fbt-chat__msg--info {
    align-self: stretch;
    max-width: none;
    background: rgba(var(--accent-rgb, 245, 166, 35), 0.1);
    border: 1px solid rgba(var(--accent-rgb, 245, 166, 35), 0.45);
    color: #ffd99a;
    font-size: 0.85rem;
}

.fbt-chat__msg p {
    margin: 0 0 8px;
}

    .fbt-chat__msg p:last-child {
        margin-bottom: 0;
    }

.fbt-chat__msg ul,
.fbt-chat__msg ol {
    margin: 4px 0 8px;
    padding-left: 20px;
}

    .fbt-chat__msg ul:last-child,
    .fbt-chat__msg ol:last-child {
        margin-bottom: 0;
    }

.fbt-chat__msg li {
    margin-bottom: 4px;
}

    .fbt-chat__msg li::marker {
        color: var(--accent, #f5a623);
    }

.fbt-chat__msg strong {
    font-weight: 700;
    color: #fff;
}

.fbt-chat__msg--user strong {
    color: #0a0a0a;
}

.fbt-chat__status {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary, #b0b0b0);
    font-size: 0.85rem;
}

    .fbt-chat__status i {
        color: var(--accent, #f5a623);
        animation: fbtChatPulse 1.2s infinite ease-in-out;
    }

@keyframes fbtChatPulse {
    0%, 100% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }
}

.fbt-chat__typing {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}

    .fbt-chat__typing span {
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background: var(--accent, #f5a623);
        animation: fbtChatDot 1.2s infinite ease-in-out;
    }

        .fbt-chat__typing span:nth-child(2) {
            animation-delay: 0.15s;
        }

        .fbt-chat__typing span:nth-child(3) {
            animation-delay: 0.3s;
        }

@keyframes fbtChatDot {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }

    40% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

/* ---------- Vorschläge ---------- */
.fbt-chat__chips {
    display: flex;
    gap: 8px;
    padding: 4px 14px 10px;
    overflow-x: auto;
    scrollbar-width: none;
    flex-shrink: 0;
}

    .fbt-chat__chips::-webkit-scrollbar {
        display: none;
    }

    .fbt-chat__chips[hidden] {
        display: none;
    }

.fbt-chat__chip {
    flex-shrink: 0;
    padding: 7px 12px;
    border: 1px solid rgba(var(--accent-rgb, 245, 166, 35), 0.55);
    border-radius: 999px;
    background: transparent;
    color: var(--accent, #f5a623);
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s ease, color 0.2s ease;
}

    .fbt-chat__chip:hover {
        background: var(--accent, #f5a623);
        color: #0a0a0a;
    }

    .fbt-chat__chip:focus-visible {
        outline: 2px solid #fff;
        outline-offset: 1px;
    }

/* ---------- Eingabe ---------- */
.fbt-chat__form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin: 0;
    padding: 10px 12px;
    background: var(--bg-card, #141414);
    border-top: 1px solid var(--border, #2a2a2a);
    flex-shrink: 0;
}

.fbt-chat__input {
    flex: 1;
    min-height: 44px;
    max-height: 140px;
    padding: 11px 14px;
    border: 1px solid var(--border-light, #333);
    border-radius: 10px;
    background: var(--bg-surface, #1e1e1e);
    color: #fff;
    font: inherit;
    font-size: 16px !important; /* unter 16px zoomt iOS beim Antippen automatisch hinein */
    line-height: 1.35;
    resize: none;
    -webkit-appearance: none;
    appearance: none;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

    .fbt-chat__input::placeholder {
        color: var(--text-muted, #707070);
    }

    .fbt-chat__input:focus {
        outline: none;
        border-color: var(--accent, #f5a623);
        box-shadow: 0 0 0 3px rgba(var(--accent-rgb, 245, 166, 35), 0.2);
    }

.fbt-chat__send {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border: 0;
    border-radius: 10px;
    background: var(--accent, #f5a623);
    color: #0a0a0a;
    font-size: 1.05rem;
    cursor: pointer;
}

    .fbt-chat__send:disabled {
        opacity: 0.45;
        cursor: not-allowed;
    }

    .fbt-chat__send[hidden] {
        display: none;
    }

    .fbt-chat__send:focus-visible {
        outline: 3px solid #fff;
        outline-offset: 2px;
    }

.fbt-chat__stop {
    background: var(--bg-surface-light, #252525);
    color: #fff;
    border: 1px solid var(--border-light, #333);
}

.fbt-chat__footnote {
    margin: 0;
    padding: 0 12px 10px;
    background: var(--bg-card, #141414);
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-muted, #8a8a8a);
    flex-shrink: 0;
}

    .fbt-chat__footnote a {
        color: var(--text-secondary, #b0b0b0);
    }

/* ---------- Responsiv ---------- */
@media (max-width: 768px) {
    .fbt-chat-launcher {
        right: 15px;
        bottom: 15px;
        height: 48px;
        padding: 0 14px 0 6px;
        font-size: 0.85rem;
    }

    .fbt-chat-launcher__icon {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 640px) {
    /* Vollbild; Höhe folgt dem sichtbaren Bereich (Tastatur) – per JS über --fbt-chat-h/--fbt-chat-top */
    .fbt-chat {
        top: var(--fbt-chat-top, 0px);
        left: 0;
        right: 0;
        bottom: auto;
        width: 100%;
        max-width: none;
        height: 100vh;
        height: var(--fbt-chat-h, 100dvh);
        max-height: none;
        border: 0;
        border-radius: 0;
        animation: none;
    }

    .fbt-chat__log {
        padding: 12px 10px 6px;
    }

    .fbt-chat__msg {
        max-width: 92%;
    }

    .fbt-chat__form {
        padding: 8px 10px;
    }

    .fbt-chat__chips {
        padding: 4px 10px 8px;
    }

    .fbt-chat__header {
        padding-top: calc(10px + env(safe-area-inset-top));
    }

    .fbt-chat__footnote {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }

    html.fbt-chat-open,
    body.fbt-chat-open {
        overflow: hidden;
        overscroll-behavior: none;
    }
}

@media (max-width: 380px) {
    .fbt-chat-launcher__text {
        display: none;
    }

    .fbt-chat-launcher {
        padding: 0 6px;
    }
}

@media print {
    .fbt-chat-launcher,
    .fbt-chat {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fbt-chat,
    .fbt-chat-launcher,
    .fbt-chat__typing span,
    .fbt-chat__status i {
        animation: none;
        transition: none;
    }
}
