/* Chat — UI messaggi e lista conversazioni */

.chat-layout {
  display: grid;
  gap: var(--space-6);
  height: calc(100vh - var(--header-height, 4rem));
  padding: var(--space-4);
}
@media (min-width: 768px) {
  .chat-layout {
    grid-template-columns: 20rem 1fr;
    height: calc(100vh - var(--header-height, 4rem));
    max-height: 50rem;
  }
}

.chat-list {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.chat-list__header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-list__header h2 {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 600;
  font-family: var(--font-body);
}
.chat-list__items {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  flex: 1;
}
.chat-list__item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--space-3);
  padding: var(--space-4);
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  align-items: center;
  transition: background var(--transition-fast);
}
.chat-list__item:hover { background: var(--color-surface-muted); }
.chat-list__item.is-active { background: var(--color-surface-muted); }
.chat-list__avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 600;
}
.chat-list__meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.chat-list__meta strong { font-size: var(--text-sm); color: var(--color-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list__meta span { font-size: var(--text-xs); color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list__time { font-size: var(--text-xs); color: var(--color-text-muted); }

.chat-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}
.chat-panel__header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.chat-panel__user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.chat-panel__avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 600;
}
.chat-panel__user strong { display: block; font-size: var(--text-sm); }
.chat-panel__user span { font-size: var(--text-xs); color: var(--color-text-muted); }

.chat-panel__messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.chat-msg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 85%;
}
.chat-msg--out { align-self: flex-end; align-items: flex-end; }
.chat-msg__bubble {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: 1.5;
}
.chat-msg--in .chat-msg__bubble {
  background: var(--color-surface-muted);
  color: var(--color-text);
}
.chat-msg--out .chat-msg__bubble {
  background: var(--color-primary);
  color: #fff;
}
.chat-msg__time {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.chat-panel__input {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border-top: 1px solid var(--color-border);
}
.chat-panel__input .input { flex: 1; }
