/* MevaMed Print Stylesheet — loaded via <link media="print"> */

@media print {

  /* ── 1. Hide application chrome ── */
  .dashboard-sidebar,
  .dashboard-topbar,
  .hbys-statusbar,
  .app-sidebar,
  .app-topbar,
  .no-print,
  .btn-group-actions,
  .page-shell-search,
  .ui-filter-bar,
  .page-shell-toolbar .ui-filter-bar,
  .dataTables_length,
  .dataTables_filter,
  .dataTables_info,
  .dataTables_paginate,
  .pagination,
  .dropdown-menu,
  [data-bs-toggle="dropdown"],
  .navbar-toggler,
  .sidebar-toggle,
  #sidebarToggle,
  #sidebarToggleMobile,
  #notificationBadge,
  .btn-print-hide,
  footer,
  .toast-container,
  .tooltip,
  .popover {
    display: none !important;
  }

  /* ── 2. Reset layout to full width ── */
  .dashboard-main {
    margin-left: 0 !important;
    width: 100% !important;
  }

  .dashboard-content {
    padding: 0 !important;
  }

  .dashboard-content-inner {
    max-width: 100% !important;
  }

  .dashboard-layout {
    display: block !important;
  }

  .container,
  .container-fluid {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

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

  /* ── 3. Page setup ── */
  @page {
    size: A4;
    margin: 12mm 10mm;
  }

  /* ── 4. Typography ── */
  h1, .ui-page-title { font-size: 14pt !important; }
  h2 { font-size: 12pt !important; }
  h3 { font-size: 11pt !important; }

  .ui-page-header {
    margin-bottom: 8pt !important;
    padding-bottom: 4pt !important;
    border-bottom: 1pt solid #333 !important;
  }

  .ui-page-header .ui-page-actions {
    display: none !important;
  }

  .ui-breadcrumb {
    display: none !important;
  }

  /* ── 5. Cards — flatten for print ── */
  .ui-card-container,
  .ui-form-card,
  .card {
    box-shadow: none !important;
    border: 1pt solid #ccc !important;
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 8pt !important;
  }

  .ui-card-header,
  .ui-form-header,
  .card-header {
    background: #f5f5f5 !important;
    color: #000 !important;
    padding: 4pt 8pt !important;
    font-size: 10pt !important;
  }

  .ui-card-body,
  .ui-form-body,
  .card-body {
    padding: 6pt 8pt !important;
  }

  /* ── 6. Tables — compact and readable ── */
  .ui-table-card,
  .ui-table-layout {
    box-shadow: none !important;
    border: 1pt solid #999 !important;
  }

  .ui-table-header {
    background: #333 !important;
    color: #fff !important;
    padding: 3pt 6pt !important;
    font-size: 10pt !important;
  }

  .table {
    font-size: 9pt !important;
    width: 100% !important;
  }

  .table thead th {
    background: #eee !important;
    color: #000 !important;
    font-size: 8pt !important;
    padding: 3pt 5pt !important;
    border-bottom: 1pt solid #999 !important;
  }

  .table tbody td {
    padding: 2pt 5pt !important;
    border-bottom: 0.5pt solid #ddd !important;
  }

  .table-responsive {
    overflow: visible !important;
  }

  /* ── 7. KPI / Stat cards — inline for print ── */
  .ui-stat-card {
    box-shadow: none !important;
    border: 1pt solid #ccc !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .ui-stat-card .ui-stat-icon {
    width: 1.5rem !important;
    height: 1.5rem !important;
    font-size: 0.8rem !important;
  }

  .ui-stat-card .ui-stat-value {
    font-size: 1.1rem !important;
  }

  .ui-stat-card:hover {
    transform: none !important;
    box-shadow: none !important;
  }

  /* ── 8. Badges — ensure color contrast ── */
  .ui-badge,
  .badge {
    border: 0.5pt solid currentColor !important;
    padding: 1pt 4pt !important;
    font-size: 8pt !important;
  }

  /* ── 9. Links — show URL for external ── */
  a[href^="http"]:not([href*="localhost"])::after {
    content: " (" attr(href) ")";
    font-size: 7pt;
    color: #666;
    word-break: break-all;
  }

  /* Don't show URLs for nav/action links */
  .nav-link::after,
  .dropdown-item::after,
  .btn::after,
  .navbar-brand::after,
  .ui-page-actions a::after,
  .ui-btn-group a::after {
    content: none !important;
  }

  /* ── 10. Images ── */
  img {
    max-width: 100% !important;
    page-break-inside: avoid;
  }

  .clinic-logo {
    max-height: 40px !important;
  }

  /* ── 11. Prevent orphaned headers ── */
  h1, h2, h3, h4, h5, h6,
  .ui-page-header,
  .ui-card-header,
  .ui-table-header,
  .ui-form-header {
    page-break-after: avoid;
    break-after: avoid;
  }

  /* ── 12. Form elements — static display ── */
  .form-control,
  .form-select {
    border: 0.5pt solid #999 !important;
    box-shadow: none !important;
    background: #fff !important;
    font-size: 9pt !important;
    padding: 2pt 4pt !important;
  }

  input[type="checkbox"],
  input[type="radio"] {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* ── 13. Alerts — keep visible ── */
  .alert {
    border: 1pt solid currentColor !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    padding: 4pt 8pt !important;
    font-size: 9pt !important;
  }

  /* ── 14. Modals — if open during print, make full-page ── */
  .modal.show .modal-dialog {
    max-width: 100% !important;
    margin: 0 !important;
  }

  .modal-backdrop {
    display: none !important;
  }

  /* ── 15. HIS detail panel ── */
  .his-detail-panel {
    max-height: none !important;
    overflow: visible !important;
    border: 1pt solid #ccc !important;
    page-break-inside: avoid;
  }

  /* ── 16. Print header helper — views can add a .print-header div ── */
  .print-header {
    display: block !important;
    text-align: center;
    margin-bottom: 10pt;
    padding-bottom: 6pt;
    border-bottom: 1.5pt solid #333;
  }

  .print-header .print-clinic-name {
    font-size: 14pt;
    font-weight: 700;
  }

  .print-header .print-report-title {
    font-size: 12pt;
    font-weight: 600;
    margin-top: 2pt;
  }

  .print-header .print-date {
    font-size: 8pt;
    color: #666;
    margin-top: 2pt;
  }

  /* ── 17. Print footer helper ── */
  .print-footer {
    display: block !important;
    margin-top: 12pt;
    padding-top: 6pt;
    border-top: 0.5pt solid #999;
    font-size: 7pt;
    color: #666;
    text-align: center;
  }

  /* Hide print helpers on screen */
}

/* Screen: hide print-only elements */
@media screen {
  .print-header,
  .print-footer {
    display: none !important;
  }
}
