/* Print Styles for Result Page */
@media print {
  /* Hide navigation, buttons, and non-essential elements */
  .header,
  .footer,
  .nav,
  .btn,
  .filter-bar,
  .form-actions,
  .header-actions,
  .page-header,
  input,
  select,
  button,
  a.btn,
  .form-group {
    display: none !important;
  }

  /* Reset page layout */
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }

  body {
    background: white !important;
    font-family: Arial, sans-serif;
    font-size: 9pt;
    line-height: 1.3;
    color: #333;
  }

  .main {
    padding: 0;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }

  /* Page setup */
  @page {
    size: letter;
    margin: 0.4in;
  }

  /* Result container - compact */
  .result-container {
    box-shadow: none;
    border: none;
    padding: 0;
  }

  /* Header section - project left, principal & date right */
  .result-header {
    display: block;
    background: transparent !important;
    border-bottom: 2px solid #1e40af;
    padding: 0 0 6px 0;
    margin-bottom: 10px;
  }

  .result-project {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 0 20px;
    align-items: start;
  }

  .result-project h2 {
    grid-column: 1;
    grid-row: 1 / 3;
    font-size: 14pt;
    color: #1e40af;
    margin: 0;
    align-self: center;
  }

  .result-project .client-name {
    grid-column: 2;
    grid-row: 1;
    font-size: 10pt;
    font-weight: 500;
    margin: 0;
    opacity: 1;
    color: #333;
    text-align: right;
  }

  .result-project .estimate-date {
    grid-column: 2;
    grid-row: 2;
    font-size: 9pt;
    opacity: 1;
    color: #666;
    text-align: right;
    margin: 0;
  }

  /* Hide the summary from header - we show totals at bottom */
  .result-summary {
    display: none !important;
  }

  /* Details section - side by side, compact */
  .result-details {
    display: flex;
    gap: 12px;
    padding: 0;
    margin-bottom: 10px;
  }

  .detail-section {
    flex: 1;
    border: 1px solid #ddd;
    padding: 6px 8px;
  }

  .detail-section h3 {
    font-size: 8pt;
    color: #1e40af;
    text-transform: uppercase;
    margin-bottom: 4px;
    border-bottom: 1px solid #eee;
    padding-bottom: 2px;
  }

  .detail-table {
    width: 100%;
    font-size: 8pt;
  }

  .detail-table td {
    padding: 1px 0;
    border: none;
  }

  .detail-table td:last-child {
    text-align: right;
    font-weight: 500;
  }

  /* Calculation sections - compact */
  .calc-section {
    border: 1px solid #ddd;
    margin-bottom: 8px;
    break-inside: avoid;
  }

  .calc-section h3 {
    background: #f5f5f5 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    padding: 3px 8px;
    font-size: 9pt;
    color: #1e40af;
    border-bottom: 1px solid #ddd;
    margin: 0;
  }

  .calc-section .content,
  .calc-section > div:not(.calc-subtotals):not(h3) {
    padding: 4px 8px;
  }

  /* Tier tables - compact */
  .data-table,
  .tier-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 8pt;
  }

  .data-table th,
  .tier-table th {
    background: #f9f9f9 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    padding: 3px 6px;
    text-align: left;
    font-weight: 600;
    border-bottom: 1px solid #ddd;
  }

  .data-table td,
  .tier-table td {
    padding: 2px 6px;
    border-bottom: 1px solid #eee;
  }

  .tier-table .num,
  .data-table td:last-child {
    text-align: right;
  }

  /* Subtotals row */
  .calc-subtotals {
    display: flex;
    justify-content: flex-end;
    gap: 20px;
    padding: 4px 8px;
    background: #f9f9f9 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    font-size: 8pt;
  }

  .calc-subtotals strong {
    color: #1e40af;
  }

  /* Final totals - horizontal bar at bottom */
  .result-totals {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1e40af !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    padding: 10px 0.4in;
    margin: 0;
  }

  .totals-grid {
    display: flex !important;
    justify-content: space-around;
    gap: 0;
  }

  .total-box {
    flex: 1;
    text-align: center;
    background: transparent !important;
    border: none !important;
    box-shadow: none;
    padding: 0;
  }

  .total-box .total-label {
    font-size: 7pt;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.9);
    display: block;
  }

  .total-box .total-value {
    font-size: 14pt;
    font-weight: bold;
    color: white !important;
  }

  .premium-total .total-value,
  .commission-total .total-value,
  .net-total .total-value {
    color: white !important;
  }

  /* Add padding to content so it doesn't overlap fixed footer */
  .result-container {
    padding-bottom: 60px;
  }

  /* Hide elements marked as no-print */
  .no-print,
  .comparison-details,
  .comparison-note {
    display: none !important;
  }

  /* Avoid page breaks */
  .detail-section,
  .calc-section,
  tr {
    break-inside: avoid;
  }

  /* Change Section - print styles */
  .change-section {
    padding: 8px;
    background: #fffbeb !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    border: 1px solid #fcd34d;
    margin-bottom: 10px;
    break-inside: avoid;
  }

  .change-section h3 {
    font-size: 8pt;
    color: #92400e;
    margin-bottom: 6px;
    text-transform: uppercase;
    border-bottom: none;
    padding: 0;
    background: transparent !important;
  }

  /* Change table print styles */
  .change-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 8pt;
    margin-bottom: 8px;
  }

  .change-table th {
    background: #fef3c7 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    color: #92400e;
    padding: 4px 8px;
    text-align: right;
    font-weight: 600;
    border-bottom: 1px solid #fcd34d;
  }

  .change-table th:first-child {
    text-align: left;
  }

  .change-table td {
    padding: 4px 8px;
    text-align: right;
    border-bottom: 1px solid #fcd34d;
  }

  .change-table td:first-child {
    text-align: left;
  }

  .change-table .prior-row td {
    color: #666;
  }

  .change-table .amount-due-row {
    background: #fef3c7 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .change-table .amount-due-row td {
    border-top: 2px solid #f59e0b;
  }

  .change-table .change-increase {
    color: #dc2626 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .change-table .change-decrease {
    color: #16a34a !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Amount due grid print styles */
  .amount-due-grid {
    display: flex !important;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
  }

  .amount-due-grid .total-box {
    flex: 1;
    text-align: center;
    padding: 6px;
    background: white !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    border: 2px solid #f59e0b !important;
    box-shadow: none;
  }

  .amount-due-grid .total-label {
    font-size: 7pt;
    color: #666;
  }

  .amount-due-grid .total-value {
    font-size: 11pt;
    font-weight: bold;
    color: #333 !important;
  }

  .amount-due-grid .due-positive {
    background: #fef2f2 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .amount-due-grid .due-positive .total-value {
    color: #dc2626 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .amount-due-grid .due-negative {
    background: #f0fdf4 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .amount-due-grid .due-negative .total-value {
    color: #16a34a !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
