/**
 * Виджет поддержки покупателей — messenger UI (витрина)
 */

@import url("https://fonts.googleapis.com/css2?family=Mulish:wght@400;600;700&display=swap");

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

.wspf-cs-root button,
.wspf-cs-root input,
.wspf-cs-root textarea,
.wspf-cs-root select {
    font-family: inherit;
    line-height: inherit;
    letter-spacing: normal;
    text-transform: none;
}

.wspf-cs-root h1,
.wspf-cs-root h2,
.wspf-cs-root h3,
.wspf-cs-root h4,
.wspf-cs-root p {
    margin: 0;
    padding: 0;
    font-family: inherit;
    font-weight: inherit;
    letter-spacing: normal;
    text-transform: none;
}

.wspf-cs-root ul,
.wspf-cs-root li {
    list-style: none;
    margin: 0;
    padding: 0;
}

.wspf-cs-root {
    --wspf-cs-accent: #2563eb;
    --wspf-cs-accent-hover: #1d4ed8;
    --wspf-cs-fab-start: #3b82f6;
    --wspf-cs-header: #1e3a5f;
    --wspf-cs-header-text: #f8fafc;
    --wspf-cs-avatar-bg: #3b82f6;
    --wspf-cs-muted: #64748b;
    --wspf-cs-border: #e2e8f0;
    --wspf-cs-surface: #ffffff;
    --wspf-cs-bg: #f1f5f9;
    --wspf-cs-mine: #dbeafe;
    --wspf-cs-mine-border: #bfdbfe;
    --wspf-cs-theirs: #ffffff;
    --wspf-cs-theirs-border: #e2e8f0;
    --wspf-cs-badge-bg: #dbeafe;
    --wspf-cs-badge-text: #1e40af;
    --wspf-cs-on-accent: #ffffff;
    --wspf-cs-radius: 12px;
    --wspf-cs-panel-width: 384px;
    --wspf-cs-panel-height: 576px;
    --wspf-cs-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.wspf-cs-root--mulish {
    --wspf-cs-font: "Mulish", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.wspf-cs-root[hidden] {
    display: none !important;
}

.wspf-cs-root {
    font-family: var(--wspf-cs-font);
}

/* Плавающий виджет — только на витрине (#wspf-cs-root), не на портале в «Мой аккаунт» */
#wspf-cs-root.wspf-cs-root {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1000000;
    pointer-events: none;
}

.wspf-cs-root--left {
    right: auto;
    left: 1.25rem;
}

#wspf-cs-root.wspf-cs-root--left {
    right: auto;
    left: 1.25rem;
}

.wspf-cs-root--left .wspf-cs-panel {
    right: auto;
    left: 0;
}

#wspf-cs-root.wspf-cs-root.is-ready {
    pointer-events: auto;
}

.wspf-cs-fab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.05rem;
    border: none !important;
    border-radius: 999px !important;
    background: linear-gradient(135deg, var(--wspf-cs-fab-start) 0%, var(--wspf-cs-accent) 100%) !important;
    color: var(--wspf-cs-on-accent) !important;
    font-size: 0.9375rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(37, 99, 235, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    pointer-events: auto;
    position: relative;
    z-index: 2;
    width: auto;
    min-width: 0;
    height: auto;
    min-height: 0;
}

.wspf-cs-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(37, 99, 235, 0.5);
    color: var(--wspf-cs-on-accent) !important;
    background: linear-gradient(135deg, var(--wspf-cs-fab-start) 0%, var(--wspf-cs-accent-hover) 100%) !important;
}

.wspf-cs-root.is-open .wspf-cs-fab {
    display: none;
}

.wspf-cs-fab__icon {
    display: inline-flex;
    line-height: 1;
}

.wspf-cs-fab__icon svg {
    display: block;
}

.wspf-cs-panel {
    display: none;
    position: absolute;
    right: 0;
    bottom: 0;
    width: min(var(--wspf-cs-panel-width), calc(100vw - 2rem));
    height: min(var(--wspf-cs-panel-height), calc(100vh - 2rem));
    background: var(--wspf-cs-surface);
    border-radius: var(--wspf-cs-radius);
    box-shadow: 0 16px 48px rgba(30, 58, 95, 0.2);
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(30, 58, 95, 0.08);
    pointer-events: auto;
    z-index: 1;
}

.wspf-cs-root.is-open .wspf-cs-panel {
    display: flex;
}

.wspf-cs-panel__header {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.7rem 0.75rem;
    background: var(--wspf-cs-header);
    color: var(--wspf-cs-header-text);
    flex-shrink: 0;
}

.wspf-cs-panel__header,
.wspf-cs-panel__header * {
    color: var(--wspf-cs-header-text);
}

.wspf-cs-panel__head {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex: 1;
    min-width: 0;
}

.wspf-cs-panel__avatar {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: var(--wspf-cs-avatar-bg);
    color: var(--wspf-cs-on-accent) !important;
    font-weight: 800;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wspf-cs-panel__titles {
    min-width: 0;
}

.wspf-cs-panel__title {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 0.9rem !important;
    font-weight: 700 !important;
    color: var(--wspf-cs-header-text) !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25 !important;
    background: transparent !important;
}

.wspf-cs-panel__subtitle {
    margin: 0.1rem 0 0 !important;
    padding: 0 !important;
    font-size: 0.7rem !important;
    font-weight: 400 !important;
    color: color-mix(in srgb, var(--wspf-cs-header-text) 75%, transparent) !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: transparent !important;
}

@supports not (color: color-mix(in srgb, white 50%, black)) {
    .wspf-cs-panel__subtitle {
        color: var(--wspf-cs-header-text) !important;
        opacity: 0.75;
    }
}

.wspf-cs-icon-btn {
    background: transparent !important;
    border: none !important;
    color: var(--wspf-cs-header-text) !important;
    cursor: pointer;
    padding: 0.35rem !important;
    border-radius: 0.35rem !important;
    line-height: 0;
    flex-shrink: 0;
    appearance: none;
    -webkit-appearance: none;
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

.wspf-cs-icon-btn svg {
    display: block;
    stroke: currentColor;
    color: inherit;
}

.wspf-cs-icon-btn:hover,
.wspf-cs-icon-btn:focus {
    background: rgba(255, 255, 255, 0.12) !important;
    color: var(--wspf-cs-header-text) !important;
    outline: none;
}

.wspf-cs-panel__stage {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    background: var(--wspf-cs-bg);
}

.wspf-cs-panel__body {
    flex: 1;
    overflow: auto;
    padding: 0.875rem;
    min-height: 0;
    background: var(--wspf-cs-bg);
}

.wspf-cs-panel__composer {
    flex-shrink: 0;
    padding: 0.65rem 0.75rem 0.75rem;
    background: var(--wspf-cs-surface);
    border-top: 1px solid var(--wspf-cs-border);
}

.wspf-cs-panel__composer[hidden] {
    display: none !important;
}

.wspf-cs-loading,
.wspf-cs-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--wspf-cs-muted);
    font-size: 0.875rem;
    line-height: 1.5;
}

.wspf-cs-root .wspf-cs-list {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    background: transparent !important;
}

.wspf-cs-root .wspf-cs-list > li {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.wspf-cs-root button.wspf-cs-list__item,
.wspf-cs-root .wspf-cs-list__item {
    display: flex !important;
    align-items: flex-start !important;
    gap: 0.65rem !important;
    width: 100% !important;
    max-width: 100% !important;
    text-align: left !important;
    padding: 0.7rem 0.75rem !important;
    margin: 0 !important;
    border: 1px solid var(--wspf-cs-border) !important;
    border-radius: 0.65rem !important;
    background: #fff !important;
    background-image: none !important;
    color: #0f172a !important;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    appearance: none !important;
    -webkit-appearance: none !important;
    font: inherit !important;
    font-weight: 400 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    text-shadow: none !important;
    min-height: 0 !important;
    height: auto !important;
    min-width: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    opacity: 1 !important;
    filter: none !important;
    transform: none !important;
}

.wspf-cs-root button.wspf-cs-list__item:hover,
.wspf-cs-root button.wspf-cs-list__item:focus,
.wspf-cs-root button.wspf-cs-list__item:active,
.wspf-cs-root button.wspf-cs-list__item:focus-visible,
.wspf-cs-root .wspf-cs-list__item:hover,
.wspf-cs-root .wspf-cs-list__item:focus,
.wspf-cs-root .wspf-cs-list__item:active,
.wspf-cs-root .wspf-cs-list__item:focus-visible,
.wspf-cs-root .wspf-cs-list__item.is-active {
    background: #fff !important;
    background-image: none !important;
    border-color: var(--wspf-cs-accent) !important;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.08) !important;
    color: #0f172a !important;
    outline: none !important;
    opacity: 1 !important;
    filter: none !important;
    transform: none !important;
}

.wspf-cs-root .wspf-cs-list__avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--wspf-cs-avatar-bg);
    color: var(--wspf-cs-on-accent);
    font-size: 0.7rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wspf-cs-root .wspf-cs-list__content {
    flex: 1;
    min-width: 0;
}

.wspf-cs-root .wspf-cs-list__subject {
    font-weight: 700 !important;
    font-size: 0.8125rem !important;
    color: #0f172a !important;
    margin: 0 0 0.2rem !important;
    padding: 0 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: transparent !important;
}

.wspf-cs-root .wspf-cs-list__meta {
    font-size: 0.7rem;
    color: var(--wspf-cs-muted) !important;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    background: transparent !important;
}

.wspf-cs-badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    font-size: 0.625rem;
    font-weight: 700;
    background: var(--wspf-cs-badge-bg);
    color: var(--wspf-cs-badge-text);
    text-transform: uppercase;
}

.wspf-cs-toolbar {
    margin-bottom: 0.75rem;
}

.wspf-cs-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.55rem 0.95rem !important;
    border: none !important;
    border-radius: 0.5rem !important;
    background: var(--wspf-cs-accent) !important;
    color: var(--wspf-cs-on-accent) !important;
    font-size: 0.8125rem !important;
    font-weight: 700 !important;
    cursor: pointer;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    text-decoration: none !important;
    box-shadow: none !important;
    width: auto;
    min-width: 0;
    height: auto;
    min-height: 0;
    text-shadow: none !important;
}

.wspf-cs-btn:hover,
.wspf-cs-btn:focus {
    background: var(--wspf-cs-accent-hover) !important;
    color: var(--wspf-cs-on-accent) !important;
}

.wspf-cs-btn--secondary {
    background: #e2e8f0 !important;
    color: #334155 !important;
}

.wspf-cs-root .wspf-cs-btn--icon,
.wspf-cs-root button.wspf-cs-btn.wspf-cs-btn--icon,
.wspf-cs-root .wspf-cs-compose__send {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 2.35rem !important;
    height: 2.35rem !important;
    min-width: 2.35rem !important;
    max-width: 2.35rem !important;
    min-height: 2.35rem !important;
    max-height: 2.35rem !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 50% !important;
    flex: 0 0 2.35rem !important;
    line-height: 0 !important;
}

.wspf-cs-root .wspf-cs-btn--icon svg,
.wspf-cs-root .wspf-cs-compose__send svg {
    display: block !important;
    width: 1.1rem !important;
    height: 1.1rem !important;
    margin: 0 !important;
}

.wspf-cs-thread {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.wspf-cs-message {
    display: flex;
    flex-direction: column;
    max-width: 88%;
}

.wspf-cs-message--mine {
    align-self: flex-end;
}

.wspf-cs-message--theirs {
    align-self: flex-start;
}

.wspf-cs-message__bubble {
    padding: 0.55rem 0.75rem;
    border-radius: 0.85rem;
    font-size: 0.8125rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    color: #0f172a !important;
}

.wspf-cs-message--mine .wspf-cs-message__bubble {
    background: var(--wspf-cs-mine) !important;
    border: 1px solid var(--wspf-cs-mine-border) !important;
    border-bottom-right-radius: 0.3rem;
}

.wspf-cs-message--theirs .wspf-cs-message__bubble {
    background: var(--wspf-cs-theirs) !important;
    border: 1px solid var(--wspf-cs-theirs-border) !important;
    border-bottom-left-radius: 0.3rem;
}

.wspf-cs-message__meta {
    font-size: 0.625rem;
    color: var(--wspf-cs-muted) !important;
    margin: 0.2rem 0.35rem 0;
}

.wspf-cs-message--mine .wspf-cs-message__meta {
    text-align: right;
}

.wspf-cs-root .wspf-cs-compose {
    display: flex !important;
    align-items: center !important;
    gap: 0.45rem !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
}

.wspf-cs-root .wspf-cs-compose textarea,
.wspf-cs-root .wspf-cs-compose textarea.wspf-cs-compose__input,
.wspf-cs-root .wspf-cs-compose #wspf-cs-reply {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 2.5rem !important;
    min-height: 2.5rem !important;
    max-height: 6.5rem !important;
    resize: none !important;
    padding: 0.55rem 0.85rem !important;
    margin: 0 !important;
    border: 1px solid var(--wspf-cs-border) !important;
    border-radius: 999px !important;
    background: #fff !important;
    color: #0f172a !important;
    font-size: 0.8125rem !important;
    font-family: inherit !important;
    font-weight: 400 !important;
    line-height: 1.35 !important;
    box-sizing: border-box !important;
    box-shadow: none !important;
    outline: none !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    overflow-y: auto !important;
    vertical-align: middle !important;
}

.wspf-cs-root .wspf-cs-compose textarea:focus,
.wspf-cs-root .wspf-cs-compose textarea.wspf-cs-compose__input:focus,
.wspf-cs-root .wspf-cs-compose #wspf-cs-reply:focus {
    border-color: var(--wspf-cs-accent) !important;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--wspf-cs-accent) 25%, transparent) !important;
}

.wspf-cs-root .wspf-cs-compose .wspf-cs-btn--icon,
.wspf-cs-root .wspf-cs-compose .wspf-cs-compose__send {
    align-self: center !important;
}

.wspf-cs-form label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: #475569;
    margin-bottom: 0.25rem;
}

.wspf-cs-form input,
.wspf-cs-form textarea {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 0.6rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--wspf-cs-border);
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-family: inherit;
}

.wspf-cs-form textarea {
    min-height: 5rem;
    resize: vertical;
}

.wspf-cs-form .wspf-cs-btn {
    width: 100%;
}

.wspf-cs-hint {
    font-size: 0.68rem;
    color: #94a3b8;
    margin: -0.35rem 0 0.6rem;
}

.wspf-cs-error {
    padding: 0.65rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
}

.wspf-cs-closed {
    padding: 0.65rem;
    background: #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    color: var(--wspf-cs-muted);
    text-align: center;
    margin-bottom: 0.5rem;
}

.wspf-cs-rate {
    padding: 0.75rem;
    background: var(--wspf-cs-surface);
    border: 1px solid var(--wspf-cs-border);
    border-radius: 0.65rem;
}

.wspf-cs-rate__stars {
    display: flex;
    gap: 0.2rem;
    margin: 0.45rem 0;
}

.wspf-cs-rate__star {
    background: none;
    border: none;
    font-size: 1.35rem;
    cursor: pointer;
    color: #cbd5e1;
    padding: 0;
    line-height: 1;
}

.wspf-cs-rate__star.is-active {
    color: #f59e0b;
}

.wspf-cs-rate textarea {
    width: 100%;
    box-sizing: border-box;
    margin: 0.35rem 0 0.5rem;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--wspf-cs-border);
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-family: inherit;
    resize: vertical;
    min-height: 2.5rem;
}

@media (max-width: 480px) {
    .wspf-cs-root {
        right: 0.75rem;
        bottom: 0.75rem;
    }

    .wspf-cs-fab__label {
        display: none;
    }

    .wspf-cs-panel {
        width: calc(100vw - 1.5rem);
        height: calc(100vh - 1.5rem);
    }
}
