.sales-chat-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #0099d6, #0077a8);
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 153, 214, 0.35);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}
.sales-chat-teaser {
    position: fixed;
    right: 1.5rem;
    bottom: calc(5.75rem + env(safe-area-inset-bottom, 0px));
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: min(18rem, calc(100vw - 2rem));
    padding: 0.625rem 0.875rem 0.625rem 1rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    color: #0f172a;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(10px);
    opacity: 0;
    transform: translateY(10px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.sales-chat-teaser-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.sales-chat-teaser-text {
    appearance: none;
    border: none;
    background: none;
    color: inherit;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.2;
    padding: 0;
    margin: 0;
    cursor: pointer;
    text-align: left;
}
.sales-chat-teaser-text:hover {
    color: #0077a8;
}
.sales-chat-teaser-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    min-width: 1.75rem;
    border: none;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.06);
    color: #475569;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    touch-action: manipulation;
}
.sales-chat-teaser-close:hover {
    background: rgba(15, 23, 42, 0.12);
    color: #0f172a;
}
.sales-chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0, 153, 214, 0.45);
}
.sales-fab-hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}
.sales-chat-teaser-hidden {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
    pointer-events: none;
}

.sales-chat-box {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1001;
    width: 380px;
    max-width: calc(100vw - 2rem);
    height: 520px;
    max-height: calc(100vh - 3rem);
    border-radius: 1rem;
    background: #fafbfc;
    border: 1px solid #e2e8f0;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease;
    transform-origin: bottom right;
}

@supports (height: 100dvh) {
    .sales-chat-box {
        max-height: calc(100dvh - 3rem);
    }
}
.sales-chat-hidden {
    transform: scale(0.3) translateY(40px);
    opacity: 0;
    pointer-events: none;
}

.sales-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    background: linear-gradient(135deg, #0099d6, #0077a8);
    color: white;
    flex-shrink: 0;
}
.sales-chat-header-title {
    font-size: 0.9375rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.sales-chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.125rem;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.15s;
    padding: 0.25rem;
    line-height: 1;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}
.sales-chat-close:hover { opacity: 1; }

.sales-chat-messages {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.sales-chat-bubble {
    max-width: 85%;
    padding: 0.625rem 0.875rem;
    border-radius: 0.875rem;
    font-size: 0.8125rem;
    line-height: 1.55;
    word-wrap: break-word;
}
.sales-bubble-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #0099d6, #0077a8);
    color: white;
    border-bottom-right-radius: 0.2rem;
}
.sales-bubble-agent {
    align-self: flex-start;
    background: white;
    border: 1px solid #e8e8e8;
    color: #334155;
    border-bottom-left-radius: 0.2rem;
}

.sales-chat-reply-preview {
    display: none !important;
    padding: 0.5rem 0.75rem;
    background: #f0f4f8;
    border-top: 1px solid #e2e8f0;
    font-size: 0.75rem;
    line-height: 1.4;
    color: #64748b;
    max-height: 3.5rem;
    overflow: hidden;
    flex-shrink: 0;
}

.sales-chat-input-bar {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    background: white;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}
.sales-chat-input-bar input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    outline: none;
    transition: border-color 0.2s;
}
.sales-chat-input-bar input:focus {
    border-color: #0099d6;
    box-shadow: 0 0 0 2px rgba(0, 153, 214, 0.1);
}
.sales-chat-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.5rem;
    border: none;
    background: linear-gradient(135deg, #0099d6, #0077a8);
    color: white;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation;
}
.sales-chat-send-btn:hover {
    box-shadow: 0 2px 8px rgba(0, 153, 214, 0.3);
}

.sales-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 0.125rem 0;
}
.sales-typing-dots span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: salesTypingBounce 1.2s infinite;
}
.sales-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.sales-typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes salesTypingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* ── Mobile ────────────────────────────────────────────────────── */

/* Lock page scroll when chat is open (class toggled by JS) */
html.sales-chat-open,
html.sales-chat-open body {
    overflow: hidden !important;
    overscroll-behavior: none;
}
/* Solid backdrop behind chat — covers any sub-pixel gaps or rubber-band bounce */
html.sales-chat-open #sales-chat-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(250, 251, 252, 0.96);
    backdrop-filter: blur(8px);
    z-index: 1001;
}

@media (max-width: 767px) {
    .sales-chat-teaser {
        right: calc(1rem + env(safe-area-inset-right, 0px));
        bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px));
        max-width: min(16rem, calc(100vw - 2rem));
    }
    .sales-chat-fab {
        bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
        right: calc(1rem + env(safe-area-inset-right, 0px));
    }
    .sales-chat-box {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: var(--app-height, 100dvh);
        max-height: var(--app-height, 100dvh);
        border-radius: 0;
        border: none;
        box-shadow: none;
        overscroll-behavior: contain;
    }
    .sales-chat-header {
        padding-top: calc(1rem + env(safe-area-inset-top, 0px));
    }
    .sales-chat-messages {
        padding: 1rem;
    }
    .sales-chat-input-bar {
        position: relative;
        z-index: 1;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
        background: rgba(255, 255, 255, 0.98);
    }
    .sales-chat-input-bar input {
        font-size: 16px; /* prevents iOS Safari auto-zoom on focus */
    }
    .sales-chat-send-btn {
        width: 2.75rem;
        height: 2.75rem;
    }
}

@media (min-width: 768px) {
    .sales-chat-teaser {
        display: none;
    }
}
