/* Support chat widget (assets/js/support-chat.js) */
.nx-chat {
    --nx-accent: #ee6129;
    --nx-accent-dark: #d4521d;
    --nx-dark: #393c45;
    --nx-bg: #f4f4f6;
    --nx-border: #dcdde2;
    --nx-text: #1a1a1a;
    --nx-muted: #6b6f7a;
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9000;
    font-family: "RobotoCondensed", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--nx-text);
}

body.calc-modal-open .nx-chat,
body:has(.mobile-menu__wrap.active) .nx-chat {
    display: none;
}

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

/* Launcher */
.nx-chat__launcher {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    margin-left: auto;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--nx-accent);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(238, 97, 41, 0.38);
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.nx-chat__launcher:hover {
    background: var(--nx-accent-dark);
    transform: translateY(-2px);
}

.nx-chat__launcher:focus-visible,
.nx-chat__close:focus-visible,
.nx-chat__send:focus-visible,
.nx-chat__chip:focus-visible {
    outline: 3px solid rgba(238, 97, 41, 0.45);
    outline-offset: 2px;
}

.nx-chat__launcher svg {
    width: 28px;
    height: 28px;
}

.nx-chat__launcher .nx-chat__icon-close {
    display: none;
}

.nx-chat.is-open .nx-chat__launcher .nx-chat__icon-open {
    display: none;
}

.nx-chat.is-open .nx-chat__launcher .nx-chat__icon-close {
    display: block;
}

.nx-chat__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border: 2px solid #fff;
    border-radius: 10px;
    background: var(--nx-dark);
    font-size: 11px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

.nx-chat.is-open .nx-chat__badge,
.nx-chat__badge[hidden] {
    display: none;
}

/* Panel */
.nx-chat__panel {
    position: absolute;
    right: 0;
    bottom: 76px;
    display: flex;
    flex-direction: column;
    width: 370px;
    height: min(580px, calc(100vh - 130px));
    overflow: hidden;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(17, 17, 17, 0.22);
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    transform-origin: bottom right;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
}

.nx-chat.is-open .nx-chat__panel {
    opacity: 1;
    transform: none;
    visibility: visible;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.nx-chat__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    background: var(--nx-dark);
    color: #fff;
}

.nx-chat__avatar {
    display: flex;
    flex: 0 0 40px;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #fff;
}

.nx-chat__avatar img {
    width: 28px;
    height: 28px;
}

.nx-chat__heading {
    flex: 1 1 auto;
    min-width: 0;
}

.nx-chat__title {
    margin: 0;
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}

.nx-chat__status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 2px 0 0;
    color: #c9cbd2;
    font-size: 13px;
    line-height: 1.3;
}

.nx-chat__status::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3ccf6e;
}

.nx-chat__close {
    display: flex;
    flex: 0 0 32px;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.nx-chat__close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages */
.nx-chat__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 10px;
    padding: 18px 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--nx-bg);
}

.nx-chat__msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.4;
    white-space: pre-line;
    overflow-wrap: anywhere;
    animation: nx-chat-in 0.2s ease;
}

.nx-chat__msg--bot {
    align-self: flex-start;
    border: 1px solid var(--nx-border);
    border-bottom-left-radius: 4px;
    background: #fff;
}

.nx-chat__msg--user {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    background: var(--nx-accent);
    color: #fff;
}

.nx-chat__msg a {
    color: var(--nx-accent);
    text-decoration: underline;
}

.nx-chat__typing {
    display: inline-flex;
    gap: 4px;
    align-self: flex-start;
    padding: 12px 14px;
    border: 1px solid var(--nx-border);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    background: #fff;
}

.nx-chat__typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #a5a8b1;
    animation: nx-chat-dot 1.2s infinite ease-in-out;
}

.nx-chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.nx-chat__typing span:nth-child(3) { animation-delay: 0.3s; }

.nx-chat__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.nx-chat__chip {
    padding: 7px 12px;
    border: 1px solid var(--nx-accent);
    border-radius: 999px;
    background: #fff;
    color: var(--nx-accent);
    font: inherit;
    font-size: 14px;
    line-height: 1.2;
    cursor: pointer;
}

.nx-chat__chip:hover {
    background: var(--nx-accent);
    color: #fff;
}

/* Contact form inside the conversation */
.nx-chat__card {
    align-self: stretch;
    padding: 14px;
    border: 1px solid var(--nx-border);
    border-radius: 16px;
    background: #fff;
    animation: nx-chat-in 0.2s ease;
}

.nx-chat .nx-chat__form {
    display: grid;
    gap: 8px;
    margin: 0;
}

.nx-chat .nx-chat__form .nx-chat__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.nx-chat .nx-chat__form input {
    width: 100%;
    height: 44px;
    margin: 0;
    padding: 0 12px;
    border: 1px solid var(--nx-border);
    border-radius: 8px;
    background: #fff;
    color: var(--nx-text);
    font: inherit;
    font-size: 15px;
}

.nx-chat .nx-chat__form input:focus {
    border-color: var(--nx-accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(238, 97, 41, 0.18);
}

.nx-chat .nx-chat__form input[name="phone"] {
    height: 44px !important;
}

.nx-chat .nx-chat__form .iti__flag-container,
.nx-chat .nx-chat__form .iti__selected-flag {
    border-top-left-radius: 8px !important;
    border-bottom-left-radius: 8px !important;
}

.nx-chat .nx-chat__form .iti__country-list {
    max-height: 170px;
    font-size: 14px;
}

.nx-chat .nx-chat__form button[type="submit"] {
    width: 100%;
    height: 46px;
    margin: 4px 0 0;
    padding: 0 16px;
    border: 0;
    border-radius: 8px;
    background: var(--nx-accent);
    box-shadow: none;
    color: #fff;
    font: inherit;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    cursor: pointer;
    transform: none;
}

.nx-chat .nx-chat__form button[type="submit"]:hover:not(:disabled) {
    background: var(--nx-accent-dark);
    box-shadow: none;
    transform: none;
}

.nx-chat .nx-chat__form button[type="submit"]:disabled {
    background: #b8bac1;
}

.nx-chat__consent {
    margin: 2px 0 0;
    color: var(--nx-muted);
    font-size: 12px;
    line-height: 1.35;
}

.nx-chat__consent a {
    color: var(--nx-accent);
}

/* Composer */
.nx-chat__composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--nx-border);
    background: #fff;
}

.nx-chat .nx-chat__input {
    flex: 1 1 auto;
    min-height: 44px;
    max-height: 110px;
    margin: 0;
    padding: 11px 14px;
    resize: none;
    border: 1px solid var(--nx-border);
    border-radius: 22px;
    background: var(--nx-bg);
    color: var(--nx-text);
    font: inherit;
    font-size: 15px;
    line-height: 1.4;
}

.nx-chat .nx-chat__input:focus {
    border-color: var(--nx-accent);
    outline: none;
    background: #fff;
}

.nx-chat__send {
    display: flex;
    flex: 0 0 44px;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--nx-accent);
    color: #fff;
    cursor: pointer;
}

.nx-chat__send:disabled {
    background: #d0d2d8;
    cursor: default;
}

.nx-chat__send svg {
    width: 20px;
    height: 20px;
}

.nx-chat__note {
    margin: 0;
    padding: 0 12px 10px;
    background: #fff;
    color: var(--nx-muted);
    font-size: 11px;
    text-align: center;
}

@keyframes nx-chat-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

@keyframes nx-chat-dot {
    0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

@media (max-width: 600px) {
    .nx-chat {
        right: 16px;
        bottom: 16px;
    }

    .nx-chat__launcher {
        width: 56px;
        height: 56px;
    }

    .nx-chat.is-open {
        inset: 0;
    }

    .nx-chat.is-open .nx-chat__launcher {
        display: none;
    }

    .nx-chat__panel {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .nx-chat .nx-chat__form .nx-chat__row {
        grid-template-columns: 1fr;
    }

    .nx-chat .nx-chat__form input,
    .nx-chat .nx-chat__input {
        font-size: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .nx-chat__panel,
    .nx-chat__msg,
    .nx-chat__card,
    .nx-chat__typing span {
        animation: none;
        transition: none;
    }
}
