/* ============================================================
   chat.css — Chat interno (PV, grupos e fotos)
   ============================================================ */

#view-chat {
  display: flex;
  height: calc(100vh - 6.5rem);
  min-height: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

/* ---- Sidebar (conversation list) ---- */
.chat-sidebar {
  width: 300px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
}

.chat-sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.chat-sidebar-header h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-primary);
}

.chat-sidebar-actions {
  display: flex;
  gap: 0.4rem;
}

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

.chat-list-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

.chat-list-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.chat-list-item:hover { background: var(--bg-hover); }
.chat-list-item.active { background: var(--accent-glow); }

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

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

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

/* ---- Main panel ---- */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-main-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.75rem;
  color: var(--text-muted);
}

.chat-main-empty i { font-size: 2.5rem; opacity: 0.3; }

.chat-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border);
}

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

.chat-header-info .chat-header-name {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-header-info .chat-header-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.chat-messages-empty {
  margin: auto;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.chat-message {
  display: flex;
  gap: 0.6rem;
  max-width: 68%;
}

.chat-message.own {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-message.other { align-self: flex-start; }

.chat-bubble {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 0.55rem 0.8rem;
  min-width: 0;
}

.chat-message.own .chat-bubble {
  background: var(--accent);
  border-color: var(--accent);
}

.chat-message.own .chat-bubble-text,
.chat-message.own .chat-bubble-time { color: #fff; }

.chat-bubble-sender {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.15rem;
}

.chat-bubble-text {
  font-size: 0.875rem;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.chat-bubble-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.chat-bubble-media { padding: 0.35rem; }

.chat-bubble-img {
  display: block;
  max-width: 240px;
  max-height: 240px;
  border-radius: 8px;
  cursor: pointer;
  object-fit: cover;
}

/* ---- Message actions (menu with edit/delete) ---- */
.chat-bubble-menu {
  position: relative;
  display: inline-flex;
}

.chat-bubble-menu > i {
  cursor: pointer;
  font-size: 0.8rem;
  opacity: 0.55;
  padding: 0.1rem 0.3rem;
  transition: opacity 0.15s;
}

.chat-bubble-menu > i:hover { opacity: 1; }

.chat-bubble-menu-dropdown {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 0.3rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  z-index: 20;
  min-width: 130px;
}

.chat-bubble-menu-dropdown button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 0.55rem 0.8rem;
  font-size: 0.8rem;
  cursor: pointer;
  text-align: left;
}

.chat-bubble-menu-dropdown button:hover { background: var(--bg-hover); }

.chat-edit-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-edit-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  color: #fff;
  font-size: 0.85rem;
  font-family: inherit;
}

.chat-edit-row i {
  cursor: pointer;
  font-size: 0.9rem;
}

/* ---- Composer ---- */
.chat-composer {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1.1rem;
  border-top: 1px solid var(--border);
}

.chat-composer input[type="text"] {
  flex: 1;
}

/* ---- Avatars ---- */
#view-chat .assignee-dot,
.chat-picker-item .assignee-dot,
.chat-picker-checkbox .assignee-dot {
  width: 38px;
  height: 38px;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.chat-message .assignee-dot {
  width: 30px;
  height: 30px;
  font-size: 0.72rem;
}

.chat-avatar-group {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Pickers (modals) ---- */
.chat-picker-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
}

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

.chat-picker-list {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.chat-picker-checkbox {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem;
  border-radius: 8px;
  cursor: pointer;
}

.chat-picker-checkbox:hover { background: var(--bg-hover); }
.chat-picker-checkbox input[type="checkbox"] { width: 16px; height: 16px; flex-shrink: 0; }

/* ---- Group photo picker ---- */
.chat-group-photo-picker {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 auto;
}

#chat-group-photo-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  overflow: hidden;
  cursor: pointer;
}

.chat-group-photo-edit-btn {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elevated);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  cursor: pointer;
}

@media (max-width: 768px) {
  #view-chat {
    height: calc(100vh - 5.5rem);
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  /* No mobile só um painel aparece por vez: lista OU conversa aberta */
  .chat-sidebar { width: 100%; border-right: none; }
  .chat-main { display: none; }

  #view-chat.chat-conversation-open .chat-sidebar { display: none; }
  #view-chat.chat-conversation-open .chat-main { display: flex; }

  .chat-header-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    padding: 0.3rem 0.5rem 0.3rem 0;
    cursor: pointer;
    flex-shrink: 0;
  }

  .chat-message { max-width: 85%; }
}

/* ---- Chat no modelo do Início: painel carvão arredondado ---- */
#view-chat {
  height: calc(100vh - 7.5rem);
  background: var(--card-fill);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  animation: npPop 0.6s var(--ease) both;
}
.chat-sidebar { background: rgba(255, 255, 255, 0.015); }
body.light-theme .chat-sidebar { background: var(--bg-elevated); }
