/**
 * MODELO 2 — Prontuário SOAP Azul Clínico
 * Padrão visual dos formulários clínicos Método NES
 */

.nes-m2-layout {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 8px;
  border-radius: 14px;
  overflow: visible;
  border: 1px solid rgba(12, 59, 110, 0.12);
  background: #f4f8fc;
  box-shadow: 0 4px 18px rgba(12, 59, 110, 0.08);
}

.nes-form-page.nes-m2-layout {
  margin-top: 0;
  border-radius: 0;
  border: none;
  box-shadow: none;
  overflow: hidden;
}

/* Cabeçalho clínico azul */
.nes-m2-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #0c3b6e 0%, #1e5a9e 55%, #2b7bc9 100%);
  color: #fff;
}

.nes-m2-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.nes-m2-header-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.nes-m2-header-titles h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.nes-m2-header-titles p {
  margin: 2px 0 0;
  font-size: 0.75rem;
  opacity: 0.88;
}

.nes-m2-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.nes-m2-toolbar .btn {
  font-size: 0.78rem;
  padding: 6px 12px;
  border-radius: 8px;
}

.nes-m2-toolbar .btn-primary {
  background: #00b4a6;
  border-color: #00b4a6;
}

.nes-m2-toolbar .btn-outline {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}

.nes-m2-toolbar .btn-outline:hover {
  background: rgba(255, 255, 255, 0.22);
}

.nes-m2-toolbar .btn-ghost {
  color: rgba(255, 255, 255, 0.9);
}

/* Card do paciente */
.nes-m2-patient-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px 16px;
  padding: 12px 18px;
  background: #fff;
  border-bottom: 1px solid rgba(12, 59, 110, 0.1);
}

.nes-m2-patient-card .m2-field label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 2px;
}

.nes-m2-patient-card .m2-field span {
  font-size: 0.85rem;
  font-weight: 600;
  color: #0c3b6e;
}

/* Corpo: main + sidebar */
.nes-m2-body {
  display: grid;
  grid-template-columns: 1fr 272px;
  gap: 0;
  align-items: start;
  min-height: 0;
}

.nes-m2-main {
  padding: 16px 18px 20px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: visible;
  max-height: none;
  padding-bottom: 24px;
}

.nes-form-main.nes-m2-main {
  overflow: visible;
  max-height: none;
}

/* Blocos SOAP / seções clínicas */
.nes-m2-soap-block {
  background: #fff;
  border: 1px solid rgba(12, 59, 110, 0.1);
  border-radius: 12px;
  overflow: hidden;
}

.nes-m2-soap-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(90deg, #e8f2fb 0%, #f0f7ff 100%);
  border-bottom: 1px solid rgba(12, 59, 110, 0.08);
}

.nes-m2-soap-letter {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #0c3b6e;
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nes-m2-soap-head h4 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: #0c3b6e;
}

.nes-m2-soap-head small {
  display: block;
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 400;
}

.nes-m2-soap-body {
  padding: 14px;
}

/* Sidebar direita clínica */
.nes-m2-sidebar {
  background: #fff;
  border-left: 1px solid rgba(12, 59, 110, 0.1);
  padding: 14px 12px 18px;
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.nes-m2-side-block {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e8eef4;
}

.nes-m2-side-block:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.nes-m2-side-block h5 {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #0c3b6e;
}

.nes-m2-side-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: #475569;
}

.nes-m2-side-list li {
  padding: 4px 0;
  border-bottom: 1px dashed #eef2f6;
}

.nes-m2-side-list li:last-child {
  border-bottom: none;
}

.nes-m2-alert {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.76rem;
  margin-bottom: 6px;
  line-height: 1.4;
}

.nes-m2-alert.warn {
  background: #fff7ed;
  color: #9a3412;
  border-left: 3px solid #f97316;
}

.nes-m2-alert.danger {
  background: #fef2f2;
  color: #991b1b;
  border-left: 3px solid #dc2626;
}

.nes-m2-alert.info {
  background: #eff6ff;
  color: #1e40af;
  border-left: 3px solid #3b82f6;
}

/* Hub de módulos Modelo 2 */
.nes-m2-hub {
  padding: 16px 18px 20px;
  background: #fff;
}

.nes-m2-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.nes-m2-hub-card {
  background: #f8fbff;
  border: 1px solid rgba(12, 59, 110, 0.12);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  transition: box-shadow 0.15s, transform 0.15s;
  cursor: default;
}

.nes-m2-hub-card:hover {
  box-shadow: 0 6px 16px rgba(12, 59, 110, 0.1);
  transform: translateY(-2px);
}

.nes-m2-hub-card .hub-icon {
  font-size: 1.6rem;
  margin-bottom: 6px;
}

.nes-m2-hub-card h4 {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: #0c3b6e;
}

/* Lista de registros */
.nes-m2-reg-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nes-m2-reg-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.82rem;
}

/* Compatibilidade com cards antigos dentro do M2 */
.nes-m2-main .nes-form-nes-card {
  border-color: rgba(12, 59, 110, 0.1);
}

.nes-m2-main .form-input,
.nes-m2-main .form-textarea,
.nes-m2-main select.form-input {
  border-color: #cbd5e1;
}

.nes-m2-edu {
  border-left: 4px solid #00b4a6;
  background: #f0fdfa;
  padding: 12px 14px;
  border-radius: 0 10px 10px 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: #134e4a;
}

.nes-m2-urg {
  margin-top: 8px;
  padding: 10px 12px;
  background: #fef2f2;
  border-radius: 8px;
  color: #991b1b;
  font-size: 0.78rem;
}

/* Subabas dentro do formulário */
.nes-m2-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
}

.nes-m2-subtab {
  padding: 6px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
}

.nes-m2-subtab.active {
  background: #0c3b6e;
  border-color: #0c3b6e;
  color: #fff;
}

/* Responsivo — sidebar não bloqueia */
#prontuario-view .nes-m2-sidebar {
  max-width: 240px;
}

@media (max-width: 1100px) {
  .nes-m2-body {
    grid-template-columns: 1fr !important;
  }
  .nes-m2-sidebar {
    position: relative;
    top: 0;
    max-height: none;
    max-width: 100%;
  }
}

@media (max-width: 960px) {
  .nes-m2-body {
    grid-template-columns: 1fr;
  }

  .nes-m2-sidebar {
    position: static;
    max-height: none;
    border-left: none;
    border-top: 1px solid rgba(12, 59, 110, 0.1);
    order: 2;
  }

  .nes-m2-main {
    order: 1;
  }

  .nes-m2-header {
    flex-direction: column;
    align-items: stretch;
  }

  .nes-m2-toolbar {
    justify-content: flex-start;
  }
}

/* Integração prontuário — scroll interno + rodapé acessível */
.tab-panel .nes-m2-layout {
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.prontuario-body .nes-m2-sidebar {
  top: 0;
  max-height: calc(100vh - 120px);
  position: sticky;
}

.nes-m2-footer-actions {
  margin-top: auto;
  flex-shrink: 0;
}

.prontuario-body .tab-panel.pront-modulo-panel.active .nes-m2-layout {
  max-height: calc(100vh - 140px);
}

@media (max-width: 900px) {
  .prontuario-body .nes-m2-sidebar {
    max-height: none;
  }
}
