/* ═══════════════════════════════════════════════════════════════════════
   NES — Cabeçalho Clínico Profissional
   Redesenho da área de atendimento e seleção de paciente
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── RESET E BASE DO CARD ─────────────────────────────────────────── */

#paciente-ativo-bar {
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border-default, #e5e7eb);
  border-radius: var(--radius-xl, 1rem);
  margin: 0 0 14px;
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(10,22,40,.08));
  transition: box-shadow 0.2s;
  flex-shrink: 0;
  /* Sobrescreve o flex legado */
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  gap: 0 !important;
  max-height: none !important;
  min-height: 0 !important;
  padding: 0 !important;
}

/* ─── TOPBAR — faixa de título do card ─────────────────────────────── */

.nch-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 16px;
  background: linear-gradient(90deg, var(--navy-800, #112238) 0%, var(--navy-700, #1A3350) 100%);
  color: #fff;
  min-height: 38px;
  flex-shrink: 0;
}

.nch-topbar-label {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--teal-200, #80DFDA);
  font-family: var(--font-display, system-ui);
  user-select: none;
}

/* Botão trocar paciente dentro da topbar */
#nes-btn-trocar-paciente.nch-trocar-btn {
  font-size: 0.72rem !important;
  padding: 3px 10px !important;
  height: auto !important;
  min-height: 0 !important;
  line-height: 1.4 !important;
  border-color: rgba(255,255,255,0.3) !important;
  color: rgba(255,255,255,0.88) !important;
  background: rgba(255,255,255,0.07) !important;
  border-radius: var(--radius-full, 9999px) !important;
}
#nes-btn-trocar-paciente.nch-trocar-btn:hover {
  background: rgba(255,255,255,0.15) !important;
  border-color: rgba(255,255,255,0.5) !important;
}

/* ─── EMPTY STATE — nenhum paciente selecionado ─────────────────────── */

#nes-pb-empty-state.nes-pb-empty-state {
  padding: 28px 20px 24px;
  text-align: center;
}

#nes-pb-empty-state .nes-pb-empty-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

#nes-pb-empty-state .nes-pb-empty-icon {
  font-size: 2.2rem;
  line-height: 1;
  margin-bottom: 2px;
}

#nes-pb-empty-state .nes-pb-empty-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary, #0A1628);
  margin: 0;
  font-family: var(--font-display, system-ui);
}

#nes-pb-empty-state .nes-pb-empty-hint {
  font-size: 0.82rem;
  color: var(--text-muted, #6b7280);
  margin: 0 0 8px;
  max-width: 340px;
  line-height: 1.5;
}

#nes-pb-empty-state .nes-pb-empty-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ─── ESTADO COM PACIENTE — inner layout ─────────────────────────────── */

/* Sobrescreve restrições legadas */
#paciente-ativo-bar.visible {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  gap: 0 !important;
  padding: 0 !important;
  max-height: none !important;
  overflow: visible !important;
}

#paciente-ativo-bar .patient-bar-inner {
  display: flex !important;
  flex-direction: row;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px !important;
  max-height: none !important;
  overflow: visible !important;
  flex-wrap: wrap;
  flex: 1;
}

/* Avatar maior e mais destacado */
#paciente-ativo-bar .patient-bar-avatar.avatar {
  width: 54px !important;
  height: 54px !important;
  font-size: 1.15rem !important;
  font-weight: 800;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--navy-500, #2D5680) 0%, var(--teal-400, #00B4A6) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,180,166,0.25);
}

/* Coluna de informações */
#paciente-ativo-bar .patient-bar-info {
  flex: 1 1 180px;
  min-width: 0;
  overflow: visible;
}

#paciente-ativo-bar .patient-bar-info h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  color: var(--text-primary, #0A1628);
  line-height: 1.3;
  font-family: var(--font-display, system-ui);
}

#paciente-ativo-bar .patient-bar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 12px;
  font-size: 0.8rem;
  color: var(--text-secondary, #374151);
  margin-bottom: 6px;
}

#paciente-ativo-bar .patient-bar-meta span {
  display: inline-flex;
  align-items: center;
}

/* Tags clínicas */
#paciente-ativo-bar .patient-bar-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: none;
  margin-top: 2px;
}

/* ─── AÇÕES — grupo de botões do paciente ─────────────────────────── */

#paciente-ativo-bar .patient-bar-actions.patient-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
  align-self: flex-start;
  max-width: 420px;
}

/* Separador visual entre grupos de botões */
.nch-action-sep {
  width: 1px;
  height: 24px;
  background: var(--border-default, #e5e7eb);
  align-self: center;
  flex-shrink: 0;
}

/* ─── ALERTAS CLÍNICOS — acima das abas ────────────────────────────── */

#nch-alertas-wrapper {
  display: none; /* mostrado via JS quando há alertas */
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 0 10px;
}

#nch-alertas-wrapper.tem-alertas {
  display: flex;
}

.nch-alerta-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: var(--radius-full, 9999px);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: default;
}

.nch-alerta-badge--red   { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.nch-alerta-badge--amber { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.nch-alerta-badge--green { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.nch-alerta-badge--blue  { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ─── RESPONSIVIDADE ─────────────────────────────────────────────── */

/* Tablet: ≤ 900px — 2 colunas para as ações */
@media (max-width: 900px) {
  #paciente-ativo-bar .patient-bar-inner {
    flex-direction: column;
    gap: 12px;
  }

  #paciente-ativo-bar .patient-bar-actions.patient-actions {
    max-width: 100%;
    width: 100%;
  }
}

/* Mobile: ≤ 600px — tudo empilhado */
@media (max-width: 600px) {
  .nch-topbar {
    padding: 8px 12px;
  }

  #paciente-ativo-bar .patient-bar-inner {
    padding: 14px 12px !important;
    gap: 10px;
  }

  #paciente-ativo-bar .patient-bar-actions.patient-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  #nes-pb-empty-state.nes-pb-empty-state {
    padding: 22px 14px 18px;
  }

  #nes-pb-empty-state .nes-pb-empty-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: 260px;
  }
}

/* Modo escuro */
@media (prefers-color-scheme: dark) {
  #paciente-ativo-bar {
    background: var(--bg-surface, var(--navy-900, #0A1628));
    border-color: var(--border-default, var(--navy-700, #1A3350));
  }

  #paciente-ativo-bar .patient-bar-info h3 {
    color: #f9fafb;
  }

  #paciente-ativo-bar .patient-bar-meta {
    color: var(--navy-200, #A4C3DD);
  }

  #nes-pb-empty-state .nes-pb-empty-title {
    color: #f9fafb;
  }

  #nes-pb-empty-state .nes-pb-empty-hint {
    color: var(--navy-300, #6E9CC4);
  }
}
