/* Wave 4 Issue 31 — Print/export-friendly layout
   This stylesheet is loaded with media="print" from base.html.
   It does not affect the normal browser UI. */

@page {
  /* Wide management reports need landscape so all columns can be printed. */
  size: A4 landscape;
  margin: 8mm;
}

@media print {
  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  html,
  body {
    background: #fff !important;
    color: #111827 !important;
    font-size: 10pt !important;
    line-height: 1.5 !important;
    overflow: visible !important;
    width: auto !important;
    max-width: none !important;
  }

  body {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .app-shell,
  .main-shell,
  .page,
  .content,
  .main-content,
  main {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
  }

  .drawer,
  .app-shell__backdrop,
  .topbar,
  .mobile-menu-toggle,
  .drawer-toggle,
  .navbar,
  .sidebar,
  .breadcrumb,
  .hero-actions,
  .page-actions,
  .row-actions,
  .filter-form,
  .form-actions,
  .sticky-actions,
  .btn,
  button,
  input[type="submit"],
  .pagination,
  .no-print,
  .messages,
  .toast,
  .alert-dismissible,
  .debug-toolbar,
  #djDebug,
  script,
  noscript {
    display: none !important;
  }

  a {
    color: #111827 !important;
    text-decoration: none !important;
  }

  .card,
  .metric-card,
  .dashboard-hero,
  .confirm-card,
  .panel,
  .section-card {
    border: 1px solid #d1d5db !important;
    background: #fff !important;
    color: #111827 !important;
    border-radius: 8px !important;
    padding: 10px 12px !important;
    margin: 0 0 10px !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .dashboard-hero,
  .dashboard-hero-inner,
  .section-head,
  .page-header,
  .card-header {
    display: block !important;
  }

  .hero-title,
  .page-title,
  .section-title,
  h1,
  h2,
  h3 {
    color: #111827 !important;
    margin: 0 0 6px !important;
    break-after: avoid;
    page-break-after: avoid;
  }

  .hero-title,
  h1 { font-size: 18pt !important; }
  .section-title,
  h2 { font-size: 14pt !important; }
  h3 { font-size: 12pt !important; }

  .muted,
  .text-muted,
  .metric-label,
  .hero-subtitle,
  .hero-note {
    color: #4b5563 !important;
  }

  .grid,
  .metric-grid,
  .summary-grid,
  .dashboard-grid {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .metric-card,
  .stat-card {
    min-height: auto !important;
  }

  .metric-value,
  .stat-value,
  .mono {
    font-variant-numeric: tabular-nums !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }


  /* Issue 31B: force horizontally scrollable tables to print all columns.
     In browsers, overflow:auto containers often print only the visible viewport. */
  .card:has(.table),
  .card:has(table),
  .table-wrap,
  .responsive-table-desktop,
  .table-responsive,
  .responsive-table-wrapper,
  .overflow-x-auto {
    overflow: visible !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
    max-width: none !important;
    width: 100% !important;
    min-width: 0 !important;
    display: block !important;
    contain: none !important;
    clip-path: none !important;
  }

  .table-wrap > table,
  .responsive-table-desktop > table,
  .table-responsive > table,
  table.table,
  .table {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    font-size: 7.2pt !important;
  }

  .table th,
  .table td,
  table th,
  table td {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    hyphens: auto !important;
    padding: 3px 4px !important;
    line-height: 1.35 !important;
  }

  /* Numeric/status columns should stay readable but still wrap if the table is very wide. */
  .mono,
  .metric-value,
  .stat-value,
  .badge {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }

  /* Hide operation-only columns in print so data columns have more room. */
  th:last-child:has(+ *),
  td:last-child:has(.row-actions),
  th:has(.row-actions),
  td:has(.row-actions) {
    display: none !important;
  }

  .table-wrap,
  .responsive-table-desktop,
  .table-responsive {
    display: block !important;
    overflow: visible !important;
    width: 100% !important;
    max-width: none !important;
  }

  table,
  .table {
    width: 100% !important;
    border-collapse: collapse !important;
    table-layout: auto !important;
    font-size: 7.2pt !important;
    background: #fff !important;
  }

  thead {
    display: table-header-group !important;
  }

  tfoot {
    display: table-footer-group !important;
  }

  tr,
  td,
  th {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  th,
  td {
    border: 1px solid #d1d5db !important;
    padding: 3px 4px !important;
    color: #111827 !important;
    vertical-align: top !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }

  th {
    background: #f3f4f6 !important;
    font-weight: 700 !important;
  }

  .mobile-card-list,
  .mobile-cards,
  .responsive-card-list {
    display: none !important;
  }

  .badge,
  .badge-soft,
  .badge-muted,
  .badge-success,
  .badge-danger,
  .badge-warning,
  .badge-info {
    border: 1px solid #9ca3af !important;
    background: #fff !important;
    color: #111827 !important;
    padding: 1px 5px !important;
    border-radius: 999px !important;
    display: inline-block !important;
  }

  .text-success,
  .tone-success,
  .success { color: #065f46 !important; }
  .text-danger,
  .tone-danger,
  .danger { color: #991b1b !important; }
  .text-warning,
  .tone-warning,
  .warning { color: #92400e !important; }
  .text-info,
  .tone-info,
  .info { color: #1e3a8a !important; }

  .alert,
  .alert-warning,
  .alert-info,
  .alert-success,
  .alert-danger {
    border: 1px solid #d1d5db !important;
    background: #fff !important;
    color: #111827 !important;
    padding: 8px 10px !important;
    margin: 0 0 10px !important;
  }

  .print-title::after {
    content: " — نسخه چاپی";
  }

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