/* ============================================================
   Inbox UI — Central de Atendimento (WhatsApp)
   Design para secretaria: botoes grandes, cores claras, alertas visuais
   ============================================================ */

/* ── Layout principal ────────────────────────────────────── */
.ibx-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 90px);
  overflow: hidden;
}

/* ── Cards de resumo (topo) ──────────────────────────────── */
.ibx-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr) auto;
  gap: 8px;
  padding: 8px 16px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.ibx-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: default;
  transition: box-shadow 0.15s;
}

.ibx-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }

.ibx-card-refresh {
  cursor: pointer;
  transition: background 0.15s;
  min-width: 80px;
}
.ibx-card-refresh:hover { background: #F0FDF4; }
.ibx-card-refresh:active { transform: scale(0.97); }

.ibx-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ibx-card-info { flex: 1; min-width: 0; }

.ibx-card-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
  margin-bottom: 1px;
}

.ibx-card-value {
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

/* Card urgente pulsante */
.ibx-card-urgent .ibx-card-icon { background: #FEE2E2; color: #DC2626; }
.ibx-card-urgent .ibx-card-value { color: #DC2626; }
.ibx-card-urgent.ibx-has-items { animation: ibx-pulse 1.5s ease-in-out infinite; }

.ibx-card-waiting .ibx-card-icon { background: #FEF3C7; color: #D97706; }
.ibx-card-waiting .ibx-card-value { color: #D97706; }

.ibx-card-lara .ibx-card-icon { background: #D1FAE5; color: #059669; }
.ibx-card-lara .ibx-card-value { color: #059669; }

.ibx-card-resolved .ibx-card-icon { background: #F3F4F6; color: #6B7280; }
.ibx-card-resolved .ibx-card-value { color: #6B7280; }

@keyframes ibx-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

/* ── Area principal (lista + chat) ───────────────────────── */
.ibx-main {
  display: grid;
  grid-template-columns: 340px 1fr;
  flex: 1;
  overflow: hidden;
}

/* ── Lista de conversas (esquerda) ───────────────────────── */
.ibx-sidebar {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ibx-search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ibx-search-input {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg-card);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}

.ibx-search-input:focus { border-color: var(--accent-gold); }
.ibx-search-input::placeholder { color: var(--text-muted, #9ca3af); }

.ibx-filters {
  display: flex;
  gap: 4px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
}

.ibx-filter-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.ibx-filter-btn:hover { background: var(--bg-hover, #f9fafb); }
.ibx-filter-btn.ibx-filter-active {
  background: var(--accent-gold);
  color: #fff;
  border-color: var(--accent-gold);
}

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

/* Conversa individual na lista */
.ibx-conv {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.ibx-conv:hover { background: var(--bg-hover, #f9fafb); }
.ibx-conv.ibx-conv-selected { background: #EEF2FF; }
.ibx-conv.ibx-conv-urgent { background: #FEF2F2; }
.ibx-conv.ibx-conv-urgent:hover { background: #FEE2E2; }

.ibx-conv-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.ibx-dot-red { background: #DC2626; }
.ibx-dot-yellow { background: #D97706; }
.ibx-dot-green { background: #059669; }
.ibx-dot-gray { background: #9CA3AF; }

.ibx-conv-body { flex: 1; min-width: 0; }

.ibx-conv-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}

.ibx-conv-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ibx-conv-time {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.ibx-conv-preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.ibx-conv-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.ibx-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ibx-tag-urgent { background: #FEE2E2; color: #DC2626; }
.ibx-tag-agendar { background: #FEF3C7; color: #92400E; }
.ibx-tag-preco { background: #DBEAFE; color: #1E40AF; }
.ibx-tag-lara { background: #D1FAE5; color: #065F46; }
.ibx-tag-humano { background: #F3E8FF; color: #6B21A8; }

.ibx-conv-who {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

/* ── Chat (direita) ──────────────────────────────────────── */
.ibx-chat {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #F8FAFC;
}

.ibx-chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  gap: 8px;
}

.ibx-chat-empty-icon { opacity: 0.3; }
.ibx-chat-empty-text { font-size: 15px; font-weight: 600; }
.ibx-chat-empty-sub { font-size: 13px; }

/* Chat header */
.ibx-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.ibx-chat-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.ibx-chat-phone {
  font-size: 12px;
  color: var(--text-secondary);
}

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

/* Botoes grandes para secretaria */
.ibx-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.ibx-btn-assume {
  background: #FEF3C7;
  color: #92400E;
  border: 2px solid #F59E0B;
}
.ibx-btn-assume:hover { background: #FDE68A; }

.ibx-btn-release {
  background: #D1FAE5;
  color: #065F46;
  border: 2px solid #10B981;
}
.ibx-btn-release:hover { background: #A7F3D0; }

.ibx-btn-resolve {
  background: #F3F4F6;
  color: #6B7280;
  border: 2px solid #D1D5DB;
}
.ibx-btn-resolve:hover { background: #E5E7EB; }

.ibx-btn-danger {
  background: #FEE2E2;
  color: #DC2626;
  border: 2px solid #F87171;
}

/* Chat messages area */
.ibx-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Baloes de mensagem estilo WhatsApp */
.ibx-msg {
  max-width: 75%;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
  position: relative;
}

.ibx-msg-inbound {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.ibx-msg-outbound {
  align-self: flex-end;
  background: #DCF8C6;
  border-bottom-right-radius: 4px;
}

.ibx-msg-outbound.ibx-msg-lara {
  background: #E8DAFF;
}

.ibx-msg-outbound.ibx-msg-humano {
  background: #DCF8C6;
}

.ibx-msg-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.ibx-msg-time {
  font-size: 10px;
  color: #6B7280;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.ibx-msg-status {
  font-size: 11px;
  font-weight: 700;
}

.ibx-status-sent {
  color: #10B981;
}

.ibx-status-pending {
  color: #F59E0B;
}

.ibx-status-failed {
  color: #EF4444;
}

.ibx-msg-doc {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(0,0,0,0.05);
  border-radius: 8px;
  color: #2563EB;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}

.ibx-msg-doc:hover {
  background: rgba(0,0,0,0.08);
}

.ibx-msg-image {
  cursor: pointer;
}

.ibx-msg-media-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: rgba(0,0,0,0.04);
  border-radius: 8px;
  font-size: 13px;
  color: #6B7280;
  font-weight: 500;
}

.ibx-msg-sender {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
}

.ibx-msg-sender-lara {
  background: #7C3AED20;
  color: #7C3AED;
}

.ibx-msg-sender-humano {
  background: #05966920;
  color: #059669;
}

/* Input de mensagem */
.ibx-chat-input {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.ibx-input-field {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--text-primary);
  outline: none;
  resize: none;
  min-height: 38px;
  max-height: 80px;
  transition: border-color 0.15s;
}

.ibx-input-field:focus { border-color: var(--accent-gold); }
.ibx-input-field::placeholder { color: #9CA3AF; }

.ibx-send-btn {
  padding: 8px 20px;
  background: var(--accent-gold);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ibx-send-btn:hover { background: var(--accent-gold-dark); }
.ibx-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Status da conversa */
.ibx-chat-status {
  padding: 5px 16px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.ibx-status-lara {
  background: #F3E8FF;
  color: #7C3AED;
}

.ibx-status-humano {
  background: #D1FAE5;
  color: #065F46;
}

/* ── Loading ─────────────────────────────────────────────── */
.ibx-loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

.ibx-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: ibx-spin 0.7s linear infinite;
}

@keyframes ibx-spin { to { transform: rotate(360deg); } }

/* ── Image messages ────────────────────────────────────── */
.ibx-msg-image {
  max-width: 220px;
  border-radius: 8px;
  display: block;
  margin-bottom: 4px;
  cursor: pointer;
}
.ibx-msg-image:hover { opacity: 0.9; }
.ibx-msg-caption {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .ibx-cards { grid-template-columns: repeat(2, 1fr); }
  .ibx-main { grid-template-columns: 280px 1fr; }
}
