/* ----------------------------------- */
/* : Live Chat Widget : */

.chat-widget {
    position: fixed;
    inset-inline-end: 24px;
    bottom: 24px;
    z-index: 1055;
    font-family: var(--font-family-base);
}

.chat-widget-launcher {
    position: absolute;
    bottom: 0;
    inset-inline-end: 0;
    width: var(--square-btn-dimension-lg);
    height: var(--square-btn-dimension-lg);
    border-radius: var(--radius-full);
    background-color: var(--indigo);
    border: 1px solid var(--indigo);
    color: var(--white);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    transition: all 0.15s var(--transition-function-1, ease-out);
}

.chat-widget-launcher:hover {
    background-color: var(--indigo-hover);
    border-color: var(--indigo-hover);
    transform: translateY(-2px);
}

.chat-widget-launcher i {
    font-size: 22px;
    line-height: 1;
}

.chat-widget.is-open .chat-widget-launcher {
    display: none;
}

.chat-widget-badge {
    position: absolute;
    top: -4px;
    inset-inline-end: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: var(--radius-full);
    background-color: var(--red);
    color: var(--white);
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 20px;
    text-align: center;
}

.chat-widget-badge.w-hidden {
    display: none;
}

.chat-widget-panel {
    position: absolute;
    bottom: 0;
    inset-inline-end: 0;
    width: 340px;
    max-height: min(85vh, 640px);
    display: none;
    flex-direction: column;
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    transition: all 0.15s var(--transition-function-1, ease-out);
}

.chat-widget.is-open .chat-widget-panel {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
}

.chat-widget-header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 2.5rem 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    background-color: var(--secondary-bg);
}

.chat-widget-close {
    position: absolute;
    top: 0.5rem;
    inset-inline-end: 0.5rem;
    width: var(--square-btn-dimension-xs);
    height: var(--square-btn-dimension-xs);
    border-radius: var(--radius-full);
    background-color: transparent;
    border: 1px solid transparent;
    color: var(--muted-foreground);
    transition: all 0.15s var(--transition-function-1, ease-out);
}

.chat-widget-close:hover {
    background-color: var(--accent);
    color: var(--foreground);
}

.chat-widget-close i {
    font-size: 14px;
    line-height: 1;
}

.chat-widget-header-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: var(--radius-full);
    background-color: var(--indigo);
    color: var(--white);
}

.chat-widget-header-avatar i {
    font-size: 16px;
    line-height: 1;
}

.chat-widget-header-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.chat-widget-header-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--foreground);
}

.chat-widget-header-status {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: var(--text-xs);
    color: var(--muted-foreground);
}

.chat-widget-header-status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: var(--radius-full);
    background-color: var(--green);
}

.chat-widget-messages,
.chat-widget-form textarea {
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--background);
}

.chat-widget-messages::-webkit-scrollbar,
.chat-widget-form textarea::-webkit-scrollbar {
    width: 6px;
    background: var(--background);
    border-radius: var(--radius-lg);
}

.chat-widget-messages::-webkit-scrollbar-thumb,
.chat-widget-form textarea::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-lg);
}

.chat-widget-messages {
    flex: 1 1 auto;
    min-height: 340px;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.chat-widget-message {
    max-width: 85%;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-widget-message.is-operator {
    align-self: flex-start;
    background-color: var(--secondary-bg);
    color: var(--foreground-text);
    border: 1px solid var(--border);
    border-bottom-left-radius: var(--radius-none);
}

.chat-widget-message.is-visitor {
    align-self: flex-end;
    background-color: var(--indigo);
    color: var(--white);
    border-bottom-right-radius: var(--radius-none);
}

.chat-widget-greeting {
    align-self: flex-start;
    max-width: 90%;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-md);
    border-bottom-left-radius: var(--radius-none);
    background-color: var(--secondary-bg);
    border: 1px solid var(--border);
    color: var(--foreground-text);
    font-size: var(--text-sm);
    line-height: 1.4;
}

.chat-widget-email {
    padding: 0 1rem 0.75rem;
}

.chat-widget-email input {
    font-size: var(--text-xs);
    padding: var(--input-padding-sm, 0.375rem 0.625rem);
}

.chat-widget-email-hint {
    margin-top: 0.375rem;
    font-size: var(--text-xs);
    color: var(--muted-foreground);
}

.chat-widget-form {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid var(--border);
}

.chat-widget-form textarea {
    resize: none;
    max-height: 90px;
    font-family: var(--font-family-base);
}

.chat-widget-send {
    width: var(--square-btn-dimension-md);
    height: var(--square-btn-dimension-md);
    flex-shrink: 0;
    border-radius: var(--radius-full);
}

.chat-widget-send i {
    font-size: 16px;
    line-height: 1;
}

.chat-widget-send:disabled {
    opacity: 0.6;
    cursor: default;
}

@media (max-width: 480px) {
    .chat-widget {
        inset-inline-end: 12px;
        bottom: 12px;
    }

    .chat-widget-panel {
        width: calc(100vw - 24px);
    }
}


/* =========================================================
   Чат: новый вид (неон, как на главной), нормальные отступы на телефоне
   ========================================================= */

.chat-widget {
    inset-inline-end: calc(24px + env(safe-area-inset-right, 0px));
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

/* кнопка-«пузырь» */
.chat-widget .chat-widget-launcher {
    width: 62px;
    height: 62px;

    display: flex;
    align-items: center;
    justify-content: center;

    color: #fff;

    background: linear-gradient(140deg, #4f39f6 0%, #8b5cf6 55%, #ec4899 100%);
    border: 0;
    border-radius: 50%;

    box-shadow: 0 12px 34px rgba(139, 92, 246, .55), 0 0 44px rgba(236, 72, 153, .22);

    outline: none;

    transition: transform .2s ease, box-shadow .2s ease;
}

/* мягкая пульсация вокруг кнопки */
.chat-widget .chat-widget-launcher::before {
    content: "";

    position: absolute;
    inset: 0;

    border-radius: 50%;
    border: 2px solid rgba(139, 92, 246, .7);

    opacity: 0;

    animation: chat-launcher-pulse 3s ease-out infinite;

    pointer-events: none;
}

/* зелёная точка «оператор онлайн» */
.chat-widget .chat-widget-launcher::after {
    content: "";

    position: absolute;
    right: 3px;
    bottom: 3px;

    width: 14px;
    height: 14px;

    background: #22c55e;
    border: 2.5px solid #0a0a0a;
    border-radius: 50%;

    box-shadow: 0 0 12px rgba(34, 197, 94, .8);
}

.chat-widget .chat-widget-launcher:hover {
    transform: translateY(-3px) scale(1.05);

    box-shadow: 0 16px 44px rgba(139, 92, 246, .75), 0 0 60px rgba(236, 72, 153, .35);
}

.chat-widget .chat-widget-launcher:focus,
.chat-widget .chat-widget-launcher:active {
    outline: none !important;
}

.chat-widget .chat-widget-launcher i {
    font-size: 25px;
}

.chat-widget .chat-widget-badge {
    top: -5px;
    inset-inline-end: -5px;
    z-index: 2;

    min-width: 22px;
    height: 22px;

    border: 2px solid #0a0a0a;

    font-size: 12px;
    font-weight: 700;
    line-height: 18px;
}

@keyframes chat-launcher-pulse {
    0% { opacity: .7; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.7); }
}

/* панель чата */
.chat-widget .chat-widget-panel {
    width: 372px;

    background: rgba(14, 14, 24, .94);
    border: 1px solid rgba(139, 92, 246, .4);
    border-radius: 24px;

    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);

    box-shadow: 0 24px 70px rgba(0, 0, 0, .55), 0 0 60px rgba(139, 92, 246, .22);
}

.chat-widget .chat-widget-header {
    padding: 1rem 3rem 1rem 1.1rem;

    background:
        radial-gradient(260px 120px at 0% 0%, rgba(79, 57, 246, .45), transparent 70%),
        radial-gradient(240px 120px at 100% 100%, rgba(236, 72, 153, .3), transparent 70%),
        rgba(255, 255, 255, .03);

    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.chat-widget .chat-widget-header-avatar {
    width: 42px;
    height: 42px;

    background: linear-gradient(140deg, #4f39f6, #8b5cf6 60%, #ec4899);
    border-radius: 14px;

    box-shadow: 0 8px 22px rgba(139, 92, 246, .5);
}

.chat-widget .chat-widget-header-title {
    color: #fff;

    font-size: 15px;
    font-weight: 700;
}

.chat-widget .chat-widget-header-status {
    color: #86efac;
}

.chat-widget .chat-widget-header-status::before {
    background-color: #22c55e;

    box-shadow: 0 0 10px #22c55e;
}

.chat-widget .chat-widget-close {
    top: .75rem;
    inset-inline-end: .75rem;

    background: rgba(255, 255, 255, .06);
}

.chat-widget .chat-widget-close:hover {
    background: rgba(255, 255, 255, .14);
}

.chat-widget .chat-widget-messages {
    min-height: 320px;
    padding: 1.1rem;
}

.chat-widget .chat-widget-message,
.chat-widget .chat-widget-greeting {
    padding: .65rem .9rem;

    border-radius: 18px;

    font-size: 14px;
    line-height: 1.45;
}

.chat-widget .chat-widget-message.is-operator,
.chat-widget .chat-widget-greeting {
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .09);
    border-bottom-left-radius: 6px;
}

.chat-widget .chat-widget-message.is-visitor {
    background: linear-gradient(135deg, #4f39f6, #8b5cf6);
    border-bottom-right-radius: 6px;

    box-shadow: 0 6px 20px rgba(79, 57, 246, .35);
}

.chat-widget .chat-widget-form {
    padding: .85rem;

    border-top: 1px solid rgba(255, 255, 255, .08);
}

.chat-widget .chat-widget-form textarea {
    border-radius: 16px;
}

.chat-widget .chat-widget-send {
    width: 44px;
    height: 44px;

    color: #fff !important;

    background: linear-gradient(140deg, #4f39f6, #8b5cf6 60%, #ec4899) !important;
    border: 0 !important;
    border-radius: 50%;

    box-shadow: 0 6px 20px rgba(139, 92, 246, .5);

    outline: none !important;
}

/* телефон: кнопка не липнет к краю, панель с нормальными полями */
@media (max-width: 767.98px) {
    .chat-widget {
        inset-inline-end: calc(18px + env(safe-area-inset-right, 0px));
        bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    }

    .chat-widget .chat-widget-launcher {
        width: 56px;
        height: 56px;
    }

    .chat-widget .chat-widget-launcher i {
        font-size: 23px;
    }

    .chat-widget .chat-widget-panel {
        width: min(calc(100vw - 36px), 400px);
        max-height: calc(100dvh - 100px);
    }

    .chat-widget .chat-widget-messages {
        min-height: 240px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .chat-widget .chat-widget-launcher::before { animation: none; }
}
