/* ===================================================
   NCLI TYPING MASTER - PRINT STYLES
   Phase 1-8: Certificate Printing & PDF Export
=================================================== */

@media print {
  /* Hide interactive elements */
  .tp-tabs-wrapper,
  .tp-tab,
  .practice-buttons,
  .game-controls,
  .coding-buttons,
  .filter-btn,
  .btn-primary,
  .btn-outline,
  .header,
  .footer,
  header,
  footer,
  nav {
    display: none !important;
  }

  /* Page setup */
  @page {
    size: A4;
    margin: 0;
  }

  body {
    background: #fff;
    color: #000;
  }

  /* Certificate visual styling now lives in css/typing.css (applies to print
     too). Keep only print color fidelity + A4 sizing here. */
  .certificate-page {
    page-break-after: avoid;
    width: 100%;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Statistics Print */
  .stats-print {
    page-break-after: always;
    padding: 40px;
  }

  .stats-print h1 {
    font-size: 28px;
    margin-bottom: 20px;
    text-align: center;
  }

  .stats-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
  }

  .stats-table th,
  .stats-table td {
    border: 1px solid #e2e8f0;
    padding: 12px;
    text-align: left;
  }

  .stats-table th {
    background: #f8fafc;
    font-weight: 700;
    color: #0f172a;
  }

  .stats-table td {
    color: #475569;
  }

  /* Progress Report Print */
  .progress-report {
    page-break-after: always;
    padding: 40px;
  }

  .progress-report h1 {
    font-size: 28px;
    margin-bottom: 20px;
  }

  .progress-section {
    margin-bottom: 30px;
  }

  .progress-section h2 {
    font-size: 18px;
    color: #0f172a;
    margin-bottom: 12px;
    border-bottom: 2px solid #2563eb;
    padding-bottom: 8px;
  }

  .progress-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
  }

  .progress-item-name {
    font-weight: 600;
    color: #0f172a;
  }

  .progress-item-value {
    color: #2563eb;
    font-weight: 700;
  }

  /* Dashboard Print */
  .dashboard-print {
    page-break-after: always;
    padding: 40px;
  }

  .dashboard-print h1 {
    font-size: 28px;
    margin-bottom: 30px;
    text-align: center;
  }

  .dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 30px;
  }

  .dashboard-card {
    border: 2px solid #e2e8f0;
    padding: 20px;
    border-radius: 8px;
  }

  .dashboard-card h3 {
    font-size: 14px;
    color: #475569;
    margin-bottom: 10px;
  }

  .dashboard-card-value {
    font-size: 24px;
    font-weight: 800;
    color: #2563eb;
  }

  /* Common Print Styles */
  .print-title {
    font-size: 28px;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 20px;
    text-align: center;
  }

  .print-date {
    text-align: right;
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 20px;
  }

  .print-footer {
    text-align: center;
    font-size: 12px;
    color: #94a3b8;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
  }

  /* Override responsive styles for print */
  .tp-panels-container {
    display: block;
  }

  .tp-panel {
    display: block !important;
    page-break-after: always;
    padding: 0;
  }

  .container {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  /* Links in print */
  a {
    text-decoration: underline;
  }

  a[href]:after {
    content: none;
  }

  /* Code styling for print */
  code,
  pre {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
  }

  /* Table of contents */
  .toc {
    page-break-after: always;
  }

  .toc ul {
    list-style: none;
    padding-left: 0;
  }

  .toc li {
    margin-bottom: 10px;
  }

  .toc a {
    color: #0f172a;
    text-decoration: none;
  }

  .toc a:after {
    content: none;
  }

  /* Ensure no widows or orphans */
  p,
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    orphans: 3;
    widows: 3;
  }

  /* Print-safe colors */
  .no-print {
    display: none !important;
  }

  .print-only {
    display: block !important;
  }

  /* ===== Certificate-only printing =====
     When a certificate is being printed, hide everything else
     so the print output is just the certificate (not all panels). */
  body.printing-certificate * {
    visibility: hidden !important;
  }

  body.printing-certificate #certificateModal,
  body.printing-certificate #certificateModal * {
    visibility: visible !important;
  }

  body.printing-certificate #certificateModal {
    position: absolute;
    inset: 0;
    display: block !important;
    background: #fff;
    padding: 0;
    overflow: visible;
  }

  body.printing-certificate .certificate-modal-actions {
    display: none !important;
  }

  body.printing-certificate .certificate-page {
    page-break-after: avoid;
  }
}
