/* ========================================================
   NexChange — встроенный чат «визитор ↔ админ»
   Style: Crypto.com support, accent — фирменный фиолетовый
   ======================================================== */

.nx-chat-launcher {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 9999;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #667eea;
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.45);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nx-chat-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(102, 126, 234, 0.55);
    background: #7a8fef;
}
.nx-chat-launcher svg {
    width: 26px;
    height: 26px;
    stroke: #fff;
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.nx-chat-launcher .nx-chat-online-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 14px;
    height: 14px;
    background: #22c55e;
    border: 2px solid #0b0f1c;
    border-radius: 50%;
}
.nx-chat-launcher .nx-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    border-radius: 12px;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
    padding: 0 6px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    display: none;
}
.nx-chat-launcher.has-unread .nx-chat-badge { display: block; }
.nx-chat-launcher.has-unread .nx-chat-online-dot { display: none; }

.nx-chat-window {
    position: fixed;
    right: 22px;
    bottom: 92px;
    z-index: 9999;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 540px;
    max-height: calc(100vh - 120px);
    background: #1a1d29;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    color: #e8e8ec;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.nx-chat-window.open { display: flex; }

/* ---------- HEADER ---------- */
.nx-chat-header {
    background: #1a1d29;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}
.nx-chat-header__avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #667eea;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    position: relative;
}
.nx-chat-header__avatar::after {
    content: '';
    position: absolute;
    bottom: -1px; right: -1px;
    width: 12px; height: 12px;
    background: #22c55e;
    border: 2px solid #1a1d29;
    border-radius: 50%;
}
.nx-chat-header__info { flex: 1; min-width: 0; }
.nx-chat-header__title { font-weight: 600; font-size: 14px; color: #fff; line-height: 1.2; }
.nx-chat-header__sub {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.nx-chat-header__sub::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    flex-shrink: 0;
}
.nx-chat-header__close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.55);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.nx-chat-header__close:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nx-chat-header__close svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- BODY (messages) ---------- */
.nx-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #1a1d29;
}
.nx-chat-body::-webkit-scrollbar { width: 4px; }
.nx-chat-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 4px; }

.nx-msg {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
    max-width: 85%;
    align-items: flex-end;
}
.nx-msg__bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.42;
    word-wrap: break-word;
}
.nx-msg__time {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 3px;
    padding: 0 4px;
}
.nx-msg__avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #667eea;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: 18px;
}

.nx-msg.admin {
    align-self: flex-start;
    flex-direction: row;
}
.nx-msg.admin .nx-msg__bubble {
    background: #2a2e40;
    color: #fff;
    border-bottom-left-radius: 4px;
}

.nx-msg.visitor {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.nx-msg.visitor .nx-msg__avatar { display: none; }
.nx-msg.visitor .nx-msg__bubble {
    background: #667eea;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.nx-msg.visitor .nx-msg__time { text-align: right; }

.nx-msg.system {
    align-self: center;
    color: rgba(255, 255, 255, 0.45);
    font-size: 11.5px;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 12px;
    border-radius: 12px;
    margin: 6px 0;
    text-align: center;
}

/* ---------- INPUT ---------- */
.nx-chat-input-wrap {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 12px 14px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: #1a1d29;
    flex-shrink: 0;
}
.nx-chat-input-wrap textarea {
    flex: 1;
    background: #2a2e40;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 12px;
    color: #fff;
    font-family: inherit;
    font-size: 13.5px;
    resize: none;
    min-height: 40px;
    max-height: 110px;
    outline: none;
    transition: border-color 0.15s;
}
.nx-chat-input-wrap textarea::placeholder { color: rgba(255, 255, 255, 0.35); }
.nx-chat-input-wrap textarea:focus { border-color: #667eea; }
.nx-chat-input-wrap button {
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 10px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}
.nx-chat-input-wrap button:hover { background: #7a8fef; }
.nx-chat-input-wrap button:disabled { opacity: 0.5; cursor: not-allowed; }
.nx-chat-input-wrap button svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- INIT FORM ---------- */
.nx-chat-init {
    flex: 1;
    overflow-y: auto;
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: #1a1d29;
}
.nx-chat-init .nx-chat-lead {
    background: rgba(102, 126, 234, 0.12);
    border: 1px solid rgba(102, 126, 234, 0.25);
    border-radius: 12px;
    padding: 14px;
    font-size: 13px;
    line-height: 1.5;
    color: #fff;
    margin: 0;
}
.nx-chat-init .nx-chat-lead b { color: #a78bfa; font-weight: 600; }
.nx-chat-init label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: -8px;
}
.nx-chat-init input {
    background: #2a2e40;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 12px 14px;
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}
.nx-chat-init input::placeholder { color: rgba(255, 255, 255, 0.3); }
.nx-chat-init input:focus { border-color: #667eea; }
.nx-chat-init button {
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 13px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    margin-top: 6px;
    transition: background 0.15s;
}
.nx-chat-init button:hover { background: #7a8fef; }
.nx-chat-init .nx-chat-error { color: #f87171; font-size: 12px; }

/* ---------- MOBILE ---------- */
@media (max-width: 480px) {
    .nx-chat-window {
        right: 8px;
        left: 8px;
        bottom: 80px;
        width: auto;
        max-width: none;
        height: 70vh;
    }
    .nx-chat-launcher { right: 14px; bottom: 14px; }
}
.chat-widget-toggle, [class*="chat-btn"], [class*="chat-toggle"] { width: auto !important; min-width: 180px !important; padding-left: 20px !important; padding-right: 20px !important; display: inline-flex !important; align-items: center !important; justify-content: center !important; }
#chat-widget-container button, #chat-widget-container a, .chat-box button, [id*="chat"] button, [class*="chat"] button { width: auto !important; min-width: 190px !important; padding: 10px 25px !important; display: inline-flex !important; align-items: center !important; justify-content: center !important; word-break: keep-all !important; white-space: nowrap !important; }
.support__btn { width: auto !important; min-width: max-content !important; padding-left: 25px !important; padding-right: 25px !important; display: inline-flex !important; align-items: center !important; justify-content: center !important; white-space: nowrap !important; }

.nx-chat-header__close, button.nx-chat-header__close { width: 28px !important; height: 28px !important; min-width: 28px !important; max-width: 28px !important; display: flex !important; padding: 0 !important; flex-shrink: 0 !important; }

@media (max-width: 768px) {
    .exchange__block_small div[style*="display: flex"] {
        display: block !important;
        white-space: normal !important;
    }
    .exchange__block_small div[style*="display: flex"] small {
        display: block !important;
        white-space: normal !important;
        word-break: break-word !important;
        width: 100% !important;
    }
}

@media (max-width: 576px) {
    footer .footer__body, footer [class*="footer__body"] {
        flex-direction: column !important;
        gap: 10px !important;
        text-align: center !important;
        align-items: center !important;
        justify-content: center !important;
    }
}

@media (max-width: 480px) {
    .footer__logo, [class*="footer__logo"] {
        font-size: 1.2rem !important;
        display: block !important;
        width: 100% !important;
        text-align: center !important;
        overflow: visible !important;
    }
}


/* ===== ФИКС: кнопка отправки и поле ввода в виджете чата =====
   Широкие правила выше ([class*="chat"] button { min-width:190px }) задумывались
   для плавающей кнопки запуска, но ошибочно раздували кнопку «отправить» и
   сжимали поле ввода. Возвращаем компактную круглую кнопку и широкое поле. */
.nx-chat-input-wrap textarea,
#chat-widget-container .nx-chat-input-wrap textarea {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    min-height: 44px !important;
    padding: 11px 14px !important;
}
.nx-chat-input-wrap button,
.nx-chat-input-wrap .nx-chat-send,
#chat-widget-container .nx-chat-input-wrap button,
[class*="chat"] .nx-chat-input-wrap button {
    width: 46px !important;
    min-width: 46px !important;
    max-width: 46px !important;
    height: 46px !important;
    padding: 0 !important;
    flex: 0 0 46px !important;
    border-radius: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.nx-chat-input-wrap {
    gap: 10px !important;
    align-items: flex-end !important;
}

/* === Добавка для вложений в чат-виджете (визитор) === */
.nx-chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.nx-chat-attach-btn {
    background: rgba(0,0,0,.04);
    border: 1px solid rgba(0,0,0,.08);
    color: rgba(0,0,0,.6);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.nx-chat-attach-btn:hover { background: rgba(0,0,0,.08); }
.nx-chat-attach-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nx-msg__image {
    max-width: 220px;
    max-height: 220px;
    border-radius: 12px;
    display: block;
    cursor: pointer;
}

.nx-msg__file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(0,0,0,.05);
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    max-width: 220px;
}
.nx-msg__file-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    flex-shrink: 0;
}
.nx-msg__file-info { display: flex; flex-direction: column; min-width: 0; }
.nx-msg__file-name {
    font-size: 12px;
    font-weight: 600;
    word-break: break-all;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nx-msg__file-size { font-size: 10px; opacity: .6; }
