/**
 * Layout amplo — formulários clínicos Modelo 2 (página inteira)
 */

.nes-form-page {
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #f4f8fb;
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  overflow: visible;
}

.nes-form-header {
  flex: 0 0 auto;
  background: #ffffff;
  border-bottom: 1px solid #dbe7ef;
  padding: 16px 24px;
}

.nes-form-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.nes-form-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.nes-form-header-icon {
  font-size: 1.35rem;
  flex-shrink: 0;
}

.nes-form-header-title h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #0c3b6e;
}

.nes-form-header-title p {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: #64748b;
}

.nes-form-header .nes-m2-patient-card,
.nes-form-header .nes-form-header-patient {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 6px 14px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #eef2f6;
}

.nes-form-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 20px;
  padding: 20px 24px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.nes-form-main {
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: visible;
  max-height: none;
  padding-bottom: 260px !important;
}

.nes-form-body,
.nes-wide-form-body,
.clinical-form-area,
.form-fullscreen-body,
#tab-declaracoes .nes-dec-hub-page {
  padding-bottom: 260px !important;
}

.nes-form-sidebar {
  width: 260px;
  min-width: 0;
  align-self: start;
  position: sticky;
  top: 0;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  background: #fff;
  border: 1px solid rgba(12, 59, 110, 0.1);
  border-radius: 12px;
  padding: 14px 12px;
}

.nes-form-sidebar .nes-form-editor-aside {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eef2f6;
}

.nes-form-footer {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  z-index: 300;
  min-height: 72px;
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid #dbe7ef;
  padding: 12px 24px calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 -4px 16px rgba(15, 35, 55, 0.08);
}

.nes-form-footer .left-actions,
.nes-form-footer .right-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.nes-form-footer button {
  min-height: 44px;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .nes-form-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .nes-form-footer .left-actions,
  .nes-form-footer .right-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .nes-form-footer button {
    flex: 1 1 auto;
  }
}

.nes-form-footer .left-actions {
  margin-right: auto;
}

.nes-form-footer .right-actions {
  margin-left: auto;
  justify-content: flex-end;
}

/* Toolbar legado — oculto após promoção para rodapé */
.nes-form-page .nes-form-nes-toolbar:not(.nes-form-footer *) {
  display: none !important;
}

.nes-form-editor-mode .nes-form-nes-tab-head,
.nes-form-editor-mode .nes-form-nes-list,
.nes-form-editor-mode .nes-form-tab-head {
  display: none !important;
}

.nes-form-editor-expanded {
  display: flex !important;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  border: none;
  box-shadow: none;
  margin: 0;
}

.nes-form-page > .nes-form-layout > .nes-form-main > .nes-form-nes-mobile-summary {
  display: none;
}

@media (max-width: 1200px) {
  .nes-form-layout {
    grid-template-columns: 1fr;
  }

  .nes-form-sidebar {
    width: 100%;
    position: static;
    max-height: none;
  }
}

/* Fullscreen no prontuário */
body.form-fullscreen-mode .tab-panel.form-fullscreen > .nes-form-page,
body.form-fullscreen-mode .nes-form-page.form-fullscreen,
body.form-fullscreen-mode .nes-form-page.nes-form-nes-editor-fs {
  width: 100%;
  min-height: calc(100vh - 64px);
  max-height: none;
  height: auto;
}

/* Hub de declarações — sem área vazia */
.nes-dec-hub-page {
  padding: 12px 24px 32px;
  margin: 0;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.nes-dec-hub-head {
  margin-bottom: 16px;
}

.nes-dec-hub-head h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  color: #0c3b6e;
}

.nes-dec-hub-head p {
  margin: 0;
  font-size: 0.85rem;
  color: #64748b;
}

.nes-dec-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.nes-dec-hub-card {
  background: #fff;
  border: 1px solid rgba(12, 59, 110, 0.12);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.nes-dec-hub-card h4 {
  margin: 0;
  font-size: 0.95rem;
  color: #0c3b6e;
}

.nes-dec-hub-card p {
  margin: 0;
  font-size: 0.8rem;
  color: #64748b;
  flex: 1 1 auto;
}

.nes-dec-hub-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.nes-dec-hub-history {
  border-top: 1px solid #e2e8f0;
  padding-top: 16px;
}

.nes-dec-hub-history h4 {
  margin: 0 0 10px;
  font-size: 0.9rem;
  color: #0c3b6e;
}

#tab-declaracoes:not(.form-fullscreen) {
  overflow-y: auto;
  min-height: 0;
  padding: 0;
  margin: 0;
}

.nes-form-editor-mode .nes-dec-hub-page {
  display: none !important;
}

body.form-fullscreen-mode .tab-panel.form-fullscreen .nes-m2-layout.nes-form-page,
body.form-fullscreen-mode .tab-panel.form-fullscreen > .nes-form-page {
  border-radius: 0;
  border: none;
}

body.form-fullscreen-mode #paciente-ativo-bar.visible {
  max-height: 72px;
  padding: 8px 12px;
}

body.form-fullscreen-mode .nes-form-page .nes-m2-toolbar {
  display: none;
}

body.form-fullscreen-mode .nes-form-page .nes-form-header-actions {
  display: flex !important;
}
