/* ============================================================================
 * STOCKflow chat widget
 * Floating support/chat panel, bottom-right.
 * Tokens komen uit blocks-tokens.css (--sf-brand-*, --sf-ink-*).
 * ========================================================================== */

.sfc-root,
.sfc-root *,
.sfc-root *::before,
.sfc-root *::after {
    box-sizing: border-box;
}

.sfc-root {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 99999;
    isolation: isolate;
    pointer-events: none; /* root zelf vangt niks — alleen child elementen */
    font-family: var(--sf-font-body, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
    color: var(--sf-ink-900, #0C1626);
    line-height: 1.4;
}

/* Klikbare children krijgen expliciet pointer-events terug */
.sfc-root .sfc-fab,
.sfc-root .sfc-teaser,
.sfc-root[data-open="true"] .sfc-panel {
    pointer-events: auto;
}

/* ----- FAB (collapsed state) -------------------------------------------- */
.sfc-fab {
    position: relative;
    z-index: 2; /* boven panel binnen root */
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 0;
    cursor: pointer;
    background: linear-gradient(135deg, var(--sf-brand-500, #018EFF) 0%, var(--sf-brand-600, #0067AD) 100%);
    box-shadow: 0 8px 24px -6px rgba(1, 142, 255, 0.45), 0 4px 10px -4px rgba(12, 22, 38, 0.25);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-left: auto;
}

.sfc-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px -6px rgba(1, 142, 255, 0.55), 0 6px 14px -4px rgba(12, 22, 38, 0.30);
}

.sfc-fab__icon {
    width: 26px;
    height: 26px;
    transition: opacity 0.15s, transform 0.15s;
}

.sfc-fab__icon--close {
    position: absolute;
    opacity: 0;
    transform: rotate(-45deg);
}

.sfc-root[data-open="true"] .sfc-fab__icon--chat {
    opacity: 0;
    transform: rotate(45deg);
}

.sfc-root[data-open="true"] .sfc-fab__icon--close {
    opacity: 1;
    transform: rotate(0);
}

.sfc-fab__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #FF4D4F;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

.sfc-root[data-open="true"] .sfc-fab__badge,
.sfc-root[data-dismissed-badge="true"] .sfc-fab__badge {
    display: none;
}

/* ----- Teaser (above FAB, before first open) ---------------------------- */
.sfc-teaser {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border-radius: 999px;
    padding: 8px 16px 8px 8px;
    box-shadow: 0 8px 24px -8px rgba(12, 22, 38, 0.18), 0 2px 6px -2px rgba(12, 22, 38, 0.08);
    margin-bottom: 14px;
    margin-left: auto;
    max-width: 320px;
    cursor: pointer;
    transform: translateY(8px);
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    border: 0;
    font-family: inherit;
    color: var(--sf-ink-900, #0C1626);
    text-align: left;
}

.sfc-root[data-teaser="true"] .sfc-teaser {
    transform: translateY(0);
    opacity: 1;
}

.sfc-root[data-open="true"] .sfc-teaser,
.sfc-root[data-teaser="false"] .sfc-teaser {
    display: none;
}

.sfc-teaser__avatar {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sf-brand-400, #00B0FF), var(--sf-brand-600, #0067AD));
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sfc-teaser__text {
    font-size: 13px;
    color: var(--sf-ink-800, #18243A);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sfc-teaser__text strong {
    color: var(--sf-ink-900, #0C1626);
    font-weight: 600;
}

/* ----- Panel ----------------------------------------------------------- */
.sfc-panel {
    position: absolute;
    right: 0;
    bottom: 76px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 24px 48px -16px rgba(12, 22, 38, 0.28), 0 10px 24px -8px rgba(12, 22, 38, 0.14);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(16px) scale(0.98);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform-origin: bottom right;
}

.sfc-root[data-open="true"] .sfc-panel {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Header */
.sfc-header {
    background: linear-gradient(135deg, var(--sf-ink-900, #0C1626) 0%, var(--sf-brand-900, #002A55) 60%, var(--sf-brand-700, #014580) 100%);
    color: #fff;
    padding: 18px 18px 20px;
    position: relative;
}

.sfc-header::after {
    /* subtle dotted pattern */
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, rgba(255,255,255,0.06) 1px, transparent 1px);
    background-size: 14px 14px;
    pointer-events: none;
    opacity: 0.6;
}

.sfc-header__row {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.sfc-header__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sf-brand-300, #00D1FF), var(--sf-brand-600, #0067AD));
    color: #fff;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.sfc-header__title {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}

.sfc-header__title span {
    opacity: 0.65;
    font-weight: 400;
    margin-left: 4px;
}

.sfc-header__status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
    font-weight: 400;
}

.sfc-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22C55E;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
}

.sfc-header__close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 0;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex: 0 0 28px;
}

.sfc-header__close:hover {
    background: rgba(255, 255, 255, 0.16);
}

.sfc-header__close svg {
    width: 14px;
    height: 14px;
}

/* Messages */
.sfc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fff;
}

.sfc-divider {
    text-align: center;
    color: var(--sf-ink-400, #8A95A8);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin: 4px 0 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sfc-divider::before,
.sfc-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--sf-line-200, #E5EAF2);
}

.sfc-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: sfc-pop 0.25s ease-out;
}

@keyframes sfc-pop {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.sfc-msg--bot {
    align-self: flex-start;
}

.sfc-msg--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.sfc-msg__avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sf-brand-400, #00B0FF), var(--sf-brand-600, #0067AD));
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 26px;
    margin-top: 2px;
}

.sfc-msg--user .sfc-msg__avatar {
    display: none;
}

.sfc-msg__bubble {
    background: var(--sf-line-100, #EEF1F6);
    color: var(--sf-ink-900, #0C1626);
    padding: 9px 13px;
    border-radius: 14px;
    border-top-left-radius: 4px;
    font-size: 13.5px;
}

.sfc-msg--user .sfc-msg__bubble {
    background: var(--sf-brand-500, #018EFF);
    color: #fff;
    border-radius: 14px;
    border-top-right-radius: 4px;
}

/* Typing indicator */
.sfc-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 12px 14px;
}
.sfc-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--sf-ink-400, #8A95A8);
    animation: sfc-blink 1.2s infinite both;
}
.sfc-typing span:nth-child(2) { animation-delay: 0.15s; }
.sfc-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes sfc-blink {
    0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-2px); }
}

/* Quick replies */
.sfc-quick {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
    margin-top: 4px;
}

.sfc-quick__btn {
    background: #fff;
    border: 1.5px solid var(--sf-brand-500, #018EFF);
    color: var(--sf-brand-600, #0067AD);
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s, transform 0.1s;
}

.sfc-quick__btn:hover {
    background: var(--sf-brand-500, #018EFF);
    color: #fff;
}

.sfc-quick__btn:active {
    transform: scale(0.97);
}

.sfc-quick--disabled .sfc-quick__btn {
    pointer-events: none;
    opacity: 0.5;
}

/* Inline lead form */
.sfc-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--sf-surface, #F7F9FC);
    border: 1px solid var(--sf-line-200, #E5EAF2);
    border-radius: 12px;
    padding: 12px;
    margin-top: 4px;
}

.sfc-form__row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sfc-form__label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--sf-ink-500, #5B6878);
    letter-spacing: 0.02em;
}

.sfc-form__input,
.sfc-form__textarea {
    background: #fff;
    border: 1px solid var(--sf-line-200, #E5EAF2);
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--sf-ink-900, #0C1626);
    width: 100%;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.sfc-form__input:focus,
.sfc-form__textarea:focus {
    outline: 0;
    border-color: var(--sf-brand-500, #018EFF);
    box-shadow: 0 0 0 3px rgba(1, 142, 255, 0.15);
}

.sfc-form__textarea {
    resize: vertical;
    min-height: 64px;
}

.sfc-form__submit {
    background: linear-gradient(135deg, var(--sf-brand-500, #018EFF), var(--sf-brand-600, #0067AD));
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 10px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    margin-top: 4px;
    transition: opacity 0.15s, transform 0.1s;
}

.sfc-form__submit:hover { opacity: 0.92; }
.sfc-form__submit:active { transform: scale(0.99); }
.sfc-form__submit:disabled { opacity: 0.5; cursor: progress; }

.sfc-form__error {
    color: #B91C1C;
    font-size: 12px;
    margin-top: 2px;
}

/* Composer (bottom input bar) */
.sfc-root[data-form-active="true"] .sfc-composer {
    display: none;
}

.sfc-composer {
    border-top: 1px solid var(--sf-line-200, #E5EAF2);
    padding: 10px 12px 8px;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sfc-composer__input {
    flex: 1;
    background: var(--sf-surface, #F7F9FC);
    border: 1px solid var(--sf-line-200, #E5EAF2);
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--sf-ink-900, #0C1626);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.sfc-composer__input:focus {
    outline: 0;
    border-color: var(--sf-brand-300, #00D1FF);
    box-shadow: 0 0 0 3px rgba(0, 209, 255, 0.15);
    background: #fff;
}

.sfc-composer__send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 0;
    background: linear-gradient(135deg, var(--sf-brand-500, #018EFF), var(--sf-brand-600, #0067AD));
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s, transform 0.1s;
}

.sfc-composer__send:hover { opacity: 0.92; }
.sfc-composer__send:active { transform: scale(0.95); }
.sfc-composer__send svg {
    width: 16px;
    height: 16px;
}

/* Footer */
.sfc-footer {
    padding: 8px 0 10px;
    text-align: center;
    background: #fff;
    border-top: 1px solid var(--sf-line-200, #E5EAF2);
    font-family: var(--sf-font-mono, ui-monospace, "SF Mono", Menlo, monospace);
    font-size: 9.5px;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--sf-ink-400, #8A95A8);
}

.sfc-footer strong {
    color: var(--sf-brand-600, #0067AD);
    font-weight: 700;
}

/* Mobile tweaks */
@media (max-width: 480px) {
    .sfc-root {
        right: 12px;
        bottom: 12px;
    }
    .sfc-panel {
        width: calc(100vw - 24px);
        height: calc(100vh - 88px);
        bottom: 72px;
    }
    .sfc-teaser {
        max-width: 240px;
    }
    .sfc-teaser__text { font-size: 12px; }
}
