/* ═══════════════════════════════════════════════════════════════
   Azteyalytics — print.css
   Print / PDF export (window.print())
   ═══════════════════════════════════════════════════════════════ */

@media print {
  /* ── Page setup ──────────────────────────────────────────────── */
  @page {
    size: A4 portrait;
    margin: 18mm 16mm;
  }

  /* ── Color adjustments ───────────────────────────────────────── */
  :root {
    --color-bg:       #ffffff;
    --color-surface:  #f8f9fa;
    --color-surface-2:#f0f2f5;
    --color-border:   #dee2e6;
    --color-text:     #212529;
    --color-text-muted:#6c757d;
    --color-text-dim: #adb5bd;
    --color-accent:   #4a5cd4;
    --color-success:  #198754;
    --color-warn:     #fd7e14;
    --color-error:    #dc3545;
  }

  body {
    background: #fff !important;
    color: #212529 !important;
    font-size: 11pt;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* ── Hide non-print elements ─────────────────────────────────── */
  .az-header,
  .az-hero,
  #scanForm,
  #progressSection,
  .az-tabs,
  #btnScan,
  #btnPrint,
  #btnExportJson,
  #btnRetry,
  .az-footer,
  .az-data-notice,
  [hidden],
  dialog {
    display: none !important;
  }

  /* ── Show all tab panels ─────────────────────────────────────── */
  .az-tab-panel {
    display: block !important;
    hidden: false !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* ── Score card ──────────────────────────────────────────────── */
  .az-score-card {
    border: 2px solid var(--color-border);
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 16pt;
  }

  /* ── Cards ───────────────────────────────────────────────────── */
  .az-card {
    border: 1px solid var(--color-border);
    break-inside: avoid;
    page-break-inside: avoid;
    box-shadow: none;
    margin-bottom: 10pt;
  }

  /* ── Tables ──────────────────────────────────────────────────── */
  .az-table th, .az-table td {
    border: 1px solid #dee2e6;
    padding: 5pt 8pt;
  }
  .az-table { font-size: 9pt; }

  /* ── Section breaks between tab panels ──────────────────────── */
  #tab-perf, #tab-content, #tab-keywords, #tab-aeo, #tab-links, #tab-intel, #tab-recs {
    page-break-before: always;
    break-before: page;
  }

  /* ── Badges ──────────────────────────────────────────────────── */
  .az-badge {
    border: 1px solid currentColor;
    padding: 1pt 4pt;
  }

  /* ── Recommendations ─────────────────────────────────────────── */
  .az-rec {
    border-left: 3pt solid var(--color-border);
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .az-rec--critical { border-left-color: #dc3545 !important; }
  .az-rec--high     { border-left-color: #fd7e14 !important; }
  .az-rec--medium   { border-left-color: #0dcaf0 !important; }
  .az-rec--low      { border-left-color: #adb5bd !important; }

  /* ── Print header (added via CSS ::before) ───────────────────── */
  #resultsSection::before {
    content: "Azteyalytics — Informe SEO · " attr(data-url) " · " attr(data-generated);
    display: block;
    font-size: 9pt;
    color: #6c757d;
    border-bottom: 1pt solid #dee2e6;
    padding-bottom: 6pt;
    margin-bottom: 12pt;
  }

  /* ── Links ───────────────────────────────────────────────────── */
  a::after {
    content: " (" attr(href) ")";
    font-size: 8pt;
    color: #6c757d;
  }
  .az-logo a::after, .btn::after { content: none; }

  /* ── Metric grid ─────────────────────────────────────────────── */
  .az-metric-grid { grid-template-columns: repeat(3, 1fr); }

  /* ── Chart areas — hide echarts, show text fallback ─────────── */
  .az-chart, [id="gaugeChart"] { display: none !important; }
}
