/**
 * Print CSS – Proje PDF/Yazdırma Şeması (Port 5002)
 * SUBTASK-030-17 + Operations Overview print uyumu
 * Şema: docs/print-pdf-schema.md
 *
 * Yükleme: index.html'deki `<link rel="stylesheet" ... media="print">` ile
 * (statik import YOK — entry CSS'inde render-blocking durmasın).
 * Ekranda geçerli olan iki kural (`.print-only`, `.registration-cards-print-target`)
 * src/style.css içinde tutulur; buraya geri taşınmaz.
 */

/* Print-hidden: yazdırmada gizlenir (ekranda görünür) */
.print-hidden {
  /* default: visible; @media print'te gizlenecek */
}

@media print {
  body.print-front-office .sidebar,
  body.print-front-office .navbar,
  body.print-front-office nav,
  body.print-front-office header,
  body.print-housekeeping-performance .sidebar,
  body.print-housekeeping-performance .navbar,
  body.print-housekeeping-performance nav,
  body.print-housekeeping-performance header,
  body.print-maintenance-performance .sidebar,
  body.print-maintenance-performance .navbar,
  body.print-maintenance-performance nav,
  body.print-maintenance-performance header {
    display: none !important;
  }

  body.print-front-office .main-content,
  body.print-housekeeping-performance .main-content,
  body.print-maintenance-performance .main-content {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .print-only {
    display: block !important;
  }

  /* Hide non-printable elements */
  .no-print,
  .print-hidden,
  button:not(.print-keep),
  .quick-actions,
  nav,
  header,
  footer,
  .sidebar,
  .navbar,
  .modal,
  a[href].no-print,
  [data-no-print] {
    display: none !important;
  }

  /* Registration card print mode: hide all layout, show only the teleported cards */
  body.print-registration-cards .registration-card-print-dialog-root,
  body.print-registration-cards .main-content,
  body.print-registration-cards .sidebar,
  body.print-registration-cards [class*='ToastNotification'],
  body.print-registration-cards [class*='navbar'],
  body.print-registration-cards [class*='EmergencyAccessBar'] {
    display: none !important;
  }

  body.print-registration-cards .registration-cards-print-target {
    display: block !important;
    visibility: visible !important;
    width: 100%;
    max-width: 100%;
    overflow: visible;
    position: static !important;
  }

  body.print-registration-cards .registration-cards-print-content {
    display: block !important;
    visibility: visible !important;
    width: 200mm;
    margin: 0 auto;
  }

  /* Ensure registration card content is visible and uses print-friendly styles */
  body.print-registration-cards .registration-card {
    display: block !important;
    visibility: visible !important;
    width: 200mm !important;
    min-height: 148mm !important;
    margin: 0 auto 8mm auto !important;
    break-inside: avoid;
    page-break-inside: avoid;
    page-break-after: always;
  }

  body.print-registration-cards .registration-card:last-child {
    page-break-after: auto;
  }

  body.print-registration-cards .registration-cards-print-target .grid,
  body.print-registration-cards .registration-cards-print-target .grid-cols-1 {
    display: block !important;
  }

  body.print-registration-cards .registration-cards-print-target table,
  body.print-registration-cards .registration-cards-print-target th,
  body.print-registration-cards .registration-cards-print-target td {
    border: initial !important;
    width: auto !important;
    padding: initial !important;
    text-align: initial !important;
  }

  /* Checklist preview drawer print: hide app shell, show only drawer panel */
  body.print-checklist-preview #app {
    display: none !important;
  }

  body.print-checklist-preview [class*='ToastNotification'] {
    display: none !important;
  }

  /* BaseSideDrawer: hide backdrop, show only the panel (stable class from shared-components).
     reka DialogPortal overlay'i doğrudan body altına taşır; panel kardeşidir (inset-0 taşımaz). */
  body.print-checklist-preview > div.fixed.inset-0 {
    display: none !important;
  }

  body.print-checklist-preview .base-side-drawer-panel {
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 100vh;
    box-shadow: none !important;
    border: none !important;
  }

  /* Hide drawer footer when printing checklist */
  body.print-checklist-preview .base-side-drawer-panel > div:last-of-type {
    display: none !important;
  }

  /* Reset background */
  body {
    background: white !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Main content */
  .operations-content {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Card styling */
  .bg-white,
  [class*='dark:bg-navy'] {
    background: white !important;
    border: 1px solid #e5e7eb !important;
    box-shadow: none !important;
  }

  /* Text colors for print */
  .text-navy-700,
  [class*='dark:text-white'] {
    color: #1f2937 !important;
  }

  .text-gray-600,
  .text-gray-500,
  [class*='dark:text-gray'] {
    color: #4b5563 !important;
  }

  /* Grid layout for print - 2 columns */
  .grid.grid-cols-4 {
    display: flex !important;
    flex-wrap: wrap !important;
  }

  .grid.grid-cols-4 > div {
    width: 48% !important;
    margin: 1% !important;
  }

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

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

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

  /* Print header - shown only when printing */
  .print-header {
    display: block !important;
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #1f2937;
    padding-bottom: 10px;
  }

  .print-header h1 {
    font-size: 24px;
    margin: 0;
    color: #1f2937;
  }

  .print-header p {
    margin: 5px 0 0;
    font-size: 12px;
    color: #6b7280;
  }

  /* Status indicators */
  .bg-green-500,
  .bg-green-600 {
    background-color: #10b981 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .bg-yellow-500,
  .bg-orange-500 {
    background-color: #f59e0b !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .bg-red-500,
  .bg-red-600 {
    background-color: #ef4444 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Round status dots */
  .rounded-full {
    border-radius: 50% !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Ensure SVG charts print correctly */
  svg {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* KPI cards and content sections – bölümler tek sayfada kalsın */
  .kpi-card,
  .print-section {
    page-break-inside: avoid;
  }

  /* Print footer – içerik sonunda tek blok */
  .print-footer {
    display: block !important;
    margin-top: 24px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
    text-align: center;
    font-size: 11px;
    color: #6b7280;
  }

  /* Tables */
  table {
    border-collapse: collapse;
    width: 100%;
  }

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

  th {
    background-color: #f3f4f6 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/**
 * Front office yazdırma önizlemesi (M2Dialog portal) — yalnız bu modda.
 * Kural: #app gizlenir, portal sheet'i akışa girer; diğer print modları etkilenmez.
 */
@page front-office-print {
  size: A4 landscape;
  margin: 12mm;
}

@media print {
  body.print-front-office #app {
    display: none !important;
  }

  body.print-front-office .m2-dialog-overlay {
    display: none !important;
  }

  body.print-front-office .m2-dialog--center {
    position: static !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
    margin: 0 !important;
    box-shadow: none !important;
    border: 0 !important;
    page: front-office-print;
  }

  body.print-front-office .print-sheet-scroll {
    overflow: visible !important;
    max-height: none !important;
  }

  body.print-front-office .print-toolbar {
    display: none !important;
  }

  /* Uzun rapor: başlık her sayfada, satır ve bloklar bölünmez. */
  body.print-front-office thead {
    display: table-header-group;
  }

  body.print-front-office tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  body.print-front-office .print-header,
  body.print-front-office .print-summary,
  body.print-front-office .print-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  body.print-front-office .print-card {
    border: 1px solid #e5e7eb !important;
    box-shadow: none !important;
  }
}
