/* ── Sales Bot Widget ── */
#sales-bot * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

#sales-bot {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    color: #1a2b4c;
}

/* ── Toggle button ── */
#sales-bot .sb-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #2a8cdc;
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(42, 140, 220, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

/* ── Pulse animation (gentle, every 3s) ── */
@keyframes sbPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 4px 20px rgba(42,140,220,0.35); }
    50% { transform: scale(1.06); box-shadow: 0 6px 30px rgba(42,140,220,0.50); }
}
@keyframes sbRingPulse {
    0% { transform: scale(1); opacity: 0.45; }
    100% { transform: scale(1.3); opacity: 0; }
}

/* Apply pulse only on devices that support hover (desktop) */
@media (hover: hover) {
    #sales-bot .sb-toggle:not(:hover) {
        animation: sbPulse 3s ease-in-out 2s infinite;
    }
    #sales-bot .sb-toggle::before {
        content: '';
        position: absolute;
        inset: -6px;
        border-radius: 50%;
        border: 2px solid rgba(42, 140, 220, 0.25);
        pointer-events: none;
        animation: sbRingPulse 3s ease-in-out 0s infinite;
    }
}

#sales-bot .sb-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(42, 140, 220, 0.45);
}
#sales-bot.sb-open .sb-toggle {
    animation: none !important;
    transform: none;
}
#sales-bot.sb-open .sb-toggle::before {
    animation: none !important;
    opacity: 0;
}
#sales-bot .sb-toggle svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
}
#sales-bot .sb-toggle .sb-close-icon { display: none; }
#sales-bot.sb-open .sb-toggle .sb-open-icon { display: none; }
#sales-bot.sb-open .sb-toggle .sb-close-icon { display: block; }

/* ── Chat window ── */
#sales-bot .sb-window {
    position: fixed;
    bottom: 92px;
    right: 24px;
    z-index: 9998;
    width: 380px;
    max-height: 600px;
    height: calc(100vh - 140px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: sbFadeIn 0.25s ease;
}
#sales-bot.sb-open .sb-window { display: flex; }

@keyframes sbFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ── */
#sales-bot .sb-header {
    background: #2a8cdc;
    color: #fff;
    padding: 16px 18px;
    flex-shrink: 0;
}
#sales-bot .sb-header-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.3px;
}
#sales-bot .sb-header-sub {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
}
#sales-bot .sb-header-phones {
    margin-top: 8px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
#sales-bot .sb-header-phones a {
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    opacity: 0.95;
}
#sales-bot .sb-header-phones a:hover { opacity: 1; text-decoration: underline; }

/* ── Messenger bar ── */
#sales-bot .sb-messengers {
    display: flex;
    gap: 4px;
    padding: 10px 18px;
    background: #f0f6fe;
    border-bottom: 1px solid #e4edf5;
    flex-shrink: 0;
}
#sales-bot .sb-messengers a {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    color: #1a2b4c;
    background: #fff;
    border: 1px solid #d4e0ec;
    transition: background 0.15s, border-color 0.15s;
}
#sales-bot .sb-messengers a:hover {
    background: #e4edf5;
    border-color: #b8cde0;
}
#sales-bot .sb-messengers a .sb-messenger-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

/* ── Messages area ── */
#sales-bot .sb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    background: #f8fafc;
}
#sales-bot .sb-msg {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.45;
    margin-bottom: 10px;
    animation: sbMsgIn 0.2s ease;
}
@keyframes sbMsgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
#sales-bot .sb-msg.bot {
    background: #fff;
    border: 1px solid #e4edf5;
    color: #1a2b4c;
    border-bottom-left-radius: 4px;
    margin-right: auto;
}
#sales-bot .sb-msg.user {
    background: #2a8cdc;
    color: #fff;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}
#sales-bot .sb-msg.system {
    background: transparent;
    color: #888;
    font-size: 12px;
    text-align: center;
    padding: 4px 0;
    margin-bottom: 6px;
}

/* ── Action buttons ── */
#sales-bot .sb-actions {
    padding: 6px 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
#sales-bot .sb-action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    color: #1a2b4c;
    background: #fff;
    border: 1px solid #d4e0ec;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    text-align: left;
}
#sales-bot .sb-action-btn:hover {
    background: #f0f6fe;
    border-color: #2a8cdc;
    transform: translateY(-1px);
}
#sales-bot .sb-action-btn:active {
    transform: translateY(0);
}
#sales-bot .sb-action-btn .sb-action-icon { font-size: 18px; flex-shrink: 0; }
#sales-bot .sb-action-btn.primary {
    background: #2a8cdc;
    color: #fff;
    border-color: #2a8cdc;
}
#sales-bot .sb-action-btn.primary:hover {
    background: #1f7bc9;
    border-color: #1f7bc9;
}

/* ── Input area (hidden by default) ── */
#sales-bot .sb-input-area {
    display: none;
    padding: 10px 16px 14px;
    border-top: 1px solid #e4edf5;
    gap: 8px;
    flex-shrink: 0;
}
#sales-bot .sb-input-area.sb-visible { display: flex; }
#sales-bot .sb-input-area input,
#sales-bot .sb-input-area textarea {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid #d4e0ec;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    resize: none;
    transition: border-color 0.15s;
}
#sales-bot .sb-input-area input:focus,
#sales-bot .sb-input-area textarea:focus {
    border-color: #2a8cdc;
}
#sales-bot .sb-input-area textarea { min-height: 36px; max-height: 80px; }
#sales-bot .sb-input-area button {
    padding: 9px 16px;
    border-radius: 8px;
    border: none;
    background: #2a8cdc;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
#sales-bot .sb-input-area button:hover { background: #1f7bc9; }
#sales-bot .sb-input-area button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Lead form ── */
#sales-bot .sb-lead-form {
    padding: 6px 16px 14px;
}
#sales-bot .sb-lead-form input,
#sales-bot .sb-lead-form textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d4e0ec;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    margin-bottom: 8px;
    transition: border-color 0.15s;
}
#sales-bot .sb-lead-form input:focus,
#sales-bot .sb-lead-form textarea:focus {
    border-color: #2a8cdc;
}
#sales-bot .sb-lead-form textarea { min-height: 54px; resize: none; }
#sales-bot .sb-lead-form .sb-submit-btn {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: none;
    background: #2a8cdc;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}
#sales-bot .sb-lead-form .sb-submit-btn:hover { background: #1f7bc9; }
#sales-bot .sb-lead-form .sb-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
#sales-bot .sb-lead-form .sb-error {
    color: #dc3545;
    font-size: 12px;
    margin-bottom: 6px;
    display: none;
}
#sales-bot .sb-lead-form .sb-error.sb-visible { display: block; }

/* ── Success message ── */
#sales-bot .sb-success {
    text-align: center;
    padding: 20px 16px;
    color: #28a745;
    font-weight: 600;
    font-size: 15px;
}

/* ── Mobile ── */
@media (max-width: 767px) {
    #sales-bot .sb-toggle {
        bottom: 78px;
        right: 14px;
        width: 52px;
        height: 52px;
    }
    #sales-bot .sb-window {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
}

/* Disable pulse on touch devices (mobile) — was causing invisible widget */
@media (hover: none) and (max-width: 767px) {
    #sales-bot .sb-toggle {
        animation: none !important;
    }
    #sales-bot .sb-toggle::before {
        animation: none !important;
        opacity: 0;
    }
}

/* ── Mobile visibility safeguard ──
 * Fixes rendering issues on mobile browsers where ::before/position:fixed
 * can cause the widget to become invisible or unclickable.
 * Scoped to max-width:768px, does not affect desktop. */
@media (max-width: 768px) {
    #sales-bot {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    #sales-bot .sb-toggle {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}
