/* Camino Equalizer - Print Styles */

@media print {
  @page {
    size: landscape;
    margin: 0.5in;
  }

  /* Force desktop width regardless of device */
  html, body {
    width: 100% !important;
    min-width: 1000px !important;
    background: white !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 10pt !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    /* Reset any mobile transforms */
    transform: none !important;
    zoom: 1 !important;
  }

  /* Prevent mobile viewport scaling issues */
  .container {
    width: 100% !important;
    max-width: none !important;
    min-width: 900px !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .card {
    box-shadow: none;
    page-break-inside: avoid;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
  }

  .no-print,
  .cell-actions,
  th.col-actions {
    display: none !important;
  }

  /* Always show desktop columns, hide mobile columns for print */
  .hide-mobile {
    display: table-cell !important;
  }

  .show-mobile-only {
    display: none !important;
  }

  /* Hide mobile edit buttons */
  .mobile-edit-btn {
    display: none !important;
  }

  /* Hide all edit buttons/icons in print - must come after .hide-mobile */
  .btn-icon {
    display: none !important;
  }

  /* Ensure actions column stays hidden even with hide-mobile */
  .cell-actions,
  td.cell-actions,
  th.col-actions,
  .hide-mobile.no-print {
    display: none !important;
  }

  /* Force desktop layout for all screen sizes when printing */
  .totals-grid {
    display: grid !important;
    grid-template-columns: 1fr auto !important;
    gap: 1.5rem !important;
    width: 100% !important;
  }

  /* Force desktop table widths in print */
  .totals-table {
    width: auto !important;
    min-width: 250px !important;
  }

  h1 {
    font-size: 14pt;
  }

  h2 {
    font-size: 12pt;
    margin-bottom: 0.5rem;
  }

  table {
    font-size: 9pt;
    page-break-inside: auto;
    width: 100% !important;
  }

  /* Remove min-width so columns can shrink to fit print page,
     but keep JS-set width values so asset/debt columns stay synced */
  .col-v1, .col-v2, .col-v3, .col-v4, .col-v5,
  .col-party-a, .col-party-b,
  .cell-party-a, .cell-party-b,
  .col-adj-party, .cell-adj-party,
  .col-adj-amount, .cell-adj-amount,
  .spacer-col {
    min-width: 0 !important;
  }

  .table-wrapper {
    overflow: hidden !important;
  }

  thead {
    display: table-header-group;
  }

  /* Prevent tfoot (subtotals) from repeating on every page */
  tfoot {
    display: table-row-group;
  }

  tr {
    page-break-inside: avoid;
  }

  /* Keep header and first section together on same page */
  .header-content {
    break-after: avoid;
  }

  th, td {
    padding: 0.25rem 0.5rem;
  }

  /* Keep section backgrounds */
  .section-assets {
    background: #dbeafe !important;
  }

  .section-debts {
    background: #fee2e2 !important;
  }

  .section-adjustments {
    background: #f5f3ff !important;
  }

  .section-offsets {
    background: #ede9fe !important;
  }

  .totals-row-assets {
    background: #dbeafe !important;
  }

  .totals-row-debts {
    background: #fee2e2 !important;
  }

  .totals-row-assets-debts {
    background: #f3f4f6 !important;
  }

  .totals-row-adjustments {
    background: #f5f3ff !important;
  }

  .totals-row-offsets {
    background: #ede9fe !important;
  }

  .totals-row-total {
    background: #dcfce7 !important;
  }

  .equalization-box {
    background: #dcfce7 !important;
    margin-top: 0 !important;
    min-width: 200px !important;
  }

  /* Preserve negative color */
  .text-negative {
    color: #dc2626 !important;
  }

  /* Hide rows marked as hide-print */
  .hide-print {
    display: none !important;
  }

  /* Page break between sections */
  .print-page-break {
    page-break-before: always;
  }

  .print-page-break:first-of-type {
    page-break-before: auto;
  }

  /* When print color is disabled, remove backgrounds */
  body:not(.print-color) .section-assets,
  body:not(.print-color) .section-debts {
    background: white !important;
  }

  body:not(.print-color) .section-adjustments {
    background: white !important;
  }

  body:not(.print-color) .section-offsets {
    background: white !important;
  }

  body:not(.print-color) .totals-row-assets,
  body:not(.print-color) .totals-row-debts,
  body:not(.print-color) .totals-row-assets-debts,
  body:not(.print-color) .totals-row-adjustments,
  body:not(.print-color) .totals-row-offsets,
  body:not(.print-color) .totals-row-total {
    background: white !important;
  }

  body:not(.print-color) .equalization-box {
    background: #f0f0f0 !important;
  }

  /* Party name inputs should look like plain text in print */
  .party-name-input,
  input#party-a-name,
  input#party-b-name {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    font-weight: inherit;
    font-size: inherit;
  }

  /* Case info inputs should look like plain text in print */
  .case-field .input {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    font-weight: inherit;
    font-size: inherit;
  }

  /* Show case info fields in print (override no-print) */
  .header-case-info {
    display: flex !important;
  }

  .case-field {
    display: inline-flex !important;
  }

  .case-field-row {
    display: flex !important;
    gap: 1rem !important;
  }

  /* All inputs should look like plain text in print */
  input,
  select,
  textarea {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    font-weight: inherit;
    font-size: inherit;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
  }

  /* Hide date picker calendar icon in print */
  input[type="date"]::-webkit-calendar-picker-indicator {
    display: none !important;
  }

  /* Hide report purpose row when blank or print setting is off */
  .print-hide-blank,
  .print-hide-purpose {
    display: none !important;
  }

  /* Show print-only text for report purpose (select doesn't render in print) */
  .report-purpose-print {
    display: inline !important;
    font-size: inherit;
  }

  /* Hide case type radios in print, just show the title */
  .case-type-and-name {
    display: none !important;
  }

  /* Override all mobile-specific styles for print (desktop layout always) */
  .line-num {
    width: 2rem !important;
    min-width: 2rem !important;
    max-width: 2rem !important;
    font-size: 9pt !important;
    padding: 0.25rem 0.5rem !important;
  }

  .cell-description {
    font-size: 9pt !important;
    padding: 0.25rem 0.5rem !important;
  }


  .cell-party-a,
  .cell-party-b {
    font-size: 9pt !important;
    padding: 0.25rem 0.5rem !important;
  }

  /* Ensure header stacks properly */
  .header-content {
    flex-direction: row !important;
    gap: 1.5rem !important;
  }

  .header-parties {
    flex-direction: column !important;
  }

  /* Section headers inline, not sticky in print */
  .section-header {
    flex-direction: row !important;
    justify-content: space-between !important;
    position: static !important;
  }
}
