/* Print styles for estimates */
@media print {
  /* Page setup - optimized for clean PDF output */
  @page {
    size: A4 portrait;
    margin: 0.5in 0.75in;
  }
  
  /* First page with custom margins */
  @page :first {
    margin-top: 0.5in;
  }
  
  /* Left and right pages for double-sided printing */
  @page :left {
    margin-left: 0.75in;
    margin-right: 0.5in;
  }
  
  @page :right {
    margin-left: 0.5in;
    margin-right: 0.75in;
  }

  /* Hide navigation, preview banner, and other UI elements */
  .no-print,
  nav,
  header,
  footer,
  .bg-blue-600,
  .preview-banner,
  button,
  [type="button"],
  a[href^="mailto:"],
  .print-hide {
    display: none !important;
  }

  /* Reset background colors for printing */
  body {
    background: white !important;
    color: black !important;
    margin: 0;
    padding: 0;
    font-size: 12pt;
    line-height: 1.5;
  }

  .bg-gray-50,
  .bg-gray-100,
  .dark\:bg-slate-900 {
    background: white !important;
  }

  /* Preserve important background colors */
  .bg-blue-50,
  .bg-green-50,
  .bg-yellow-50,
  thead,
  th {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Optimize page layout */
  .py-6,
  .px-4,
  .sm\:px-6,
  .lg\:px-8 {
    padding: 0.25in !important;
  }

  /* Smart page breaks */
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
    page-break-inside: avoid;
  }
  
  table, figure, img {
    page-break-inside: avoid;
  }
  
  tr, li {
    page-break-inside: avoid;
  }
  
  ul, ol {
    page-break-before: avoid;
  }

  /* Force page break */
  .page-break,
  .page-break-before {
    page-break-before: always;
  }
  
  .page-break-after {
    page-break-after: always;
  }

  /* Avoid page break */
  .avoid-break,
  .no-page-break {
    page-break-inside: avoid;
  }

  /* Remove shadows and rounded corners for cleaner print */
  .shadow,
  .shadow-sm,
  .shadow-md,
  .shadow-lg,
  .sm\:rounded-lg,
  .rounded-lg,
  .rounded {
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  /* Better table rendering */
  table {
    border-collapse: collapse;
    width: 100%;
    page-break-inside: auto;
  }
  
  thead {
    display: table-header-group;
  }
  
  tfoot {
    display: table-footer-group;
  }

  tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }
  
  th, td {
    padding: 0.1in 0.15in;
  }

  /* Make sure content fits */
  .max-w-5xl,
  .max-w-4xl,
  .max-w-3xl {
    max-width: 100% !important;
  }
  
  .container {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Typography optimizations */
  a {
    text-decoration: none;
    color: inherit;
  }
  
  a[href]:after {
    content: none !important;
  }
  
  abbr[title]:after {
    content: none !important;
  }

  /* Ensure images print well */
  img {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Remove grid gaps for tighter printing */
  .grid,
  .lg\:grid {
    gap: 0.1in !important;
  }

  /* Optimize spacing */
  .space-y-6 > * + *,
  .space-y-4 > * + *,
  .space-y-8 > * + * {
    margin-top: 0.15in !important;
  }
}
