/* Chat widget — BuySell */
.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: inherit;
}

.chat-widget__toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #007963;
    box-shadow: 0 6px 20px rgba(0, 121, 99, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.chat-widget__toggle:hover {
    transform: scale(1.06);
    box-shadow: 0 8px 24px rgba(0, 121, 99, 0.45);
}

.chat-widget__toggle svg {
    width: 26px;
    height: 26px;
    fill: #fff;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.chat-widget__toggle .chat-widget__icon-close {
    position: absolute;
    opacity: 0;
    transform: scale(0.5) rotate(-45deg);
}

.chat-widget._open .chat-widget__toggle .chat-widget__icon-open {
    opacity: 0;
    transform: scale(0.5) rotate(45deg);
}

.chat-widget._open .chat-widget__toggle .chat-widget__icon-close {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.chat-widget__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #e8483c;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

.chat-widget__badge:empty,
.chat-widget__badge[data-count="0"] {
    display: none;
}

.chat-widget__window {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(7, 11, 18, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform-origin: bottom right;
}

.chat-widget._open .chat-widget__window {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.chat-widget__header {
    background: #007963;
    color: #fff;
    padding: 16px 18px;
    flex-shrink: 0;
}

.chat-widget__header-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
}

.chat-widget__header-status {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-widget__status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
    flex-shrink: 0;
}

.chat-widget__body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 6px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7f7f7;
}

.chat-widget__body::-webkit-scrollbar {
    width: 6px;
}

.chat-widget__body::-webkit-scrollbar-thumb {
    background: #dfdfdf;
    border-radius: 3px;
}

.chat-widget__msg {
    max-width: 82%;
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    animation: chatMsgIn 0.18s ease;
}

@keyframes chatMsgIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-widget__msg--visitor {
    align-self: flex-end;
    background: #007963;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-widget__msg--operator {
    align-self: flex-start;
    background: #fff;
    color: #070b12;
    border: 1px solid #e2e2e2;
    border-bottom-left-radius: 4px;
}

.chat-widget__msg--system {
    align-self: center;
    background: #f0f0f0;
    color: #7d888b;
    font-size: 12px;
    border-radius: 10px;
}

.chat-widget__msg-time {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 3px;
}

.chat-widget__empty {
    margin: auto;
    text-align: center;
    color: #7d888b;
    font-size: 13px;
    padding: 20px;
}

.chat-widget__typing {
    align-self: flex-start;
    display: none;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e2e2e2;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.chat-widget__typing.is-visible {
    display: flex;
}

.chat-widget__typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #a0a8aa;
    animation: chatTypingBlink 1.2s infinite ease-in-out;
}

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

@keyframes chatTypingBlink {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-2px); }
}

.chat-widget__form {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e2e2e2;
    background: #fff;
}

.chat-widget__input {
    flex: 1;
    resize: none !important;
    -moz-appearance: none;
    -webkit-appearance: none;
    appearance: none;
    overflow-x: hidden;
    overflow-y: auto;
    border: 1px solid #dfdfdf;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    max-height: 90px;
    min-height: 40px;
    outline: none;
    transition: border-color 0.15s ease;
}

.chat-widget__input::-webkit-resizer {
    display: none;
}

.chat-widget__input:focus {
    border-color: #007963;
}

.chat-widget__send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #007963;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, transform 0.1s ease;
}

.chat-widget__send:hover {
    background: #008c52;
}

.chat-widget__send:active {
    transform: scale(0.94);
}

.chat-widget__send:disabled {
    background: #cddbd7;
    cursor: default;
}

.chat-widget__send svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

.chat-widget__precheck {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    justify-content: center;
}

.chat-widget__precheck-title {
    font-size: 15px;
    font-weight: 600;
    color: #070b12;
    margin-bottom: 4px;
}

.chat-widget__precheck input {
    border: 1px solid #dfdfdf;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
}

.chat-widget__precheck input:focus {
    border-color: #007963;
}

.chat-widget__precheck-btn {
    background: #007963;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 11px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
    transition: background 0.15s ease;
}

.chat-widget__precheck-btn:hover {
    background: #008c52;
}

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

    .chat-widget__window {
        width: calc(100vw - 20px);
        height: min(65vh, 480px);
        max-height: 65vh;
        bottom: 64px;
        right: -6px;
        border-radius: 14px;
    }

    .chat-widget__toggle {
        width: 50px;
        height: 50px;
    }

    .chat-widget__header {
        padding: 12px 14px;
    }

    .chat-widget__body {
        padding: 10px 10px 4px;
    }
}

@media (max-width: 360px) {
    .chat-widget__window {
        height: min(58vh, 420px);
        max-height: 58vh;
    }
}
