/* ============================================
   LEGAL TOOLS - PRINT STYLES
   For letter writer and expenses tools
   ============================================ */
/* Font faces only - all other styles in tools.css */
@font-face {
  font-family: "David";
  src: url(./david.ttf);
}
@font-face {
  font-family: "David";
  src: url(./davidbd.ttf);
  font-weight: bold;
}
@font-face {
  font-family: "Calibri";
  src: url(./calibri.ttf);
}
@font-face {
  font-family: "Calibri";
  src: url(./calibrib.ttf);
  font-weight: bold;
}

@media print {
  /* Base print setup */
  @page {
    size: A4 portrait;
    margin: 20mm 15mm;
  }

  *, *::before, *::after {
    box-sizing: border-box;
  }

  body, html {
    background: white !important;
    color: black !important;
    font-size: 11pt;
    line-height: 1.4;
    margin: 0;
    padding: 0;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Hide screen-only elements */
  .no_print,
  .tool-header,
  .tool-nav,
  .lang-toggle,
  .export-section,
  .danger-zone,
  button,
  .btn,
  input,
  select,
  datalist,
  form {
    display: none !important;
  }

  /* ============================================
     EXPENSES PRINT STYLES
     ============================================ */

  /* Show printed project name */
  #printed_name {
    display: block !important;
    font-size: 18pt;
    font-weight: 700;
    text-align: center;
    color: #1a3352;
    margin: 0 0 8mm 0;
    padding-bottom: 4mm;
    border-bottom: 2pt solid #8b6914;
  }

  /* Card styling for print */
  .card {
    background: white !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 0 8mm 0 !important;
    page-break-inside: avoid;
  }

  .card-header {
    border-bottom: 1pt solid #d1d5db !important;
    padding-bottom: 2mm !important;
    margin-bottom: 4mm !important;
  }

  .card-header h2 {
    font-size: 13pt !important;
    font-weight: 600 !important;
    color: #1a3352 !important;
    margin: 0 !important;
  }

  /* Container */
  .tool-container {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* ============================================
     EXPENSE TABLE PRINT STYLES
     ============================================ */

  .expense-table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin-bottom: 6mm !important;
    font-size: 10pt !important;
  }

  .expense-table thead {
    display: table-header-group;
  }

  .expense-table th {
    background: #eae3c0 !important;
    color: black !important;
    font-weight: 600 !important;
    padding: 3mm 4mm !important;
    text-align: start !important;
    border: none !important;
  }

  .expense-table th:first-child {
    border-radius: 2mm 0 0 0 !important;
  }

  .expense-table th:last-child {
    border-radius: 0 2mm 0 0 !important;
  }

  .expense-table td {
    padding: 2.5mm 4mm !important;
    border-bottom: 0.5pt solid #e5e7eb !important;
    vertical-align: top !important;
  }

  .expense-table tbody tr:nth-child(even) td {
    background: #f9fafb !important;
  }

  .expense-table tbody tr:hover td {
    background: inherit !important;
  }

  /* Total row styling */
  .expense-table tr.total td {
    background: #faf3e0 !important;
    font-weight: 700 !important;
    border-top: 1.5pt solid #8b6914 !important;
    border-bottom: 1.5pt solid #8b6914 !important;
    padding: 3mm 4mm !important;
    color: #1a3352 !important;
  }

  /* Comment styling */
  .expense-table .comment {
    font-size: 9pt !important;
    color: #6b7280 !important;
    font-style: italic !important;
    margin-top: 1mm !important;
  }

  /* Hide remove buttons in print */
  .expense-table .remove-btn,
  .expense-table td:last-child:empty {
    display: none !important;
  }

  /* Adjust column widths for expenses table */
  #expenses_table th:nth-child(1),
  #expenses_table td:nth-child(1) {
    width: 22% !important;
  }

  #expenses_table th:nth-child(2),
  #expenses_table td:nth-child(2) {
    width: 50% !important;
  }

  #expenses_table th:nth-child(3),
  #expenses_table td:nth-child(3) {
    width: 28% !important;
    text-align: end !important;
  }

  /* Summary table column widths */
  #summary_table th:nth-child(1),
  #summary_table td:nth-child(1) {
    width: 65% !important;
  }

  #summary_table th:nth-child(2),
  #summary_table td:nth-child(2) {
    width: 35% !important;
    text-align: end !important;
  }

  /* ============================================
     PAGE BREAK CONTROLS
     ============================================ */

  .card {
    page-break-inside: avoid !important;
  }

  .expense-table tr {
    page-break-inside: avoid !important;
  }

  .expense-table tr.total {
    page-break-before: avoid !important;
  }

  /* Keep summary table on same page if possible */
  #summary_table {
    page-break-before: avoid !important;
  }

  /* ============================================
     PRINT FOOTER
     ============================================ */

  @page {
    @bottom-center {
      content: counter(page) " / " counter(pages);
      font-size: 9pt;
      color: #6b7280;
    }
  }

  /* ============================================
     RTL PRINT ADJUSTMENTS
     ============================================ */

  [dir="rtl"] .expense-table th,
  [dir="rtl"] .expense-table td,
  body.he .expense-table th,
  body.he .expense-table td {
    text-align: start !important;
  }

  [dir="rtl"] #expenses_table th:nth-child(3),
  [dir="rtl"] #expenses_table td:nth-child(3),
  body.he #expenses_table th:nth-child(3),
  body.he #expenses_table td:nth-child(3),
  [dir="rtl"] #summary_table th:nth-child(2),
  [dir="rtl"] #summary_table td:nth-child(2),
  body.he #summary_table th:nth-child(2),
  body.he #summary_table td:nth-child(2) {
    text-align: start !important;
  }

  /* ============================================
     TYPOGRAPHY REFINEMENTS
     ============================================ */

  h1, h2, h3, h4, h5, h6 {
    color: #1a3352 !important;
    page-break-after: avoid !important;
  }

  /* Ensure proper font rendering */
  body.he, [dir="rtl"] {
    font-family: "David", "Arial Hebrew", Arial, sans-serif !important;
  }

  body.en, [dir="ltr"] {
    font-family: "Calibri", Arial, sans-serif !important;
  }
}
