/* ===============================================
   CHAT INTERFACE - WhatsApp Web Style
   =============================================== */

.chat-container {
    display: flex;
    height: calc(100vh - 120px);
    background: var(--card);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}

/* Sidebar de chats */
.chat-sidebar {
    width: 350px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: var(--card);
}

.chat-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-sidebar-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
}

.evolution-config-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.evolution-config-select:hover {
    border-color: var(--primary);
}

.evolution-config-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.chat-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.chat-search input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    transition: all 0.2s;
}

.chat-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.chat-search input::placeholder {
    color: var(--muted);
}

.chats-list {
    flex: 1;
    overflow-y: auto;
    background: var(--bg);
}

.chat-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-item:hover {
    background: var(--hover);
}

.chat-item.active {
    background: var(--primary);
    color: white;
}

.chat-item.active .chat-item-name,
.chat-item.active .chat-item-preview,
.chat-item.active .chat-item-time {
    color: white;
}

.chat-item-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

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

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.chat-item-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-time {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}

.chat-item-preview {
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-unread {
    background: var(--primary);
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

/* Área de chat principal */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    position: relative;
}

.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    text-align: center;
    padding: 40px;
}

.empty-chat-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.chat-empty-state h3 {
    margin: 0 0 8px 0;
    font-size: 20px;
    color: var(--text);
}

.chat-empty-state p {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
}

/* Chat activo */
.chat-active {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--card);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-contact-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.chat-contact-details h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.chat-contact-number {
    margin: 2px 0 0 0;
    font-size: 13px;
    color: var(--muted);
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: transparent;
    border: none;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    color: var(--text);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--hover);
}

/* Mensajes */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg);
    background-image: 
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 10px,
            rgba(var(--muted-rgb), 0.03) 10px,
            rgba(var(--muted-rgb), 0.03) 20px
        );
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message {
    display: flex;
    margin-bottom: 8px;
    animation: messageSlideIn 0.3s ease;
}

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

.message.sent {
    justify-content: flex-end;
}

.message.received {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 8px;
    word-wrap: break-word;
    position: relative;
}

.message.sent .message-bubble {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.message.received .message-bubble {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 2px;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

.message.received .message-time {
    text-align: left;
}

.message-status {
    font-size: 11px;
    margin-left: 4px;
    opacity: 0.7;
}

/* Input de mensaje */
.chat-input-container {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--card);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-input-container input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    transition: all 0.2s;
}

.chat-input-container input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.chat-input-container input::placeholder {
    color: var(--muted);
}

/* Scrollbar personalizado */
.chats-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chats-list::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chats-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--muted);
    border-radius: 3px;
}

.chats-list::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Responsive */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
        height: calc(100vh - 80px);
    }
    
    .chat-sidebar {
        width: 100%;
        height: 40%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .chat-main {
        height: 60%;
    }
}

