/* ============================================================================
   Floating Chat Widget — popup bottom-right, vê lista de conversas ou thread.
   Mountado em MainLayout + AttendanceLayout, controlado por FloatingChatService.
   Tokens-only. Dark mode adapta automaticamente.
   ============================================================================ */

.wt-floating-chat {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 340px;
    height: 480px;
    max-height: calc(100vh - 32px);
    background: var(--wt-card);
    border: 1px solid var(--wt-border);
    border-radius: 12px;
    box-shadow: var(--wt-shadow-lg);
    z-index: 50;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: wt-floating-chat-in 180ms ease-out;
}

@keyframes wt-floating-chat-in {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Header (compartilhado entre List e Thread) ──────────────────────────── */

.wt-floating-chat-head {
    padding: 10px 12px;
    border-bottom: 1px solid var(--wt-border);
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--wt-card);
}

.wt-floating-chat-head-title {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    font-size: 13.5px;
    color: var(--wt-fg);
}

.wt-floating-chat-back,
.wt-floating-chat-expand,
.wt-floating-chat-close {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
    border: 0;
    color: var(--wt-fg-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.wt-floating-chat-back:hover,
.wt-floating-chat-expand:hover,
.wt-floating-chat-close:hover {
    background: var(--wt-bg-3);
    color: var(--wt-fg);
}

/* ── Thread header (avatar + status do interlocutor) ─────────────────────── */

.wt-floating-chat-head-avatar {
    position: relative;
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
}
.wt-floating-chat-head-avatar .wt-avatar {
    width: 100%;
    height: 100%;
}
.wt-floating-chat-head-avatar::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--wt-card);
    background: var(--wt-fg-4);
}
.wt-floating-chat-head-avatar.is-online::after {
    background: var(--wt-success);
}

.wt-floating-chat-head-info {
    flex: 1;
    min-width: 0;
    line-height: 1.2;
}
.wt-floating-chat-head-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--wt-fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wt-floating-chat-head-status {
    font-size: 10.5px;
    color: var(--wt-fg-3);
}
.wt-floating-chat-head-status.is-ok {
    color: var(--wt-success);
}

/* ── Body (container das views) ──────────────────────────────────────────── */

.wt-floating-chat-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.wt-floating-chat-loading,
.wt-floating-chat-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--wt-fg-3);
    font-size: 12px;
}

/* ── Lista de conversas (View.List) ──────────────────────────────────────── */

.wt-floating-chat-list {
    padding: 0;
}

.wt-floating-chat-conv-row {
    width: 100%;
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--wt-border);
    cursor: pointer;
    text-align: left;
}
.wt-floating-chat-conv-row:hover {
    background: var(--wt-bg-3);
}
.wt-floating-chat-conv-row:last-child {
    border-bottom: 0;
}

.wt-floating-chat-conv-avatar {
    position: relative;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
}
.wt-floating-chat-conv-avatar .wt-avatar {
    width: 100%;
    height: 100%;
}
.wt-floating-chat-conv-avatar::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--wt-card);
    background: var(--wt-fg-4);
}
.wt-floating-chat-conv-avatar.is-online::after {
    background: var(--wt-success);
}

.wt-floating-chat-conv-body {
    flex: 1;
    min-width: 0;
}
.wt-floating-chat-conv-top {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    align-items: baseline;
}
.wt-floating-chat-conv-name {
    font-weight: 600;
    color: var(--wt-fg);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wt-floating-chat-conv-time {
    color: var(--wt-fg-3);
    font-size: 10.5px;
    flex-shrink: 0;
}
.wt-floating-chat-conv-bottom {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    align-items: center;
    margin-top: 1px;
}
.wt-floating-chat-conv-preview {
    flex: 1;
    color: var(--wt-fg-3);
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wt-floating-chat-conv-unread {
    background: var(--wt-primary);
    color: white;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    flex-shrink: 0;
}

/* ── Thread area (View.Thread) ───────────────────────────────────────────── */

.wt-floating-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: var(--wt-bg-2);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* ── Mobile: vira full-screen ────────────────────────────────────────────── */

@media (max-width: 640px) {
    .wt-floating-chat {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        border: 0;
    }
}
