/* Чат на лендинге: пульсирующий значок и панель переписки */

.svc-fab,
.svc-panel {
    --svc-navy: #111a26;
    --svc-navy-2: #17222f;
    --svc-yellow: #ffc11e;
    --svc-yellow-2: #e6a90a;
    --svc-ink: #10161e;
    --svc-muted: #5b6673;
    --svc-paper: #f5f6f8;
    --svc-line: #e3e7ec;

    font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.svc-fab *,
.svc-panel * {
    box-sizing: border-box;
}

/* ---------- значок ---------- */

.svc-fab {
    position: fixed;
    right: max(20px, env(safe-area-inset-right, 0px));
    bottom: max(20px, env(safe-area-inset-bottom, 0px));
    z-index: 1040;

    width: 62px;
    height: 62px;

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

    border: none;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--svc-yellow), var(--svc-yellow-2));
    color: var(--svc-navy);
    cursor: pointer;

    box-shadow:
        0 10px 28px rgba(17, 26, 38, 0.35),
        0 2px 6px rgba(17, 26, 38, 0.2);

    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.svc-fab:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow:
        0 14px 34px rgba(17, 26, 38, 0.42),
        0 3px 8px rgba(17, 26, 38, 0.24);
}

.svc-fab:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
    box-shadow: 0 0 0 6px var(--svc-navy);
}

.svc-fab::before,
.svc-fab::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--svc-yellow);
    opacity: 0;
    pointer-events: none;
    animation: svcPulse 2.6s ease-out infinite;
}

.svc-fab::after {
    animation-delay: 1.3s;
}

.svc-fab.svc-open::before,
.svc-fab.svc-open::after {
    animation: none;
}

@keyframes svcPulse {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }

    80%,
    100% {
        transform: scale(1.75);
        opacity: 0;
    }
}

.svc-fab-icon {
    position: relative;
    width: 30px;
    height: 30px;
    transition: transform 0.25s ease, opacity 0.2s ease;
}

.svc-fab-icon svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transition: transform 0.25s ease, opacity 0.2s ease;
}

.svc-fab-icon .svc-ico-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.6);
}

.svc-fab.svc-open .svc-ico-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.6);
}

.svc-fab.svc-open .svc-ico-close {
    opacity: 1;
    transform: none;
}

.svc-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;

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

    border: 2px solid #ffffff;
    border-radius: 11px;
    background: #e11d2e;
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
}

.svc-badge.svc-visible {
    display: inline-flex;
}

/* ---------- панель ---------- */

.svc-panel {
    position: fixed;
    right: max(20px, env(safe-area-inset-right, 0px));
    bottom: calc(max(20px, env(safe-area-inset-bottom, 0px)) + 76px);
    z-index: 1040;

    width: 380px;
    height: min(600px, calc(100vh - 120px));

    display: none;
    flex-direction: column;

    overflow: hidden;
    border-radius: 18px;
    background: #ffffff;
    color: var(--svc-ink);

    box-shadow:
        0 24px 64px rgba(17, 26, 38, 0.38),
        0 4px 14px rgba(17, 26, 38, 0.2);

    transform-origin: bottom right;
}

.svc-panel.svc-open {
    display: flex;
    animation: svcAppear 0.22s ease-out;
}

@keyframes svcAppear {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.svc-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;

    background: linear-gradient(160deg, var(--svc-navy-2), var(--svc-navy));
    border-bottom: 3px solid var(--svc-yellow);
    color: #ffffff;
}

.svc-head-logo {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;

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

    border-radius: 50%;
    background: var(--svc-yellow);
    color: var(--svc-navy);
    font-size: 15px;
    font-weight: 800;
}

.svc-head-text {
    flex: 1;
    min-width: 0;
}

.svc-head-text b {
    display: block;
    font-size: 15px;
}

.svc-head-text small {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #b7c6d6;
    font-size: 12px;
}

.svc-head-text small::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3ddc84;
}

.svc-head-close {
    width: 32px;
    height: 32px;

    border: none;
    border-radius: 8px;
    background: transparent;
    color: #b7c6d6;
    font-size: 18px;
    cursor: pointer;
}

.svc-head-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.svc-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 14px;
    background: var(--svc-paper);
}

.svc-msg {
    display: flex;
    margin-bottom: 8px;
}

.svc-msg.svc-me {
    justify-content: flex-end;
}

.svc-bubble {
    max-width: 82%;
    padding: 9px 12px 6px;

    border-radius: 16px 16px 16px 4px;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(17, 26, 38, 0.1);
    font-size: 14px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.svc-me .svc-bubble {
    border-radius: 16px 16px 4px 16px;
    background: var(--svc-yellow);
    color: var(--svc-navy);
}

.svc-bubble a {
    color: inherit;
    text-decoration: underline;
}

.svc-text {
    white-space: pre-wrap;
}

.svc-time {
    display: block;
    margin-top: 2px;
    color: var(--svc-muted);
    font-size: 10px;
    text-align: right;
}

.svc-me .svc-time {
    color: rgba(17, 26, 38, 0.6);
}

.svc-day {
    margin: 10px 0;
    color: var(--svc-muted);
    font-size: 11px;
    font-weight: 600;
    text-align: center;
}

.svc-att-img {
    display: block;
    margin-bottom: 4px;
}

.svc-att-img img {
    display: block;
    max-width: 100%;
    max-height: 200px;
    border-radius: 10px;
}

.svc-att-file {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    padding: 8px 10px;

    border-radius: 10px;
    background: rgba(17, 26, 38, 0.07);
    color: inherit;
    font-size: 13px;
    text-decoration: none !important;
}

.svc-att-file small {
    display: block;
    opacity: 0.7;
}

/* ---------- карточка с контактами ---------- */

.svc-card {
    margin-bottom: 12px;
    padding: 14px;

    border: 1px solid var(--svc-line);
    border-radius: 14px;
    background: #ffffff;
}

.svc-card b {
    display: block;
    margin-bottom: 2px;
    font-size: 14px;
}

.svc-card p {
    margin: 0 0 10px;
    color: var(--svc-muted);
    font-size: 12px;
    line-height: 1.4;
}

.svc-card input[type='text'],
.svc-card input[type='tel'] {
    width: 100%;
    height: 40px;
    margin-bottom: 8px;
    padding: 0 12px;

    border: 1px solid var(--svc-line);
    border-radius: 10px;
    background: var(--svc-paper);
    color: var(--svc-ink);
    font: inherit;
    font-size: 14px;
    outline: none;
}

.svc-card input:focus {
    border-color: var(--svc-yellow-2);
    background: #ffffff;
}

.svc-card-actions {
    display: flex;
    gap: 8px;
}

.svc-btn {
    flex: 1;
    height: 38px;

    border: none;
    border-radius: 10px;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.svc-btn-primary {
    background: var(--svc-navy);
    color: #ffffff;
}

.svc-btn-ghost {
    background: var(--svc-paper);
    color: var(--svc-muted);
}

.svc-hp {
    position: absolute !important;
    left: -9999px !important;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.svc-error {
    margin: 0 0 8px;
    color: #c0182a;
    font-size: 12px;
}

/* ---------- ввод ---------- */

.svc-foot {
    padding: 10px 12px 12px;
    border-top: 1px solid var(--svc-line);
    background: #ffffff;
}

.svc-files {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.svc-files[hidden] {
    display: none;
}

.svc-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 4px 8px;

    border-radius: 9px;
    background: var(--svc-paper);
    font-size: 12px;
}

.svc-chip span {
    overflow: hidden;
    max-width: 150px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.svc-chip button {
    border: none;
    background: transparent;
    color: var(--svc-muted);
    cursor: pointer;
}

.svc-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.svc-icon {
    width: 36px;
    height: 38px;
    flex: 0 0 auto;

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

    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--svc-muted);
    font-size: 19px;
    cursor: pointer;
}

.svc-icon:hover {
    background: var(--svc-paper);
    color: var(--svc-navy);
}

.svc-input {
    flex: 1;
    min-height: 38px;
    max-height: 120px;
    padding: 9px 12px;

    border: 1px solid var(--svc-line);
    border-radius: 12px;
    background: var(--svc-paper);
    color: var(--svc-ink);
    font: inherit;
    font-size: 14px;
    line-height: 1.35;
    resize: none;
    outline: none;
}

.svc-input:focus {
    border-color: var(--svc-yellow-2);
    background: #ffffff;
}

.svc-send {
    width: 40px;
    height: 38px;
    flex: 0 0 auto;

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

    border: none;
    border-radius: 12px;
    background: var(--svc-yellow);
    color: var(--svc-navy);
    cursor: pointer;
}

.svc-send:hover {
    background: var(--svc-yellow-2);
}

.svc-send:disabled {
    opacity: 0.55;
    cursor: default;
}

.svc-send svg {
    width: 20px;
    height: 20px;
}

/* ---------- смайлики ---------- */

.svc-emoji {
    position: absolute;
    left: 10px;
    bottom: 64px;
    z-index: 3;

    width: 290px;

    border: 1px solid var(--svc-line);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 14px 36px rgba(17, 26, 38, 0.24);
}

.svc-emoji[hidden] {
    display: none;
}

.svc-emoji-tabs {
    display: flex;
    padding: 6px;
    border-bottom: 1px solid var(--svc-line);
}

.svc-emoji-tabs button {
    flex: 1;
    padding: 4px 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-size: 18px;
    cursor: pointer;
}

.svc-emoji-tabs button.svc-active {
    background: #fff4d1;
}

.svc-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    max-height: 180px;
    padding: 8px;
    overflow-y: auto;
}

.svc-emoji-grid button {
    padding: 4px 0;
    border: none;
    border-radius: 7px;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
}

.svc-emoji-grid button:hover {
    background: var(--svc-paper);
}

/* ---------- мобильные ---------- */

@media (max-width: 640px) {
    .svc-fab {
        /* выше закреплённой нижней панели лендинга */
        bottom: calc(86px + env(safe-area-inset-bottom, 0px));
        right: 16px;
        width: 56px;
        height: 56px;
    }

    .svc-panel {
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        border-radius: 0;
    }

    .svc-fab.svc-open {
        display: none;
    }

    .svc-head {
        padding-top: calc(16px + env(safe-area-inset-top, 0px));
    }

    .svc-foot {
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .svc-input {
        font-size: 16px; /* без автозума на iOS */
    }
}

@media (prefers-reduced-motion: reduce) {

    .svc-fab::before,
    .svc-fab::after {
        animation: none;
    }

    .svc-panel.svc-open {
        animation: none;
    }
}

/* ---------- «Оператор печатает» и плашка «чат закрыт» ---------- */

.svc-typing {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 4px 16px 6px;
    background: var(--svc-paper);
    color: #6b7785;
    font-size: 12px;
}

.svc-typing[hidden] {
    display: none;
}

.svc-typing i {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    animation: svcTypingDot 1.2s infinite ease-in-out;
}

.svc-typing i:nth-of-type(1) {
    margin-left: 3px;
}

.svc-typing i:nth-of-type(2) {
    animation-delay: 0.15s;
}

.svc-typing i:nth-of-type(3) {
    animation-delay: 0.3s;
}

@keyframes svcTypingDot {
    0%,
    60%,
    100% {
        opacity: 0.25;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

.svc-closed {
    margin: 14px auto 4px;
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 12px;
    background: #eef1f5;
    color: #4a5866;
    font-size: 13px;
    line-height: 1.4;
    text-align: center;
}

/* Файл удалён по сроку хранения */
.svc-att-gone {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 4px;
    padding: 8px 10px;

    border: 1px dashed rgba(15, 24, 34, 0.25);
    border-radius: 9px;
    color: #6b7785;
    font-size: 13px;
}

.svc-att-gone small {
    display: block;
    font-size: 11px;
}
