.atendimento-main {
    display: flex;
    flex-direction: column;
    height: 100vh;
    box-sizing: border-box;
}

.chat-layout {
    flex: 1;
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 18px;
    min-height: 0;
}

/* LISTA DE CONVERSAS */

.chat-list-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-list-header {
    padding: 14px;
    border-bottom: 1px solid var(--border);
}

.chat-list-header input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-list-loading,
.chat-list-empty {
    padding: 20px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: 0.15s;
}

.chat-item:hover {
    background: #f8f8f8;
}

.chat-item.active {
    background: #f0f0f0;
}

.chat-item-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #eeeeee;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
}

.chat-item-info {
    flex: 1;
    min-width: 0;
}

.chat-item-info strong {
    display: block;
    font-size: 13px;
    margin-bottom: 4px;
}

.chat-item-info span {
    display: block;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* VISUALIZAÇÃO DA CONVERSA */

.chat-view-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 14px;
}

.chat-view-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-view-header strong {
    font-size: 14px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message-bubble {
    max-width: 65%;
    padding: 10px 30px 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-bubble.received {
    background: #f0f0f0;
    align-self: flex-start;
    border-bottom-left-radius: 3px;
}

.message-bubble.sent {
    background: #000000;
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 3px;
}

.reply-quote {
    border-left: 3px solid #16a05d;
    background: rgba(0,0,0,0.05);
    padding: 5px 8px;
    margin-bottom: 6px;
    border-radius: 4px;
    font-size: 11.5px;
    line-height: 1.3;
    color: #555555;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-bubble.sent .reply-quote {
    background: rgba(255,255,255,0.14);
    border-left-color: #3ecf8e;
    color: rgba(255,255,255,0.75);
}

.reply-quote {
    cursor: pointer;
}

@keyframes flashHighlight {
    0% { box-shadow: 0 0 0 3px rgba(22,160,93,0.6); }
    100% { box-shadow: 0 0 0 0 rgba(22,160,93,0); }
}

.message-bubble.highlight-flash {
    animation: flashHighlight 1.4s ease;
}

.message-bubble {
    position: relative;
}

.bubble-reply-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.08);
    color: inherit;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 0.15s ease;
}

.message-bubble.sent .bubble-reply-btn {
    background: rgba(255,255,255,0.2);
}

.bubble-reply-btn:hover {
    opacity: 1;
}

.reply-preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f0f0f0;
    border-left: 3px solid #16a05d;
    padding: 8px 12px;
    margin: 0 14px;
    border-radius: 6px 6px 0 0;
    font-size: 12.5px;
    color: #333333;
}

.reply-preview-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: 10px;
}

.reply-preview-cancel {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #777777;
    flex-shrink: 0;
}

.message-bubble time {
    display: block;
    font-size: 10px;
    opacity: 0.6;
    margin-top: 5px;
}

.chat-input-area {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.chat-input-area input,
.chat-input-area textarea {
    flex: 1;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 9px;
    font-size: 13px;
    font-family: inherit;
}

.chat-input-area textarea {
    resize: none;
    max-height: 120px;
    line-height: 1.4;
    overflow-y: auto;
}

.chat-input-area button {
    background: #000000;
    color: #ffffff;
    padding: 0 20px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 600;
}

.chat-input-area button:hover {
    opacity: 0.85;
}
.chat-item.unread strong {
    font-weight: 700;
}

.chat-item.unread span {
    color: var(--text);
    font-weight: 500;
}

.unread-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #16a05d;
    flex-shrink: 0;
}
.client-badge {
    display: inline-block;
    background: #e7f7ef;
    color: #16a05d;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

.partner-badge {
    display: inline-block;
    background: #fff4e5;
    color: #b5650b;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

.client-status-bar {
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
}

.client-status-bar.client-known {
    background: #f0f9f4;
    color: #16a05d;
}

.client-status-bar.client-unknown {
    background: #fafafa;
    color: var(--muted);
}

.client-status-bar button {
    background: #000000;
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.client-status-bar.client-known button {
    background: #000000;
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.actions-menu-wrapper {
    position: relative;
}

.actions-menu {
    display: none;
    position: absolute;
    top: 34px;
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 50;
    width: 190px;
    overflow: hidden;
}

.actions-menu.open {
    display: block;
}

.actions-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    font-size: 12px;
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.actions-menu-item:last-child {
    border-bottom: none;
}

.actions-menu-item:hover {
    background: #f7f7f7;
}

.actions-menu-item.danger {
    color: #b5650b;
}

/* =========================================================
   MOBILE
   ========================================================= */

.chat-back-btn {
    display: none;
}

@media (max-width: 768px) {

    .atendimento-main {
        height: auto;
        min-height: 100vh;
    }

    .chat-layout {
        grid-template-columns: 1fr;
        height: calc(100vh - 90px);
    }

    .chat-list-panel {
        display: flex;
    }

    .chat-view-panel {
        display: none;
    }

    .chat-layout.chat-open .chat-list-panel {
        display: none;
    }

    .chat-layout.chat-open .chat-view-panel {
        display: flex;
        flex-direction: column;
    }

    .chat-back-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 30px;
        height: 30px;
        border-radius: 6px;
        background: #f0f0f0;
        margin-right: 8px;
        font-size: 16px;
    }

}
