/* ═══════════════════════════════════════════════════════════════
   PREMIUM REPORT — Professional Medical PDF Enhancement
   Additive only — enhances existing @media print styles
   ═══════════════════════════════════════════════════════════════ */

@media print {

  /* ── Page Setup ── */
  @page {
    size: A4;
    margin: 18mm 15mm 22mm 15mm;
  }
  @page :first {
    margin-top: 12mm;
  }

  /* ── Premium Typography ── */
  .rpt-page {
    font-family: 'IBM Plex Sans Arabic', 'Segoe UI', 'Helvetica Neue', sans-serif !important;
    font-size: 10pt !important;
    line-height: 1.65 !important;
    color: #0f172a !important;
  }
  .rpt-page.sv, .rpt-page.en {
    font-family: 'Segoe UI', 'Helvetica Neue', 'Arial', sans-serif !important;
  }

  /* ── Enhanced Page Header ── */
  .rpt-ph {
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    border-bottom: 3px solid #1e40af !important;
    padding-bottom: 16px !important;
    margin-bottom: 24px !important;
    position: relative !important;
  }
  /* Gradient accent line under header */
  .rpt-ph::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
  }
  .rpt-ph-title {
    font-size: 16pt !important;
    font-weight: 800 !important;
    color: #0f172a !important;
    letter-spacing: -0.02em !important;
  }
  .rpt-ph-meta {
    font-size: 8pt !important;
    color: #475569 !important;
    line-height: 1.9 !important;
  }

  /* ── Section Headers — Color-coded left border ── */
  .rpt-sec h3 {
    font-size: 11pt !important;
    font-weight: 800 !important;
    color: #0f172a !important;
    border-bottom: none !important;
    border-right: 4px solid #3b82f6 !important;
    padding: 6px 12px 6px 0 !important;
    margin-bottom: 14px !important;
    background: linear-gradient(90deg, transparent, #eff6ff) !important;
    border-radius: 0 8px 8px 0 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
  }
  /* Color-code different sections */
  .rpt-sec:nth-child(odd) h3 {
    border-right-color: #3b82f6 !important;
    background: linear-gradient(90deg, transparent, #eff6ff) !important;
  }
  .rpt-sec:nth-child(even) h3 {
    border-right-color: #8b5cf6 !important;
    background: linear-gradient(90deg, transparent, #f5f3ff) !important;
  }

  /* LTR sections */
  .rpt-page.sv .rpt-sec h3,
  .rpt-page.en .rpt-sec h3 {
    border-right: none !important;
    border-left: 4px solid #3b82f6 !important;
    padding: 6px 0 6px 12px !important;
    background: linear-gradient(270deg, transparent, #eff6ff) !important;
    border-radius: 8px 0 0 8px !important;
  }

  /* ── Lab Result Cards — Premium ── */
  .rpt-cell {
    border: 1px solid #e2e8f0 !important;
    border-radius: 10px !important;
    padding: 10px 12px !important;
    background: #fafbfd !important;
    position: relative !important;
    overflow: hidden !important;
  }
  .rpt-cell::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background: #94a3b8;
    border-radius: 0 10px 10px 0;
  }
  .rpt-cell.ok::before { background: #22c55e !important; }
  .rpt-cell.warn::before { background: #f59e0b !important; }

  .rpt-cell .rc-name {
    font-size: 7pt !important;
    color: #64748b !important;
    text-transform: uppercase !important;
    letter-spacing: 0.03em !important;
  }
  .rpt-cell .rc-ar {
    font-size: 8pt !important;
    color: #1e293b !important;
    font-weight: 700 !important;
  }
  .rpt-cell .rc-val {
    font-size: 12pt !important;
    font-weight: 800 !important;
    font-family: 'JetBrains Mono', 'Consolas', monospace !important;
  }
  .rpt-cell .rc-ref {
    font-size: 6.5pt !important;
    color: #94a3b8 !important;
    font-family: 'JetBrains Mono', monospace !important;
  }

  /* ── Warning Flags — Premium ── */
  .rpt-flag2 {
    border-radius: 10px !important;
    border: 1px solid #fbbf24 !important;
    border-right: 5px solid #f59e0b !important;
    background: linear-gradient(90deg, #fffbeb, #fef3c7) !important;
    padding: 10px 16px !important;
    box-shadow: 0 2px 8px rgba(245,158,11,0.08) !important;
  }
  .rpt-flag2.bad {
    border-color: #fca5a5 !important;
    border-right-color: #ef4444 !important;
    background: linear-gradient(90deg, #fef2f2, #fee2e2) !important;
    box-shadow: 0 2px 8px rgba(239,68,68,0.08) !important;
  }

  /* ── Summary Box — Premium gradient ── */
  .rpt-summary-box {
    border: 1px solid #93c5fd !important;
    border-right: 6px solid #2563eb !important;
    border-radius: 14px !important;
    padding: 18px 20px !important;
    background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%) !important;
    box-shadow: 0 4px 16px rgba(37,99,235,0.06) !important;
  }
  .rpt-summary-box strong {
    font-size: 11pt !important;
    color: #0f172a !important;
    font-weight: 900 !important;
  }

  /* ── Score Boxes — Rounded premium ── */
  .rpt-score-box {
    border-radius: 12px !important;
    padding: 12px 16px !important;
    background: #f8fafc !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04) !important;
  }
  .rpt-score-box .rsb-val {
    font-size: 14pt !important;
    font-weight: 900 !important;
    font-family: 'JetBrains Mono', monospace !important;
  }

  /* ── Medication List — Premium ── */
  .rpt-med-list li {
    position: relative !important;
    padding: 8px 20px 8px 0 !important;
    border-bottom: 1px solid #f1f5f9 !important;
  }
  .rpt-med-list li::before {
    content: '💊';
    position: absolute;
    right: 0;
    font-size: 8pt;
  }
  .rpt-med-purpose {
    font-size: 7pt !important;
    font-weight: 800 !important;
    background: #eff6ff !important;
    border: 1px solid #bfdbfe !important;
  }

  /* ── Vital Cards — Premium ── */
  .rpt-vital-card {
    border-radius: 14px !important;
    padding: 14px 16px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03) !important;
  }
  .rpt-vital-value {
    font-size: 13pt !important;
    font-family: 'JetBrains Mono', monospace !important;
  }

  /* ── Signal Rows — Premium ── */
  .rpt-signal-row {
    border-radius: 12px !important;
    padding: 12px 14px !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03) !important;
  }
  .rpt-signal-icon {
    font-size: 12pt !important;
  }

  /* ── Conclusion Box — Premium ── */
  .rpt-conclusion-box {
    border-radius: 14px !important;
    padding: 16px 18px !important;
    background: linear-gradient(135deg, #fff7ed 0%, #ffffff 100%) !important;
    box-shadow: 0 4px 16px rgba(234,88,12,0.06) !important;
  }

  /* ── Disclaimer — Professional ── */
  .rpt-disclaimer2 {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 10px !important;
    padding: 12px 16px !important;
    font-size: 7pt !important;
    color: #64748b !important;
  }

  /* ── Footer — Professional ── */
  .rpt-footer2 {
    border-top: 2px solid #e2e8f0 !important;
    padding-top: 14px !important;
    font-size: 7pt !important;
    color: #94a3b8 !important;
  }

  /* ── Mini Grid Cards — Premium ── */
  .rpt-mini-card {
    border: 1px solid #e2e8f0 !important;
    border-radius: 10px !important;
    padding: 10px 12px !important;
    background: #f8fafc !important;
  }
  .rpt-mini-value {
    font-family: 'JetBrains Mono', monospace !important;
    font-weight: 800 !important;
    font-size: 11pt !important;
  }

  /* ── Better Page Breaks ── */
  .rpt-sec {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  .rpt-summary-box,
  .rpt-conclusion-box {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  .rpt-grid3 {
    page-break-inside: avoid !important;
  }

  /* ── Confidential Watermark (subtle) ── */
  .rpt-page::after {
    content: 'CONFIDENTIAL · Family Health Hub';
    position: fixed;
    bottom: 8mm;
    left: 50%;
    transform: translateX(-50%);
    font-size: 7pt;
    color: #cbd5e1;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-weight: 600;
  }

  /* ── Adherence Section ── */
  .rpt-adherence-box {
    border-radius: 14px !important;
    padding: 14px 16px !important;
  }
  .rpt-adherence-interpret {
    font-size: 10pt !important;
    line-height: 1.6 !important;
  }

  /* ── Details/Expand Sections ── */
  .rpt-details {
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03) !important;
  }
  .rpt-details summary {
    font-size: 9pt !important;
    padding: 10px 14px !important;
  }
  .rpt-details[open] summary {
    border-bottom: 1px solid #bfdbfe !important;
  }

  /* ── List Rows ── */
  .rpt-list-row {
    padding: 8px 12px !important;
    border-bottom: 1px solid #f1f5f9 !important;
    border-radius: 6px !important;
  }
  .rpt-list-row.warn {
    background: #fffbeb !important;
    border-right: 3px solid #f59e0b !important;
  }
  .rpt-list-row.bad {
    background: #fef2f2 !important;
    border-right: 3px solid #ef4444 !important;
  }

  /* ── Narrative ── */
  .rpt-narrative-copy {
    font-size: 9.5pt !important;
    line-height: 1.75 !important;
  }

  /* ── Priority Badges ── */
  .rpt-priority-badge {
    font-size: 7.5pt !important;
    padding: 4px 12px !important;
    border-radius: 20px !important;
    print-color-adjust: exact !important;
  }

  /* ── Table Grid ── */
  .rpt-grid3 {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
  }
  /* Tighter grid on narrow pages */
  @media (max-width: 600px) {
    .rpt-grid3 { grid-template-columns: repeat(2, 1fr) !important; }
  }
}

/* ── Screen-only: Report Preview Enhancement ── */
@media screen {
  .rpt-pages {
    max-width: 900px;
    margin: 0 auto;
  }
  .rpt-page {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  }
  .rpt-ph {
    border-bottom: 2px solid var(--accent);
    padding-bottom: 14px;
    margin-bottom: 20px;
  }
  .rpt-ph-title {
    color: var(--accent2);
  }
  .btn-preview-report,
  .btn-print-report {
    transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  }
  .btn-print-report:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  }
}
