/* ── Support Chat Widget ─────────────────────────────────────────────────── */

#uiux-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
}

/* Кнопка открытия */
#uiux-toggle {
    position: relative;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d6efd, #0a9396);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(13, 110, 253, 0.4);
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}
#uiux-toggle:hover  { transform: scale(1.1); box-shadow: 0 6px 20px rgba(13,110,253,.5); }
#uiux-toggle.active { background: linear-gradient(135deg, #0a9396, #0d6efd); }

/* Бейдж непрочитанных на кнопке */
#uiux-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: #dc3545;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    pointer-events: none;
}

/* Панель */
#uiux-panel {
    position: absolute;
    bottom: 64px;
    right: 0;
    width: 400px;
    max-height: 560px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Шапка */
#uiux-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #0d6efd, #0a9396);
    color: #fff;
    font-weight: 600;
    font-size: 15px;
}
#uiux-title { flex: 1; }

#uiux-new-ticket {
    background: rgba(255,255,255,.2);
    border: 1px solid rgba(255,255,255,.4);
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    line-height: 1;
    transition: background 0.15s;
}
#uiux-new-ticket:hover { background: rgba(255,255,255,.35); }

#uiux-close {
    background: none;
    border: none;
    color: #fff;
    opacity: .8;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
}
#uiux-close:hover { opacity: 1; }

/* Переключатель тикетов */
#uiux-tickets {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 12px;
    background: #f0f4ff;
    border-bottom: 1px solid #dde3f0;
}
.uiux-ticket-tab {
    background: #fff;
    border: 1px solid #c5cfe8;
    border-radius: 20px;
    color: #3a4a6b;
    cursor: pointer;
    font-size: 11px;
    padding: 3px 10px;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.uiux-ticket-tab:hover  { background: #e8eeff; border-color: #0d6efd; }
.uiux-ticket-tab.active {
    background: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
    font-weight: 600;
}
.uiux-ticket-tab.has-unread { border-color: #dc3545; }
.uiux-tab-badge {
    display: inline-block;
    margin-left: 4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: #dc3545;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    vertical-align: middle;
}
.uiux-ticket-tab.active .uiux-tab-badge { background: rgba(255,255,255,.85); color: #dc3545; }

/* Сообщения */
#uiux-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 180px;
    max-height: 360px;
}

.uiux-msg {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.uiux-msg-icon {
    flex-shrink: 0;
    font-size: 16px;
    margin-top: 4px;
}
.uiux-msg-bubble {
    display: flex;
    flex-direction: column;
    max-width: 300px;
}
.uiux-msg-body {
    padding: 9px 12px;
    border-radius: 12px;
    line-height: 1.5;
    word-break: break-word;
}
.uiux-msg-meta {
    font-size: 10px;
    color: #8a94a8;
    margin-top: 3px;
    padding: 0 4px;
}

/* Пользователь */
.uiux-msg-user {
    flex-direction: row-reverse;
}
.uiux-msg-user .uiux-msg-bubble { align-items: flex-end; }
.uiux-msg-user .uiux-msg-icon { color: #0d6efd; }
.uiux-msg-user .uiux-msg-body {
    background: #0d6efd;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.uiux-msg-user .uiux-msg-meta { text-align: right; }

/* Техподдержка */
.uiux-msg-bot .uiux-msg-icon { color: #0a9396; }
.uiux-msg-bot .uiux-msg-body {
    background: #e8f8f8;
    color: #1a1a2e;
    border-bottom-left-radius: 4px;
}

/* Ошибка */
.uiux-msg-error .uiux-msg-icon { color: #dc3545; }
.uiux-msg-error .uiux-msg-body {
    background: #fff0f0;
    color: #dc3545;
    border: 1px solid #ffd0d0;
    border-radius: 12px;
}

/* Анимация загрузки */
.uiux-dots span {
    display: inline-block;
    animation: uiux-bounce 1.2s infinite;
    font-size: 20px;
    line-height: 1;
}
.uiux-dots span:nth-child(2) { animation-delay: 0.2s; }
.uiux-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes uiux-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: .4; }
    40%           { transform: translateY(-5px); opacity: 1; }
}

/* Подвал */
#uiux-footer {
    border-top: 1px solid #eee;
    padding: 10px 12px;
    background: #fafafa;
}

/* Ввод */
#uiux-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
#uiux-input {
    flex: 1;
    border: 1px solid #dde1e7;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
    resize: none;
    line-height: 1.4;
    transition: border-color 0.15s;
    outline: none;
}
#uiux-input:focus { border-color: #0d6efd; }
#uiux-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d6efd, #0a9396);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s;
}
#uiux-send:disabled { opacity: .5; cursor: default; }
#uiux-send:not(:disabled):hover { opacity: .9; }

/* Адаптив */
@media (max-width: 440px) {
    #uiux-panel { width: calc(100vw - 48px); right: 0; }
}
