/* Estilos de impressão global para relatórios */
@media print {
  /* Reset básico para impressão */
  * {
    -webkit-print-color-adjust: exact !important;
    color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Ocultar elementos desnecessários para impressão */
  nav,
  .navigation,
  .sidebar,
  .header-buttons,
  .modal-backdrop,
  .scroll-button,
  .pagination,
  button:not(.print-button),
  .btn:not(.print-button),
  .floating-button,
  .tooltip,
  .dropdown-menu {
    display: none !important;
  }

  /* Layout da página */
  body {
    margin: 0;
    padding: 15px;
    font-size: 11pt;
    line-height: 1.4;
    color: black;
    background: white;
    overflow: visible !important;
  }

  /* Remover scroll e overflow */
  html,
  body,
  #root {
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
  }

  /* Containers e wrappers */
  .container,
  .wrapper,
  .main-content {
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
  }

  /* Configurações da página */
  @page {
    margin: 0.75in;
    size: A4;
  }

  /* Quebras de página */
  .page-break-before {
    page-break-before: always;
  }

  .page-break-after {
    page-break-after: always;
  }

  .avoid-break {
    page-break-inside: avoid;
  }

  /* Tabelas de relatório */
  table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin-bottom: 1rem;
    font-size: 10pt;
  }

  table th,
  table td {
    border: 1px solid #333 !important;
    padding: 6px 8px !important;
    text-align: left;
    background-color: white !important;
  }

  table thead th {
    background-color: #f5f5f5 !important;
    font-weight: bold;
    color: black !important;
  }

  /* Tabela de legenda do histograma - remover bordas */
  .histograma-legenda,
  .histograma-legenda th,
  .histograma-legenda td {
    border: none !important;
  }

  /* Cards de relatório */
  .relatorio-card {
    border: 1px solid #333 !important;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background: white !important;
    page-break-inside: avoid;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
  }

  /* Cards específicos */
  [class*='CardRelatorio'] {
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    margin-bottom: 0.5rem !important;
    padding: 0.5rem !important;
  }

  .relatorio-card h1,
  .relatorio-card h2,
  .relatorio-card h3,
  .relatorio-card h4 {
    color: black !important;
    margin-top: 0;
    margin-bottom: 0.5rem;
  }

  /* Gráficos e elementos visuais */
  .chart-container,
  .recharts-wrapper {
    max-height: 200px !important;
    overflow: visible !important;
    page-break-inside: avoid;
  }

  .chart-container svg,
  .recharts-wrapper svg {
    background: white !important;
    max-height: 200px !important;
  }

  /* Esconder gráficos muito complexos na impressão */
  .recharts-responsive-container {
    max-height: 200px !important;
    overflow: hidden !important;
  }

  /* Títulos e cabeçalhos */
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    color: black !important;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    page-break-after: avoid;
  }

  /* Valores numéricos destacados */
  .valor-destaque {
    font-size: 14pt !important;
    font-weight: bold !important;
    color: black !important;
  }

  /* Filtros e informações do relatório */
  .relatorio-info {
    display: block !important;
    border-bottom: 2px solid #333;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    page-break-after: avoid;
  }

  .filtros-aplicados {
    font-size: 9pt;
    color: #666 !important;
    margin-bottom: 1rem;
  }

  /* Links */
  a {
    color: black !important;
    text-decoration: none !important;
  }

  a::after {
    content: ' (' attr(href) ')';
    font-size: 8pt;
    color: #666;
  }

  /* Remover sombras e efeitos visuais */
  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  /* Ajustes para modais em impressão */
  .modal {
    position: static !important;
    display: block !important;
    width: 100% !important;
    height: auto !important;
    background: white !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .modal-content {
    background: white !important;
    border: none !important;
    box-shadow: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .modal-header {
    border-bottom: 2px solid #333 !important;
    background: white !important;
    padding-bottom: 0.5rem !important;
  }

  .modal-body {
    padding: 1rem 0 !important;
  }

  /* Melhorar legibilidade de textos pequenos */
  .small-text {
    font-size: 9pt !important;
  }

  /* Formatação para dados tabulares */
  .data-table {
    width: 100% !important;
    font-size: 9pt !important;
  }

  .data-table th {
    background-color: #e9ecef !important;
    color: black !important;
    font-weight: bold !important;
    text-align: center !important;
  }

  .data-table td {
    text-align: center !important;
  }

  /* Rodapé da página */
  .print-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    font-size: 8pt;
    text-align: center;
    border-top: 1px solid #333;
    padding-top: 0.5rem;
    background: white;
  }

  /* Numeração de páginas */
  .page-number::after {
    content: 'Página ' counter(page) ' de ' counter(pages);
  }
}

/* Estilos específicos para componentes de relatório quando estão sendo impressos */
@media print {
  .relatorio-dashboard {
    display: block !important;
    width: 100% !important;
  }

  .relatorio-grid {
    display: block !important;
    grid-template-columns: none !important;
  }

  .relatorio-grid-item {
    width: 100% !important;
    margin-bottom: 0.5rem !important;
    page-break-inside: avoid;
  }

  /* Grid layout específico */
  [class*='Grid'] {
    display: block !important;
    grid-template-columns: none !important;
    gap: 0.5rem !important;
  }

  [class*='GridItem'] {
    width: 100% !important;
    margin-bottom: 0.5rem !important;
    page-break-inside: avoid;
  }

  /* Layout compacto para cards */
  .grid-2-columns {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
  }

  .grid-3-columns {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr !important;
    gap: 0.5rem !important;
  }

  /* Subtítulos de seção */
  .subtitulo {
    font-size: 14pt !important;
    font-weight: bold !important;
    color: black !important;
    margin: 1rem 0 0.5rem 0 !important;
    page-break-after: avoid;
    border-bottom: 1px solid #ccc;
    padding-bottom: 0.25rem;
  }

  /* Layout principal da página */
  .relatorio-dashboard {
    display: block !important;
    width: 100% !important;
    overflow: visible !important;
  }

  /* VBox e HBox containers */
  [class*='VBox'],
  [class*='HBox'] {
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
  }

  /* Valores destacados em cards */
  .card-value {
    font-size: 16pt !important;
    font-weight: bold !important;
    color: #000 !important;
    text-align: center !important;
  }

  /* Reset final para evitar problemas de overflow */
  * {
    overflow: visible !important;
    max-height: none !important;
  }

  /* Exceções específicas para elementos que precisam de controle de altura */
  .chart-container,
  .recharts-wrapper,
  .recharts-responsive-container {
    max-height: 200px !important;
    overflow: hidden !important;
  }

  /* Força altura automática em todos os containers principais */
  .main-content,
  .page-content,
  .layout-content,
  [class*='Layout'],
  [class*='Container'] {
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
}

@media print {
  .recharts-legend-wrapper {
    width: calc(100%) !important;
    height: auto !important;
  }

  .chart-container {
    height: auto !important;
  }

  .recharts-legend-item > svg {
    width: auto !important;
    display: inline-block !important;
    right: inherit !important;
    line-height: inherit !important;
  }
}
