/* Чат с посетителями сайта (inc/sitechat.php, js/sitechat.js). Тёмный люкс-минимализм сайта: фон #0b0c0e,
   медное «золото» #E5BAA2 → #C3917B → #8C5E4C, тонкие линии, Raleway, капс с разрядкой.
   Под меню-шторкой (у .menu-bar z-index 1002), при открытом меню скрыт. */

.ic,
.ic *,
.ic *::before,
.ic *::after {
    box-sizing: border-box;
}

.ic {
    --ic-bg: #0b0c0e;
    --ic-panel: rgba(14, 15, 18, 0.97);
    --ic-raised: #15161a;
    --ic-line: rgba(229, 186, 162, 0.15);
    --ic-line-strong: rgba(229, 186, 162, 0.32);
    --ic-text: #ece8e4;
    --ic-muted: #8a8e98;
    --ic-copper: #C3917B;
    --ic-copper-light: #E5BAA2;
    --ic-grad: linear-gradient(135deg, #E5BAA2 0%, #C3917B 50%, #8C5E4C 100%);
    --ic-font: 'Raleway', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-family: var(--ic-font);
    -webkit-font-smoothing: antialiased;
}

.ic[hidden],
.ic [hidden] {
    display: none !important;
}

body.fixed .ic {
    display: none;
}

/* ---------- Кнопка ---------- */

.ic-launcher {
    position: fixed;
    z-index: 1001;
    right: 28px;
    bottom: 28px;
    display: flex;
    align-items: center;
    gap: 0;
    height: 52px;
    min-width: 52px;
    padding: 0 15px;
    border: 1px solid transparent;
    border-radius: 26px;
    background: linear-gradient(rgba(11, 12, 14, 0.86), rgba(11, 12, 14, 0.86)) padding-box, var(--ic-grad) border-box;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    color: var(--ic-copper-light);
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    opacity: 0.88;
    transition: opacity 0.3s, box-shadow 0.3s, transform 0.2s;
}

.ic-launcher:hover,
.ic-launcher:focus-visible,
.ic.is-open .ic-launcher {
    opacity: 1;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55), 0 0 0 4px rgba(195, 145, 123, 0.08);
}

.ic-launcher:focus-visible {
    outline: none;
}

.ic.is-dragging .ic-launcher {
    cursor: grabbing;
    transform: scale(1.04);
    transition: none;
}

.ic-launcher-icon {
    width: 22px;
    height: 22px;
    flex: none;
}

.ic-launcher-label {
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--ic-copper-light);
    transition: max-width 0.35s ease, margin 0.35s ease;
}

@media (hover: hover) {
    .ic-launcher:hover .ic-launcher-label,
    .ic-launcher:focus-visible .ic-launcher-label,
    .ic.is-hint .ic-launcher-label {
        max-width: 160px;
        margin-left: 10px;
    }
}

/* Мягкое кольцо при первом визите — один раз */
.ic-launcher-ring {
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    pointer-events: none;
}

.ic.is-hint .ic-launcher-ring {
    animation: ic-ring 2.4s ease-out 2;
}

@keyframes ic-ring {
    0% { box-shadow: 0 0 0 0 rgba(229, 186, 162, 0.35); }
    100% { box-shadow: 0 0 0 16px rgba(229, 186, 162, 0); }
}

/* Новый ответ компании */
.ic-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--ic-grad);
    box-shadow: 0 0 0 2px var(--ic-bg);
}

/* Телефон: маленький флажок у правого края, двигается пальцем по вертикали */
.ic.is-flag .ic-launcher {
    right: 0;
    bottom: auto;
    width: 34px;
    min-width: 0;
    height: 60px;
    padding: 0;
    justify-content: center;
    border-right: 0;
    border-radius: 14px 0 0 14px;
    opacity: 0.92;
}

.ic.is-flag .ic-launcher-icon {
    width: 19px;
    height: 19px;
    margin-left: 2px;
}

.ic.is-flag .ic-launcher-label {
    display: none;
}

.ic.is-flag .ic-dot {
    top: 7px;
    right: auto;
    left: 6px;
}

/* ---------- Окно ---------- */

.ic-panel {
    position: fixed;
    z-index: 1001;
    width: 380px;
    height: min(580px, calc(100vh - 110px));
    min-height: 0;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--ic-line-strong);
    border-radius: 18px;
    background: var(--ic-panel);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    color: var(--ic-text);
    animation: ic-in 0.28s ease-out;
}

@keyframes ic-in {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.ic-head {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 18px 16px 20px;
    border-bottom: 1px solid var(--ic-line);
}

.ic-head::after {
    content: '';
    position: absolute;
    left: 20px;
    bottom: -1px;
    width: 40px;
    height: 1px;
    background: var(--ic-grad);
}

.ic-logo {
    width: 30px;
    height: 30px;
    flex: none;
}

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

.ic-title {
    font-size: 15px;
    font-weight: 400;
    letter-spacing: 5px;
    color: #fff;
    line-height: 1.2;
}

.ic-sub {
    margin-top: 4px;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--ic-muted);
}

.ic-close {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--ic-line);
    border-radius: 50%;
    background: transparent;
    color: var(--ic-copper-light);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.ic-close:hover {
    border-color: var(--ic-line-strong);
    background: rgba(229, 186, 162, 0.06);
}

.ic-close svg {
    width: 16px;
    height: 16px;
}

/* ---------- Форма первого сообщения ---------- */

.ic-start {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overscroll-behavior: contain;
}

.ic-lead {
    margin: 0;
    font-size: 14px;
    font-weight: 300;
    line-height: 1.55;
    color: #cfcac6;
}

.ic-row {
    display: flex;
    gap: 14px;
}

.ic-row .ic-field {
    flex: 1;
    min-width: 0;
}

.ic-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
}

.ic-field > span {
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--ic-muted);
}

.ic input[type='text'],
.ic input[type='tel'],
.ic input[type='email'],
.ic textarea {
    width: 100%;
    height: auto;
    margin: 0;
    padding: 8px 0;
    border: 0;
    border-bottom: 1px solid var(--ic-line-strong);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: var(--ic-text);
    font-family: var(--ic-font);
    font-size: 15px;
    font-weight: 400;
    line-height: 1.4;
    outline: none;
    resize: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.ic input::placeholder,
.ic textarea::placeholder {
    color: #5d616a;
}

.ic input:focus,
.ic textarea:focus {
    border-bottom-color: var(--ic-copper-light);
    background: transparent;
    box-shadow: none;
}

.ic-hint {
    margin: -4px 0 0;
    font-size: 12px;
    line-height: 1.45;
    color: var(--ic-muted);
}

.ic-trap {
    position: absolute !important;
    left: -10000px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    opacity: 0 !important;
}

.ic-consent {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 2px 0 0;
    font-size: 12px;
    line-height: 1.5;
    color: #b9b4b0;
    cursor: pointer;
}

.ic-consent input {
    position: absolute;
    opacity: 0;
    width: 18px;
    height: 18px;
    margin: 0;
}

.ic-check {
    flex: none;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    border: 1px solid var(--ic-line-strong);
    border-radius: 4px;
    transition: background 0.2s, border-color 0.2s;
}

.ic-consent input:checked + .ic-check {
    border-color: transparent;
    background: var(--ic-grad);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M4.5 9.5l3 3 6-7' fill='none' stroke='%230b0c0e' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"), var(--ic-grad);
}

.ic-consent input:focus-visible + .ic-check {
    box-shadow: 0 0 0 3px rgba(229, 186, 162, 0.2);
}

.ic-consent a {
    color: var(--ic-copper-light);
    text-decoration: underline;
    text-decoration-color: rgba(229, 186, 162, 0.4);
    text-underline-offset: 2px;
}

.ic-error {
    margin: 0;
    padding: 9px 12px;
    border: 1px solid rgba(214, 112, 96, 0.4);
    border-radius: 10px;
    background: rgba(214, 112, 96, 0.08);
    font-size: 13px;
    line-height: 1.45;
    color: #f0b2a6;
}

.ic-submit {
    height: 48px;
    margin-top: 4px;
    border: 0;
    border-radius: 24px;
    background: var(--ic-grad);
    color: #0b0c0e;
    font-family: var(--ic-font);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    cursor: pointer;
    transition: filter 0.2s, opacity 0.2s;
}

.ic-submit:hover {
    filter: brightness(1.07);
}

.ic-submit:disabled,
.ic-send:disabled {
    opacity: 0.5;
    cursor: default;
}

/* ---------- Переписка ---------- */

.ic-thread {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.ic-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overscroll-behavior: contain;
}

/* Ползунок в стиле сайта: тонкий медный на прозрачной дорожке (Safari не понимает scrollbar-color) */
.ic-messages,
.ic-start {
    scrollbar-width: thin;
    scrollbar-color: rgba(229, 186, 162, 0.35) transparent;
}
.ic-messages::-webkit-scrollbar,
.ic-start::-webkit-scrollbar {
    width: 6px;
    background: transparent;
}
.ic-messages::-webkit-scrollbar-track,
.ic-start::-webkit-scrollbar-track {
    background: transparent;
}
.ic-messages::-webkit-scrollbar-thumb,
.ic-start::-webkit-scrollbar-thumb {
    background: rgba(229, 186, 162, 0.35);
    border-radius: 6px;
}
.ic-messages::-webkit-scrollbar-thumb:hover,
.ic-start::-webkit-scrollbar-thumb:hover {
    background: rgba(229, 186, 162, 0.6);
}

.ic-day {
    align-self: center;
    margin: 8px 0 2px;
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #5d616a;
}

.ic-msg {
    max-width: 84%;
    padding: 9px 13px 7px;
    border: 1px solid var(--ic-line);
    border-radius: 14px;
    background: var(--ic-raised);
    animation: ic-msg 0.25s ease-out;
}

@keyframes ic-msg {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

.ic-msg.is-mine {
    align-self: flex-end;
    border-color: var(--ic-line-strong);
    border-bottom-right-radius: 4px;
    background: rgba(195, 145, 123, 0.16);
}

.ic-msg.is-theirs {
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.ic-author {
    margin-bottom: 3px;
    font-size: 10px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--ic-copper-light);
}

.ic-text {
    font-size: 14px;
    line-height: 1.5;
    color: var(--ic-text);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.ic-text.is-deleted {
    font-style: italic;
    color: var(--ic-muted);
}

.ic-meta {
    margin-top: 3px;
    text-align: right;
    font-size: 10px;
    color: var(--ic-muted);
    letter-spacing: 0.5px;
}

.ic-meta .is-read {
    color: var(--ic-copper-light);
}

.ic-note {
    align-self: center;
    max-width: 90%;
    margin: 6px 0;
    text-align: center;
    font-size: 12px;
    line-height: 1.5;
    color: var(--ic-muted);
}

.ic-composer {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin: 0;
    padding: 10px 14px 10px 18px;
    border-top: 1px solid var(--ic-line);
}

.ic-composer textarea {
    flex: 1;
    max-height: 120px;
    padding: 9px 0;
    border-bottom: 0 !important;
}

.ic-send {
    flex: none;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--ic-grad);
    color: #0b0c0e;
    cursor: pointer;
}

.ic-send svg {
    width: 18px;
    height: 18px;
}

.ic-error-thread {
    margin: 0 14px 8px;
}

.ic-foot {
    display: flex;
    justify-content: center;
    padding: 0 0 10px;
}

.ic-forget {
    padding: 4px 8px;
    border: 0;
    background: none;
    font-family: var(--ic-font);
    font-size: 10px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: #5d616a;
    cursor: pointer;
}

.ic-forget:hover {
    color: var(--ic-muted);
}

/* Телефон: окно — лист снизу во всю ширину, под верхней панелью сайта */
@media (max-width: 640px) {
    .ic-panel {
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        bottom: 0 !important;
        width: 100%;
        height: calc(100% - 64px);
        height: calc(100dvh - 64px);
        border-right: 0;
        border-left: 0;
        border-bottom: 0;
        border-radius: 18px 18px 0 0;
        animation-name: ic-up;
    }

    @keyframes ic-up {
        from { transform: translateY(30px); opacity: 0; }
        to { transform: none; opacity: 1; }
    }

    .ic input[type='text'],
    .ic input[type='tel'],
    .ic input[type='email'],
    .ic textarea {
        font-size: 16px; /* iPhone не увеличивает страницу при вводе */
    }

    .ic-row {
        flex-direction: column;
        gap: 14px;
    }

    .ic-composer {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .ic.is-open .ic-launcher {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ic-panel,
    .ic-msg,
    .ic.is-hint .ic-launcher-ring {
        animation: none;
    }
}
