/* Estilos para la barra lateral de chats */

/* Mensaje cuando no hay chats */
.no-chats-message {
    padding: 2rem;
    text-align: center;
}

/* Nueva estructura: nombre y badge en la misma fila */
.chat-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

/* Nombres de chats con ellipsis en una sola línea */
.chat-name {
    flex: 1;
    min-width: 0; /* Permite que flex-shrink funcione */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.chat-name i {
    font-size: 0.8rem;
}

/* Indicadores de estado para los chats */
.chat-item[data-is-pinned="true"] {
    background: rgba(34, 197, 94, 0.1);
    border-left: 3px solid #22c55e;
}

.chat-item[data-is-muted="true"] .chat-name {
    opacity: 0.7;
}

/* Botones del header */
.header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Botones de filtro */
.filter-unread-btn, .filter-incoming-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    line-height: 1;
}

.filter-unread-btn:hover, .filter-incoming-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    transform: scale(1.05);
}

.filter-unread-btn:active, .filter-incoming-btn:active {
    transform: scale(0.95);
}

/* Estado activo del filtro no leídos - amarillo */
.filter-unread-btn.active {
    background: var(--urutienda);
    color: #212529;
}

.filter-unread-btn.active:hover {
    background: var(--urutienda-hover);
    transform: scale(1.05);
}

/* Estado activo del filtro mensajes recibidos - rojo */
.filter-incoming-btn.active {
    background: #ef4444;
    color: white;
}

.filter-incoming-btn.active:hover {
    background: #dc2626;
    transform: scale(1.05);
}

/* Botón de recargar barra lateral */
.refresh-sidebar-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    line-height: 1;
}

/* Botón para cerrar chat en header de conversación (solo desktop) */
.close-chat-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
    line-height: 1;
    margin-right: 8px;
}

.refresh-sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    transform: scale(1.05);
}

.refresh-sidebar-btn:active {
    transform: scale(0.95);
}

.refresh-sidebar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.close-chat-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    transform: scale(1.05);
}

.close-chat-btn:active {
    transform: scale(0.95);
}

/* Animación de rotación para cuando está recargando */
.refresh-sidebar-btn.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Badge para LEADS 24H */
.leads-24h-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.5px;
    margin-top: 4px;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid transparent;
}

/* Modo oscuro - azul con texto azul clarito */
@media (prefers-color-scheme: dark) {
    .leads-24h-badge {
        background: rgba(59, 130, 246, 0.15);
        color: #93c5fd;
        border-color: rgba(59, 130, 246, 0.2);
    }
    
    .leads-24h-badge:hover {
        background: rgba(59, 130, 246, 0.25);
        color: #bfdbfe;
    }
}

/* Modo claro - azul con texto azul oscuro */
@media (prefers-color-scheme: light) {
    .leads-24h-badge {
        background: rgba(59, 130, 246, 0.15);
        color: #1e40af;
        border-color: rgba(59, 130, 246, 0.2);
    }
    
    .leads-24h-badge:hover {
        background: rgba(59, 130, 246, 0.25);
        color: #1e3a8a;
    }
}

/* Fallback para cuando no se detecta preferencia de color */
.leads-24h-badge {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border-color: rgba(59, 130, 246, 0.2);
}

/* Estilos para el preview del último mensaje */
.chat-last-message {
    font-size: 0.875rem;
    color: #9ca3af;
    display: flex;
    align-items: center;
    gap: 4px;
    overflow: hidden;
    flex: 1;
    min-width: 0; /* Permite que el texto se encoja */
}

.chat-message-arrow {
    font-size: 0.75rem;
    flex-shrink: 0;
}

.chat-message-arrow-out {
    color: #3b82f6; /* Azul para mensajes enviados */
}

.chat-message-arrow-in {
    color: #ef4444; /* Rojo para mensajes recibidos */
}

.chat-message-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

/* Modo claro */
.light-theme .chat-last-message {
    color: #6b7280;
}

/* Badge de status no se encoge */
.chat-status-badge-container {
    flex-shrink: 0;
}

/* Segunda fila: preview del mensaje + meta info */
.chat-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

/* La meta info (hora/unread) no se encoge */
.chat-meta {
    flex-shrink: 0;
}