/* Print Optimization Styles */

@media print {
  /* Hide non-printable elements */
  nav,
  aside,
  .no-print,
  button:not(.print-button),
  .sidebar,
  .header-actions,
  .modal-close,
  .toast,
  .notification {
    display: none !important;
  }

  /* Page setup */
  @page {
    size: A4;
    margin: 1.5cm;
  }

  /* Body */
  body {
    background: white !important;
    color: black !important;
    font-size: 12pt;
    line-height: 1.5;
  }

  /* Typography */
  h1 {
    font-size: 24pt;
    margin-bottom: 12pt;
    page-break-after: avoid;
  }

  h2 {
    font-size: 18pt;
    margin-top: 12pt;
    margin-bottom: 8pt;
    page-break-after: avoid;
  }

  h3 {
    font-size: 14pt;
    margin-top: 8pt;
    margin-bottom: 6pt;
    page-break-after: avoid;
  }

  /* Tables */
  table {
    width: 100%;
    border-collapse: collapse;
    page-break-inside: avoid;
  }

  th,
  td {
    border: 1px solid #ddd;
    padding: 8pt;
    text-align: left;
  }

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

  /* Cards */
  .card {
    border: 1px solid #ddd;
    padding: 12pt;
    margin-bottom: 12pt;
    page-break-inside: avoid;
  }

  /* Prescription specific */
  .prescription-header {
    border-bottom: 2px solid #000;
    padding-bottom: 12pt;
    margin-bottom: 12pt;
  }

  .prescription-rx {
    font-size: 48pt;
    color: #2563eb;
    margin: 12pt 0;
  }

  .prescription-medication {
    margin-bottom: 8pt;
    padding: 8pt;
    border-left: 3px solid #2563eb;
  }

  .prescription-footer {
    margin-top: 24pt;
    border-top: 1px solid #ddd;
    padding-top: 12pt;
  }

  /* Bill/Receipt specific */
  .bill-header {
    text-align: center;
    margin-bottom: 24pt;
  }

  .bill-items {
    margin: 12pt 0;
  }

  .bill-total {
    font-size: 14pt;
    font-weight: bold;
    border-top: 2px solid #000;
    padding-top: 8pt;
    margin-top: 8pt;
  }

  /* Report specific */
  .report-summary {
    background-color: #f5f5f5 !important;
    padding: 12pt;
    margin-bottom: 12pt;
  }

  .report-chart {
    page-break-inside: avoid;
    margin: 12pt 0;
  }

  /* Page breaks */
  .page-break {
    page-break-after: always;
  }

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

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

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

  a[href]:after {
    content: " (" attr(href) ")";
    font-size: 10pt;
    color: #666;
  }

  /* Images */
  img {
    max-width: 100%;
    page-break-inside: avoid;
  }

  /* Badges and labels */
  .badge {
    border: 1px solid #000;
    padding: 2pt 6pt;
    border-radius: 3pt;
  }

  /* Signature area */
  .signature-area {
    margin-top: 48pt;
    border-top: 1px solid #000;
    padding-top: 8pt;
    width: 200pt;
  }

  /* Footer */
  .print-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 10pt;
    color: #666;
    border-top: 1px solid #ddd;
    padding-top: 8pt;
  }

  /* QR Code */
  .qr-code {
    page-break-inside: avoid;
  }

  /* Watermark */
  .watermark {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 72pt;
    color: rgba(0, 0, 0, 0.05);
    z-index: -1;
  }

  /* Clinical photos */
  .clinical-photo {
    max-width: 300pt;
    max-height: 300pt;
    page-break-inside: avoid;
    margin: 12pt auto;
    display: block;
  }

  /* Lab results */
  .lab-result-abnormal {
    font-weight: bold;
    color: #dc2626 !important;
  }

  /* Vital signs */
  .vitals-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8pt;
  }

  /* EMR timeline */
  .timeline-item {
    page-break-inside: avoid;
    margin-bottom: 12pt;
    padding-left: 24pt;
    border-left: 2px solid #ddd;
  }

  /* Certificate */
  .certificate-border {
    border: 3px double #000;
    padding: 24pt;
    page-break-inside: avoid;
  }

  .certificate-seal {
    width: 80pt;
    height: 80pt;
    border: 2px solid #000;
    border-radius: 50%;
    margin: 12pt auto;
  }
}

/* Print button styling (visible on screen, hidden in print) */
@media screen {
  .print-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
  }
}
