/* Supptrue chat widget — изолированные стили */

#sw-widget,
#sw-widget * {
    box-sizing: border-box;
}

#sw-widget {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #1f2937;
}

/* Круглая кнопка-launcher */
#sw-widget .sw-launcher {
    width: 128px;
    height: 128px;
    border-radius: 50%;
    background: #009640;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 5px solid #fff;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    overflow: hidden;
    position: relative;
}
@media (max-width: 600px) {
    #sw-widget .sw-launcher {
        width: 96px;
        height: 96px;
        border-width: 4px;
    }
}
#sw-widget .sw-launcher:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}
#sw-widget .sw-launcher img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Красная точка непрочитанного */
#sw-widget .sw-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: #ef4444;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    min-width: 28px;
    height: 28px;
    border-radius: 14px;
    padding: 0 8px;
    display: none;
    align-items: center;
    justify-content: center;
    border: 3px solid #fff;
}
#sw-widget .sw-badge.sw-visible {
    display: flex;
}

/* Окно чата */
#sw-widget .sw-window {
    position: absolute;
    bottom: 145px;
    right: 0;
    width: 360px;
    height: 540px;
    max-height: calc(100vh - 175px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
    display: none;
    flex-direction: column;
    overflow: hidden;
}
#sw-widget.sw-open .sw-window {
    display: flex;
}

/* Шапка окна */
#sw-widget .sw-header {
    background: #009640;
    color: #fff;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
#sw-widget .sw-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #fff;
    overflow: hidden;
    flex-shrink: 0;
}
#sw-widget .sw-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
#sw-widget .sw-header-info { flex: 1; min-width: 0; }
#sw-widget .sw-header-name { font-weight: 600; font-size: 14px; line-height: 1.1; }
#sw-widget .sw-header-sub { font-size: 11px; opacity: 0.85; margin-top: 2px; }
#sw-widget .sw-header-close {
    background: rgba(255,255,255,0.18);
    color: #fff;
    border: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
#sw-widget .sw-header-close:hover { background: rgba(255,255,255,0.28); }

/* Лента сообщений */
#sw-widget .sw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
#sw-widget .sw-msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}
#sw-widget .sw-msg.sw-from-customer {
    align-self: flex-end;
    background: #009640;
    color: #fff;
    border-bottom-right-radius: 2px;
}
#sw-widget .sw-msg.sw-from-bot {
    align-self: flex-start;
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 2px;
}
#sw-widget .sw-msg.sw-from-operator {
    align-self: flex-start;
    background: #dbeafe;
    color: #1e3a8a;
    border-bottom-left-radius: 2px;
}
#sw-widget .sw-msg-bot-label {
    font-size: 10px;
    color: #9ca3af;
    margin-bottom: 3px;
}
#sw-widget .sw-msg-op-label {
    font-size: 10px;
    color: #1e40af;
    margin-bottom: 3px;
    font-weight: 600;
}
#sw-widget .sw-msg img {
    max-width: 100%;
    margin-top: 6px;
    border-radius: 6px;
    display: block;
}

/* Кнопки выбора (на лбу у сообщения бота) */
#sw-widget .sw-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-self: flex-start;
    max-width: 100%;
    margin-top: -2px;
}
#sw-widget .sw-btn {
    background: #fff;
    border: 1.5px solid #009640;
    color: #009640;
    padding: 7px 12px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
#sw-widget .sw-btn:hover {
    background: #009640;
    color: #fff;
}
#sw-widget .sw-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Поле ввода */
#sw-widget .sw-input-area {
    border-top: 1px solid #e5e7eb;
    background: #fff;
    padding: 10px;
    display: flex;
    gap: 6px;
    align-items: flex-end;
}
#sw-widget .sw-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    padding: 8px 14px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    resize: none;
    line-height: 1.4;
    max-height: 80px;
}
#sw-widget .sw-input:focus { border-color: #009640; }
#sw-widget .sw-input-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}
#sw-widget .sw-icon-btn {
    background: transparent;
    border: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #009640;
    font-size: 20px;
}
#sw-widget .sw-icon-btn:hover { background: #ecfdf5; }
#sw-widget .sw-icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

#sw-widget .sw-consent {
    font-size: 11px;
    color: #6b7280;
    padding: 6px 10px;
    background: #f9fafb;
    text-align: center;
    border-top: 1px solid #f3f4f6;
}
#sw-widget .sw-consent a { color: #009640; }

/* Состояние "печатает" */
#sw-widget .sw-typing {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 14px;
    color: #9ca3af;
    font-size: 14px;
    display: none;
}
#sw-widget .sw-typing.sw-visible { display: block; }
#sw-widget .sw-typing::after {
    content: '...';
    animation: sw-blink 1.2s infinite;
}
@keyframes sw-blink {
    0%, 60%, 100% { opacity: 0.3; }
    30% { opacity: 1; }
}

/* Адаптив — мобильный во весь экран */
@media (max-width: 600px) {
    #sw-widget .sw-window {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    #sw-widget.sw-open .sw-launcher {
        display: none;
    }
}

/* Hidden file input */
#sw-widget .sw-file-input { display: none; }

/* Блок промокодов с кнопкой копирования */
#sw-widget .sw-promo-codes {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
#sw-widget .sw-promo-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1.5px dashed #009640;
    border-radius: 8px;
    padding: 8px 10px;
}
#sw-widget .sw-promo-label {
    font-size: 11px;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
#sw-widget .sw-promo-value {
    flex: 1;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-weight: 700;
    font-size: 15px;
    color: #009640;
    user-select: all;
    word-break: break-all;
}
#sw-widget .sw-promo-copy {
    background: #009640;
    color: #fff;
    border: 0;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease;
}
#sw-widget .sw-promo-copy:hover { background: #047857; }
#sw-widget .sw-promo-copy.sw-promo-copied { background: #16a34a; }
#sw-widget .sw-promo-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
#sw-widget .sw-promo-link {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #009640;
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    transition: background 0.15s ease;
}
#sw-widget .sw-promo-link:hover { background: #047857; }

/* Скрытое сообщение об ошибке */
#sw-widget .sw-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    margin: 8px 12px 0;
    display: none;
}
#sw-widget .sw-error.sw-visible { display: block; }
