/* ═══════════════════════════════════════════════════════════
   STANDARD LAYOUT v1.1 — Card Flutuante Centralizado
   Identidade estrutural clínica unificada.

   Carregado APÓS ds.css e standard-theme.css.
   Escopo: html.light-mode (todos os módulos forçam light-mode).

   ARQUITETURA:
     body                   → fundo de página (invisível)
     .ds-layout             → CANVAS azul-névoa com padding
     .ds-main               → centralizador de largura (1200px)
     [wrapper-interno]      → padding zerado (sem dupla margem)
     .test-container        → O CARD branco (ocupa 100% do ds-main)

   VARIANTES DE LAYOUT (mapeadas para ds-layout / ds-main):
     .et-layout / .app-layout / .pid-layout → ds-layout
     .et-main / .main-content / .pid-main   → ds-main
     .w3-layout / .w4-layout                → WAIS-III / WISC-IV (mais largos)

   EXCEÇÕES:
     .lf-body / .lf-main    → Laudo Final
     .page-layout           → Atendimento / Pacientes / Gestão
═══════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════════
   1. CANVAS DE PÁGINA
   Gradiente azul-névoa que emoldura o card central.
   Inclui TODAS as variantes de layout usadas nos módulos.
══════════════════════════════════════════════════════════ */
html.light-mode .ds-layout,
html.light-mode .et-layout,
html.light-mode .app-layout,
html.light-mode .pid-layout,
html.light-mode .clinical-layout-page {
  background: linear-gradient(160deg, #EFF6FF 0%, #F1F5F9 55%, #F0F4F8 100%) !important;
  padding: 28px 20px 56px !important;
  min-height: 100vh !important;
  box-sizing: border-box !important;
  display: block !important;
}

/* WAIS-III e WISC-IV: padding menor (interface mais densa) */
html.light-mode .w3-layout,
html.light-mode .w4-layout {
  background: linear-gradient(160deg, #EFF6FF 0%, #F1F5F9 55%, #F0F4F8 100%) !important;
  padding: 24px 20px 48px !important;
  min-height: 100vh !important;
  box-sizing: border-box !important;
}

/* ══════════════════════════════════════════════════════════
   2. CENTRALIZADOR DE LARGURA
   1200px: usa mais da tela sem comprometer leitura clínica.
   Inclui variantes de ds-main usadas pelos módulos.
══════════════════════════════════════════════════════════ */
html.light-mode .ds-main,
html.light-mode .et-main.ds-main,
html.light-mode .main-content.ds-main,
html.light-mode .pid-main.ds-main {
  max-width: 1200px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  width: 100% !important;
}

/* WAIS-III e WISC-IV: mais largos por terem nav interna lateral */
html.light-mode .w3-main,
html.light-mode .w4-main {
  max-width: 1400px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  width: 100% !important;
}

/* ══════════════════════════════════════════════════════════
   3. O CARD — elemento central de todos os módulos
   Branco, bordas arredondadas, sombra suave.
   Todo o conteúdo do teste vive dentro deste card.
══════════════════════════════════════════════════════════ */
html.light-mode .test-container {
  background: #FFFFFF !important;
  border: 1px solid #E2EEF5 !important;
  border-radius: 20px !important;
  box-shadow:
    0 8px 32px rgba(15, 23, 42, 0.09),
    0 2px 8px  rgba(15, 23, 42, 0.05) !important;
  overflow: hidden !important;
  width: 100% !important;
  position: relative !important;
}

/* Linha decorativa azul no topo do card */
html.light-mode .test-container::before {
  content: '' !important;
  display: block !important;
  height: 3px !important;
  background: linear-gradient(90deg, #3B82F6, #1D4ED8, #1E3A8A) !important;
  border-radius: 20px 20px 0 0 !important;
}

/* ══════════════════════════════════════════════════════════
   4. CABEÇALHO DO CARD — faixa de identidade do instrumento
   Gradiente azul escuro profissional em cima do card.

   NOTA DE ESPECIFICIDADE: theme.js injeta um <style> ao FINAL
   do <head> com "html.light-mode .ds-test-header{background:
   transparent!important}" (especificidade 0-2-1).
   Para vencer, usamos ".test-container .ds-test-header"
   (especificidade 0-3-1) — valor maior sempre ganha, mesmo
   chegando antes na cascata.
══════════════════════════════════════════════════════════ */
html.light-mode .test-container .ds-test-header,
html.light-mode .test-container .bfp-card-header,
html.light-mode .test-container .module-header-bar,
html.light-mode .ds-main-inner .ds-test-header,
html.light-mode .ds-main-inner .bfp-card-header {
  background: linear-gradient(135deg, #1E3A5F 0%, #1E40AF 100%) !important;
  padding: 22px 32px 20px !important;
  position: relative !important;
}

/* Sobrescreve a linha do ::before do test-container quando o header
   está dentro do card (o header já tem o gradiente no fundo, a linha
   no topo do card fica redundante neste caso) */
html.light-mode .test-container:has(.ds-test-header)::before,
html.light-mode .test-container:has(.bfp-card-header)::before {
  display: none !important;
}

/* Textos no header escuro — especificidade 0-4-1 (vence theme.js 0-2-1) */
html.light-mode .test-container .ds-test-header .ds-test-title,
html.light-mode .test-container .ds-test-header .module-title,
html.light-mode .test-container .bfp-card-header .ds-test-title,
html.light-mode .test-container .bfp-card-header .module-title,
html.light-mode .ds-main-inner .ds-test-header .ds-test-title {
  color: #FFFFFF !important;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.25) !important;
  font-size: 18px !important;
  font-weight: 800 !important;
  letter-spacing: 1.5px !important;
  text-transform: uppercase !important;
}

html.light-mode .test-container .ds-test-header .ds-test-subtitle,
html.light-mode .test-container .ds-test-header .module-subtitle,
html.light-mode .test-container .bfp-card-header .ds-test-subtitle,
html.light-mode .test-container .bfp-card-header .module-subtitle,
html.light-mode .ds-main-inner .ds-test-header .ds-test-subtitle {
  color: rgba(255, 255, 255, 0.72) !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  margin-top: 4px !important;
  letter-spacing: 0.5px !important;
}

/* Btn-voltar dentro do header — garante visibilidade no fundo escuro */
html.light-mode .test-container .ds-test-header .btn-voltar,
html.light-mode .test-container .bfp-card-header .btn-voltar {
  background: rgba(255, 255, 255, 0.15) !important;
  color: #FFFFFF !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
}
html.light-mode .test-container .ds-test-header .btn-voltar:hover,
html.light-mode .test-container .bfp-card-header .btn-voltar:hover {
  background: rgba(255, 255, 255, 0.25) !important;
}

/* ══════════════════════════════════════════════════════════
   5. ABAS HORIZONTAIS — quando existirem (.ds-tabs / .ds-tab)
   Mantém o estilo do standard-theme.css e adiciona
   contexto de card: fundo cinza suave abaixo do header.
══════════════════════════════════════════════════════════ */
html.light-mode .test-container .ds-test-header + .ds-tabs,
html.light-mode .test-container .bfp-card-header + .ds-tabs {
  background: #F8FAFC !important;
  border-bottom: 2px solid #E2E8F0 !important;
  padding: 0 32px !important;
}

html.light-mode .ds-tabs {
  background: #FAFBFC;
  border-bottom: 2px solid #E2E8F0;
  padding: 0 32px;
}

/* ══════════════════════════════════════════════════════════
   6. SEÇÃO INTERNA — título e texto de apoio
   Padroniza a tipografia e cor em todos os módulos.
══════════════════════════════════════════════════════════ */
html.light-mode .section-title,
html.light-mode .ds-section-title,
html.light-mode .view-title {
  font-family: var(--font, 'Inter', sans-serif) !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  color: #0F172A !important;
  letter-spacing: -0.01em !important;
  margin-bottom: 4px !important;
  line-height: 1.35 !important;
}

html.light-mode .section-desc,
html.light-mode .ds-section-desc,
html.light-mode .view-desc {
  font-family: var(--font, 'Inter', sans-serif) !important;
  font-size: 13px !important;
  color: #64748B !important;
  margin-bottom: 24px !important;
  line-height: 1.55 !important;
}

/* ══════════════════════════════════════════════════════════
   7. ALERTAS NORMATIVOS — banner laranja padronizado
   Aparece logo abaixo do título da seção.
   Cobre todas as variantes de classes existentes nos módulos.
══════════════════════════════════════════════════════════ */
html.light-mode .ds-alert,
html.light-mode .ds-alert-warn,
html.light-mode .alert-warning,
html.light-mode .alert-warn,
html.light-mode .w3-alert-warn,
html.light-mode .norm-warning,
html.light-mode .norma-aviso {
  background: #FFFBEB !important;
  border: 1px solid #FDE68A !important;
  border-left: 4px solid #F59E0B !important;
  border-radius: 10px !important;
  color: #78350F !important;
  font-family: var(--font, 'Inter', sans-serif) !important;
  font-size: 13px !important;
  line-height: 1.6 !important;
  padding: 12px 16px !important;
  margin: 0 0 20px !important;
  display: flex !important;
  align-items: flex-start !important;
  gap: 10px !important;
}

html.light-mode .ds-alert strong,
html.light-mode .alert-warning strong {
  color: #92400E !important;
  font-weight: 700 !important;
}

/* ══════════════════════════════════════════════════════════
   8. CONTEÚDO INTERNO — padding uniforme dentro do card
   Aplica-se à área de formulários e entradas de dados.
══════════════════════════════════════════════════════════ */
html.light-mode .test-body,
html.light-mode .ds-test-body,
html.light-mode .card-body,
html.light-mode .view-content {
  padding: 28px 32px !important;
}

/* ══════════════════════════════════════════════════════════
   9. EXCEÇÃO — LAUDO FINAL (lf-*)
   Mantém header azul próprio, padroniza body e sidebar.
══════════════════════════════════════════════════════════ */
html.light-mode .lf-body {
  background: linear-gradient(160deg, #EFF6FF 0%, #F1F5F9 100%) !important;
  padding: 20px 20px 60px !important;
  gap: 20px !important;
}

html.light-mode .lf-main {
  background: #FFFFFF !important;
  border: 1px solid #E2EEF5 !important;
  border-radius: 16px !important;
  box-shadow:
    0 8px 24px rgba(15, 23, 42, 0.08),
    0 2px 6px  rgba(15, 23, 42, 0.05) !important;
  overflow: hidden !important;
}

html.light-mode .lf-sidebar {
  background: #FFFFFF !important;
  border: 1px solid #E2EEF5 !important;
  border-radius: 14px !important;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06) !important;
}

/* ══════════════════════════════════════════════════════════
   10. EXCEÇÃO — TELAS DE GESTÃO (atendimento, pacientes, etc.)
   Usa .page-layout em vez de .ds-layout.
══════════════════════════════════════════════════════════ */
html.light-mode .page-layout {
  max-width: 1200px !important;
  margin: 0 auto !important;
  padding: 32px 24px 56px !important;
  box-sizing: border-box !important;
}

html.light-mode .page-layout .card {
  background: #FFFFFF !important;
  border: 1px solid #E2EEF5 !important;
  border-radius: 16px !important;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.07) !important;
}

/* ══════════════════════════════════════════════════════════
   11. EXCEÇÃO — SIDEBAR INTERNA DE MÓDULOS (WAIS-III, WISC-IV)
   A sidebar interna do instrumento (nav de subtestes)
   recebe fundo leve para se separar visualmente do conteúdo.
══════════════════════════════════════════════════════════ */
html.light-mode .w3-sidebar {
  background: #FAFBFC !important;
  border-right: 1px solid #E2E8F0 !important;
  box-shadow: 2px 0 8px rgba(15, 23, 42, 0.04) !important;
}

/* ══════════════════════════════════════════════════════════
   12. RODAPÉ / TOOLBAR DE AÇÃO
   Barra de botões no fundo dos cards, padronizada.
══════════════════════════════════════════════════════════ */
html.light-mode .card-footer,
html.light-mode .ds-card-footer,
html.light-mode .action-bar,
html.light-mode .test-footer {
  background: #F8FAFC !important;
  border-top: 1px solid #E2E8F0 !important;
  padding: 16px 32px !important;
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  border-radius: 0 0 20px 20px !important;
}

/* ══════════════════════════════════════════════════════════
   13. PROTEÇÃO — laudos e PDFs
   As áreas de impressão NÃO herdam o layout de card.
══════════════════════════════════════════════════════════ */
html.light-mode #laudo-content,
html.light-mode #preview,
html.light-mode .report-body {
  background: #FFFFFF;
  border-radius: 0;
  box-shadow: none;
  max-width: none;
  padding: inherit;
  margin: 0;
}

/* ══════════════════════════════════════════════════════════
   14. RESPONSIVIDADE
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  html.light-mode .ds-layout,
  html.light-mode .et-layout,
  html.light-mode .app-layout,
  html.light-mode .pid-layout,
  html.light-mode .ds-layout-page,
  html.light-mode .w3-layout,
  html.light-mode .w4-layout {
    padding: 12px 8px 40px !important;
  }

  html.light-mode .ds-main,
  html.light-mode .ds-layout-page > .ds-main-inner,
  html.light-mode .w3-main,
  html.light-mode .w4-main {
    max-width: 100% !important;
  }

  html.light-mode .test-container {
    border-radius: 14px !important;
  }

  html.light-mode .ds-test-header,
  html.light-mode .bfp-card-header {
    padding: 18px 20px 16px !important;
  }

  html.light-mode .test-body,
  html.light-mode .ds-test-body {
    padding: 20px 16px !important;
  }

  html.light-mode .card-footer,
  html.light-mode .test-footer {
    padding: 14px 16px !important;
    border-radius: 0 0 14px 14px !important;
  }

  html.light-mode .page-layout {
    padding: 16px 12px 40px !important;
  }
}

/* ══════════════════════════════════════════════════════════
   15. WRAPPERS INTERNOS — RESET DE PADDING
   Cada módulo tem um wrapper interno entre ds-main e
   test-container (ex: .bai-main, .bdi-main, .tea-main).
   Zeramos o padding horizontal desses wrappers para que o
   test-container use a largura total do ds-main.
   O espaço visual entre o card e a borda da tela vem
   exclusivamente do padding do ds-layout (seção 1).
══════════════════════════════════════════════════════════ */
html.light-mode .bai-main,
html.light-mode .bdi-main,
html.light-mode .bpa-main,
html.light-mode .srs2-main,
html.light-mode .ravlt-main-view,
html.light-mode .tdah-main,
html.light-mode .tea-main,
html.light-mode .et-main,
html.light-mode .ana-main {
  padding: 0 !important;
  margin: 0 !important;
  flex: 1 !important;
  max-width: none !important;
}

/* .test-container: nunca ter margin ou max-width inline
   O ds-main já cuida do tamanho e centralização. */
html.light-mode .test-container {
  margin: 0 !important;
  max-width: none !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

/* ══════════════════════════════════════════════════════════
   16. PÁGINAS SEM ds-layout (CPT, MTCD, MWCST)
   Nessas páginas o .test-container é filho direto do body.
   O wrapper .ds-layout-page funciona como substituto.
══════════════════════════════════════════════════════════ */
html.light-mode .ds-layout-page {
  background: linear-gradient(160deg, #EFF6FF 0%, #F1F5F9 55%, #F0F4F8 100%) !important;
  padding: 28px 20px 56px !important;
  min-height: 100vh !important;
  box-sizing: border-box !important;
}

html.light-mode .ds-layout-page > .ds-main-inner {
  max-width: 1200px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  width: 100% !important;
}

@media print {
  html.light-mode .ds-layout,
  html.light-mode .ds-main,
  html.light-mode .test-container {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    max-width: none !important;
    border-radius: 0 !important;
  }
}
