/* Desktop-only search help chat widget */
.search-help {
    display: none;
}

@media (min-width: 992px) {
    .search-help {
        display: block;
        position: fixed;
        right: 24px;
        bottom: 24px;
        z-index: 2400;
        font-family: inherit;
        /* Keep chat paint isolated from map/list redraws */
        contain: layout style paint;
        pointer-events: none;
    }

    .search-help > * {
        pointer-events: auto;
    }

    .search-help[hidden] {
        display: none !important;
    }

    /* —— FAB —— */
    .search-help__fab {
        display: inline-flex;
        align-items: center;
        gap: 12px;
        border: none;
        cursor: pointer;
        background: #111;
        color: #fff;
        padding: 10px 18px 10px 10px;
        border-radius: 999px;
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .search-help__fab:hover {
        transform: translateY(-2px);
        box-shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
    }

    .search-help__fab.is-open {
        display: none;
    }

    .search-help__fab-avatar,
    .search-help__agent-avatar {
        position: relative;
        width: 42px;
        height: 42px;
        border-radius: 50%;
        background: linear-gradient(145deg, #2d2d2d, #111);
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        color: #fff;
        font-size: 16px;
    }

    .search-help__agent-avatar {
        width: 40px;
        height: 40px;
        background: linear-gradient(145deg, #3a3a3a, #1a1a1a);
    }

    .search-help__online-dot,
    .search-help__status-dot {
        position: absolute;
        right: 1px;
        bottom: 1px;
        width: 11px;
        height: 11px;
        border-radius: 50%;
        background: #22c55e;
        border: 2px solid #111;
        overflow: visible;
        /* Containing block for the pulse pseudo-element */
        transform: translateZ(0);
    }

    .search-help__online-dot::after,
    .search-help__status-dot::after {
        content: '';
        position: absolute;
        left: 50%;
        top: 50%;
        width: 11px;
        height: 11px;
        margin: -5.5px 0 0 -5.5px;
        border-radius: 50%;
        background: rgba(34, 197, 94, 0.45);
        animation: searchHelpPulse 1.8s ease-out infinite;
        pointer-events: none;
        z-index: -1;
    }

    .search-help__status-dot {
        position: relative;
        display: inline-block;
        width: 8px;
        height: 8px;
        border: none;
        margin-right: 5px;
        vertical-align: middle;
        right: auto;
        bottom: auto;
    }

    .search-help__status-dot::after {
        width: 8px;
        height: 8px;
        margin: -4px 0 0 -4px;
    }

    @keyframes searchHelpPulse {
        0% {
            opacity: 0.7;
            transform: scale(1);
        }
        70% {
            opacity: 0;
            transform: scale(2.4);
        }
        100% {
            opacity: 0;
            transform: scale(2.4);
        }
    }

    .search-help__fab-text {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        line-height: 1.2;
        text-align: left;
    }

    .search-help__fab-label {
        font-size: 14px;
        font-weight: 700;
    }

    .search-help__fab-status {
        font-size: 11px;
        color: #86efac;
        font-weight: 500;
        margin-top: 2px;
    }

    /* —— Panel —— */
    .search-help__panel {
        width: 380px;
        height: min(560px, calc(100vh - 48px));
        background: #f4f4f5;
        border: 1px solid #e4e4e7;
        border-radius: 18px;
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
        overflow: hidden;
        display: flex;
        flex-direction: column;
        animation: searchHelpIn 0.22s ease;
    }

    .search-help__panel[hidden] {
        display: none !important;
    }

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

    .search-help__header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 12px 14px;
        background: #111;
        color: #fff;
        flex-shrink: 0;
    }

    .search-help__agent {
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 0;
    }

    .search-help__title {
        margin: 0;
        font-size: 15px;
        font-weight: 700;
        color: #fff;
        line-height: 1.25;
    }

    .search-help__status {
        margin: 3px 0 0;
        font-size: 12px;
        color: #a1a1aa;
        line-height: 1.3;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .search-help__close {
        border: none;
        background: transparent;
        color: #a1a1aa;
        font-size: 26px;
        line-height: 1;
        cursor: pointer;
        padding: 0 4px;
    }

    .search-help__close:hover {
        color: #fff;
    }

    /* —— Thread —— */
    .search-help__thread {
        flex: 1;
        overflow-y: auto;
        padding: 16px 14px;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .search-help__msg {
        display: flex;
        align-items: flex-start;
        gap: 8px;
        max-width: 100%;
        animation: searchHelpBubbleIn 0.18s ease;
    }

    .search-help__msg--bot {
        align-self: flex-start;
        padding-right: 28px;
    }

    .search-help__msg--user {
        align-self: flex-end;
        justify-content: flex-end;
        padding-left: 40px;
    }

    .search-help__msg--system {
        align-self: center;
        justify-content: center;
    }

    .search-help__msg-avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        flex-shrink: 0;
        background: linear-gradient(145deg, #3b82f6, #1d4ed8);
        color: #fff;
        font-size: 12px;
        font-weight: 700;
        letter-spacing: 0.02em;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 1px 3px rgba(29, 78, 216, 0.35);
    }

    .search-help__msg-avatar-spacer {
        width: 32px;
        flex-shrink: 0;
    }

    .search-help__msg-body {
        display: flex;
        flex-direction: column;
        min-width: 0;
        max-width: 100%;
    }

    .search-help__msg-name {
        font-size: 11px;
        font-weight: 600;
        color: #71717a;
        margin: 0 0 3px 4px;
    }

    .search-help__bubble {
        max-width: 100%;
        padding: 10px 12px;
        border-radius: 16px;
        font-size: 14px;
        line-height: 1.45;
        word-wrap: break-word;
        white-space: pre-wrap;
    }

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

    .search-help__bubble--bot {
        background: #fff;
        color: #18181b;
        border: 1px solid #e4e4e7;
        border-bottom-left-radius: 5px;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    }

    .search-help__bubble--user {
        background: #18181b;
        color: #fff;
        border-bottom-right-radius: 5px;
    }

    .search-help__bubble--system {
        background: transparent;
        color: #71717a;
        font-size: 12px;
        text-align: center;
        padding: 4px 8px;
        border: none;
    }

    .search-help__typing-row {
        align-self: flex-start;
        display: flex;
        align-items: flex-start;
        gap: 8px;
        padding-right: 28px;
    }

    .search-help__typing {
        display: inline-flex;
        gap: 4px;
        padding: 12px 14px;
        background: #fff;
        border: 1px solid #e4e4e7;
        border-radius: 16px;
        border-bottom-left-radius: 5px;
    }

    .search-help__typing span {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #a1a1aa;
        animation: searchHelpTyping 1.2s infinite ease-in-out;
    }

    .search-help__typing span:nth-child(2) {
        animation-delay: 0.15s;
    }

    .search-help__typing span:nth-child(3) {
        animation-delay: 0.3s;
    }

    @keyframes searchHelpTyping {
        0%, 80%, 100% {
            opacity: 0.35;
            transform: translateY(0);
        }
        40% {
            opacity: 1;
            transform: translateY(-3px);
        }
    }

    /* —— Composer —— */
    .search-help__composer {
        flex-shrink: 0;
        padding: 10px 12px 12px;
        background: #fff;
        border-top: 1px solid #e4e4e7;
    }

    .search-help__composer-row {
        display: flex;
        align-items: flex-end;
        gap: 8px;
    }

    .search-help__contacts {
        flex-wrap: wrap;
    }

    .search-help__composer-input,
    .search-help__contact-input {
        flex: 1;
        min-width: 0;
        box-sizing: border-box;
        border: 1px solid #e4e4e7;
        border-radius: 18px;
        padding: 10px 14px;
        font-size: 14px;
        color: #18181b;
        background: #f4f4f5;
        outline: none;
        resize: none;
        max-height: 110px;
        line-height: 1.4;
        font-family: inherit;
    }

    .search-help__contact-input {
        flex: 1 1 100%;
        border-radius: 12px;
    }

    .search-help__composer-input:focus,
    .search-help__contact-input:focus {
        border-color: #a1a1aa;
        background: #fff;
    }

    .search-help__send {
        width: 40px;
        height: 40px;
        border: none;
        border-radius: 50%;
        background: #18181b;
        color: #fff;
        cursor: pointer;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
    }

    .search-help__send:hover {
        background: #3f3f46;
    }

    .search-help__send:disabled {
        opacity: 0.45;
        cursor: not-allowed;
    }

    .search-help__contacts .search-help__send {
        margin-left: auto;
    }

    .search-help__call {
        display: block;
        margin-top: 8px;
        text-align: center;
        font-size: 12px;
        color: #71717a;
        text-decoration: none;
    }

    .search-help__call:hover {
        color: #18181b;
        text-decoration: underline;
    }

    .search-help__error {
        margin: 0 0 8px;
        font-size: 12px;
        color: #dc2626;
    }

    .search-help__hp {
        position: absolute;
        left: -9999px;
        opacity: 0;
        height: 0;
        width: 0;
    }
}
