/* ============================================================
   PRINT.CSS — Estilos de Impressão / Exportação
   Think LAB — Laboratório Dinâmico de Empresas
   ============================================================ */

@media print {
  /* ── PAGE SETUP ── */
  @page {
    size: A4 portrait;
    margin: 18mm 15mm 15mm;
  }

  @page :first {
    margin-top: 25mm;
  }

  /* ── RESET FOR PRINT ── */
  *, *::before, *::after {
    box-sizing: border-box;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  html, body {
    background: #ffffff !important;
    color: #1c1c2e !important;
    font-size: 11pt;
    font-family: 'Segoe UI', Arial, sans-serif;
    line-height: 1.5;
    margin: 0;
    padding: 0;
  }

  /* ── HIDE NAVIGATION / UI CHROME ── */
  #topbar,
  #sidebar,
  #sidebar-overlay,
  #app-footer,
  #toast-container,
  .tab-bar,
  .page-actions,
  .btn,
  .btn-primary,
  .btn-danger,
  .btn-ghost,
  .btn-process,
  .no-print,
  .modal-overlay,
  .spinner-overlay,
  .explain-link,
  .sidebar-link { display: none !important; }

  /* ── RELATÓRIOS EM ABAS: imprime/exporta TODAS as abas (a barra de abas já é ocultada acima) ── */
  .report-panels > .tab-panel { display: block !important; }

  /* ── LAYOUT RESET ── */
  #screen-app { display: block !important; }
  #main-content {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }
  .panel { display: block !important; animation: none !important; }
  .panel:not(.active) { display: none !important; }

  /* ── PRINT HEADER (company + round) ── */
  .print-header {
    display: flex !important;
    align-items: flex-start;
    justify-content: space-between;
    border-bottom: 3pt solid #1a237e;
    padding-bottom: 10pt;
    margin-bottom: 14pt;
  }

  .print-header-logo {
    font-size: 18pt;
    font-weight: 900;
    color: #1a237e;
    letter-spacing: -0.5pt;
    line-height: 1;
  }
  .print-header-logo span { color: #f57c00; }

  .print-header-meta {
    text-align: right;
    font-size: 9pt;
    color: #6b7280;
    line-height: 1.6;
  }
  .print-header-meta strong { color: #1c1c2e; font-size: 10pt; display: block; }

  /* ── PAGE TITLE ── */
  .page-title {
    font-size: 16pt;
    font-weight: 800;
    color: #1a237e;
    margin-bottom: 4pt;
    page-break-after: avoid;
  }
  .page-subtitle {
    font-size: 10pt;
    color: #6b7280;
    margin-bottom: 14pt;
  }

  /* ── CARDS ── */
  .card {
    background: #fff !important;
    border: 1pt solid #e2e8f0 !important;
    border-radius: 4pt !important;
    box-shadow: none !important;
    break-inside: avoid;
    margin-bottom: 12pt;
    overflow: visible;
  }

  .card-header {
    background: transparent !important;
    border-bottom: 1pt solid #e2e8f0 !important;
    padding: 8pt 10pt 6pt !important;
  }

  .card-title {
    font-size: 10pt !important;
    font-weight: 700 !important;
    color: #1a237e !important;
  }

  .card-body { padding: 10pt !important; }

  .card-accent-top { border-top: 3pt solid #1a237e !important; }
  .card-accent-success { border-top: 3pt solid #2e7d32 !important; }
  .card-accent-danger  { border-top: 3pt solid #c62828 !important; }
  .card-accent-gold    { border-top: 3pt solid #c9a227 !important; }

  /* ── KPI GRID ── */
  .kpi-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 8pt !important;
    margin-bottom: 12pt !important;
  }

  .kpi-card {
    padding: 8pt 10pt !important;
    border: 1pt solid #e2e8f0 !important;
    box-shadow: none !important;
    break-inside: avoid;
    transform: none !important;
  }

  .kpi-card::before {
    height: 2pt !important;
  }

  .kpi-label {
    font-size: 7pt !important;
    letter-spacing: 0.05em;
  }

  .kpi-value {
    font-size: 14pt !important;
    font-weight: 800 !important;
  }

  .kpi-delta { font-size: 8pt !important; }
  .kpi-icon { display: none !important; }

  /* ── CHARTS ── */
  .chart-container {
    height: 200pt !important;
    max-height: 200pt;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .charts-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10pt !important;
  }

  /* ── TABLES ── */
  table { font-size: 9pt !important; }

  thead th {
    background-color: #1a237e !important;
    color: #ffffff !important;
    padding: 5pt 8pt !important;
    font-size: 8pt !important;
  }

  tbody td { padding: 4pt 8pt !important; }
  tbody tr:hover td { background: transparent !important; }
  tfoot td { padding: 5pt 8pt !important; font-size: 9pt !important; }

  /* ── DRE TABLE ── */
  .dre-table { font-size: 9pt !important; }
  .dre-table th {
    background-color: #1a237e !important;
    color: #fff !important;
    padding: 5pt 8pt !important;
    font-size: 8pt !important;
  }
  .dre-table td { padding: 4pt 8pt !important; }
  .dre-table tr.total-row td {
    background-color: #f0f2f8 !important;
    font-weight: 800 !important;
  }
  .dre-table tr.grand-total td {
    background-color: #e8eaf2 !important;
    color: #1a237e !important;
    font-weight: 800 !important;
    font-size: 10pt !important;
  }
  .dre-table tr.section-header td {
    background-color: rgba(57,73,171,0.08) !important;
    color: #1a237e !important;
    font-weight: 700 !important;
    font-size: 8pt !important;
  }

  /* ── PESTEL TABLE ── */
  .pestel-table th {
    background-color: #1a237e !important;
    color: #fff !important;
  }

  /* ── RANKING ── */
  .ranking-row { padding: 5pt 8pt !important; font-size: 9pt !important; }
  .ranking-position { width: 22pt !important; height: 22pt !important; font-size: 8pt !important; }
  .ranking-bar-container { display: none !important; }

  /* ── ALERTS / BADGES ── */
  .alert { font-size: 9pt !important; padding: 6pt 8pt !important; }
  .badge { font-size: 7pt !important; }

  /* ── PROGRESS BARS ── */
  .progress { height: 5pt !important; }

  /* ── PAGE BREAKS ── */
  .page-break-before { page-break-before: always; break-before: page; }
  .page-break-after  { page-break-after: always; break-after: page; }
  .no-break { page-break-inside: avoid; break-inside: avoid; }

  /* ── DECISION FORM — hide in print ── */
  #panel-decisions,
  #panel-admin { display: none !important; }

  /* ── COLORS FOR PRINT ── */
  .text-success,
  .positive  { color: #1b5e20 !important; }

  .text-danger,
  .negative  { color: #b71c1c !important; }

  .text-primary { color: #1a237e !important; }
  .text-muted   { color: #6b7280 !important; }

  /* ── FOOTER ── */
  .print-footer {
    display: block !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    border-top: 1pt solid #e2e8f0;
    padding: 4pt 15mm;
    font-size: 8pt;
    color: #9ca3af;
    display: flex;
    justify-content: space-between;
  }
}

/* ── PRINT-SPECIFIC HELPER CLASSES (also for screen "preview") ── */
.print-only {
  display: none;
}

@media print {
  .print-only { display: block !important; }
  .screen-only { display: none !important; }
}

/* ── PRINT PREVIEW OVERLAY (screen) ── */
.print-preview {
  background: #fff;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  max-width: 800px;
  margin: 0 auto;
}

.print-company-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid #1a237e;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.print-company-header .logo {
  font-size: 1.8rem;
  font-weight: 900;
  color: #1a237e;
  letter-spacing: -1px;
}
.print-company-header .logo span { color: #f57c00; }

.print-company-header .meta {
  text-align: right;
  font-size: 0.8rem;
  color: #6b7280;
  line-height: 1.7;
}
.print-company-header .meta strong { color: #1c1c2e; display: block; font-size: 0.9rem; }

.print-report-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: #1a237e;
  margin-bottom: 0.25rem;
}

.print-report-subtitle {
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 1.5rem;
}
