/**
 * Print Stylesheet for EcoCalc Calculators
 * Optimizes calculator results for printing
 */

@media print {
  /* ========================================
     GENERAL PRINT STYLES
     ======================================== */

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  body {
    font-size: 11pt;
    line-height: 1.4;
    color: #000;
    background: #fff;
    margin: 0;
    padding: 20px;
  }

  /* ========================================
     HIDE INTERACTIVE ELEMENTS
     ======================================== */

  /* Hide navigation, footers, and non-essential content */
  header,
  footer,
  nav,
  .no-print,
  button:not(.print-only),
  input,
  select,
  textarea,
  .ad-slot,
  [class*="ad-"],
  #cookie-banner,
  .social-share,
  form:not(.print-form) {
    display: none !important;
  }

  /* Hide input forms but keep labels for context */
  .input-section,
  .calculator-inputs {
    display: none !important;
  }

  /* ========================================
     SHOW RESULTS PROMINENTLY
     ======================================== */

  #results,
  .results-section {
    display: block !important;
    page-break-inside: avoid;
    border: 2px solid #059669;
    padding: 20px;
    margin: 20px 0;
    background: #f0fdf4 !important;
  }

  /* Results title */
  #results h2,
  .results-section h2 {
    font-size: 18pt;
    font-weight: bold;
    color: #059669;
    margin-top: 0;
    margin-bottom: 10pt;
    border-bottom: 2px solid #059669;
    padding-bottom: 5pt;
  }

  /* Main result numbers */
  .result-card,
  .card {
    page-break-inside: avoid;
    border: 1px solid #d1d5db;
    padding: 10pt;
    margin: 10pt 0;
    background: #fff !important;
  }

  .result-value,
  .text-4xl,
  .text-3xl {
    font-size: 16pt;
    font-weight: bold;
    color: #000;
  }

  /* ========================================
     CHARTS AND VISUALIZATIONS
     ======================================== */

  /* Progress bars */
  .progress-bar,
  [class*="Bar"] {
    border: 1px solid #000;
    height: 20px !important;
    background: #e5e7eb !important;
    position: relative;
    page-break-inside: avoid;
  }

  .progress-bar > div,
  [class*="Bar"] > div {
    background: #059669 !important;
    height: 100% !important;
  }

  /* Show percentages on progress bars */
  .progress-bar::after {
    content: attr(data-percentage);
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 9pt;
    font-weight: bold;
  }

  /* ========================================
     TABLES AND DATA
     ======================================== */

  table {
    width: 100%;
    border-collapse: collapse;
    page-break-inside: avoid;
    margin: 10pt 0;
  }

  th,
  td {
    border: 1px solid #000;
    padding: 5pt;
    text-align: left;
  }

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

  /* ========================================
     TIPS AND RECOMMENDATIONS
     ======================================== */

  .tips-section,
  #reductionTips,
  #conservationTips {
    page-break-inside: avoid;
    border-left: 3px solid #059669;
    padding-left: 10pt;
    margin: 15pt 0;
  }

  .tips-section li,
  #reductionTips li,
  #conservationTips li {
    margin: 5pt 0;
    font-size: 10pt;
    line-height: 1.4;
  }

  /* ========================================
     BRANDING AND METADATA
     ======================================== */

  /* Add printed date and URL */
  body::before {
    content: "EcoCalc.org - Environmental Calculator Results";
    display: block;
    font-size: 14pt;
    font-weight: bold;
    color: #059669;
    margin-bottom: 10pt;
    padding-bottom: 5pt;
    border-bottom: 2px solid #059669;
  }

  body::after {
    content: "Printed: " attr(data-print-date) " | " attr(data-print-url);
    display: block;
    font-size: 8pt;
    color: #666;
    margin-top: 20pt;
    padding-top: 10pt;
    border-top: 1px solid #d1d5db;
  }

  /* Page header for multi-page documents */
  @page {
    margin: 1.5cm;

    @top-center {
      content: "EcoCalc.org";
      font-size: 9pt;
      color: #666;
    }

    @bottom-center {
      content: "Page " counter(page) " of " counter(pages);
      font-size: 9pt;
      color: #666;
    }
  }

  /* ========================================
     PAGE BREAKS
     ======================================== */

  /* Avoid breaks in these elements */
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
    page-break-inside: avoid;
  }

  .result-card,
  .card,
  .breakdown-section,
  .comparison-section {
    page-break-inside: avoid;
  }

  /* Force breaks before major sections */
  .section-break {
    page-break-before: always;
  }

  /* ========================================
     LINKS
     ======================================== */

  /* Show URLs for links */
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 8pt;
    color: #666;
  }

  /* Don't show URLs for anchor links */
  a[href^="#"]::after {
    content: "";
  }

  /* ========================================
     IMAGES AND ICONS
     ======================================== */

  img {
    max-width: 100%;
    page-break-inside: avoid;
  }

  /* Hide decorative icons */
  .icon,
  svg:not(.chart-svg) {
    display: none;
  }

  /* ========================================
     UTILITY CLASSES
     ======================================== */

  .print-only {
    display: block !important;
  }

  .print-hide {
    display: none !important;
  }

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

  /* ========================================
     CALCULATOR-SPECIFIC STYLES
     ======================================== */

  /* Carbon Footprint Calculator */
  #totalEmissions {
    font-size: 20pt !important;
    font-weight: bold;
  }

  /* Comparison percentages */
  #comparison {
    font-size: 14pt;
    color: #059669;
  }

  /* Breakdown sections */
  #transportEmissions,
  #energyEmissions,
  #airEmissions,
  #dietEmissions {
    font-size: 12pt;
    font-weight: bold;
  }

  /* Solar Savings Calculator */
  #payback,
  #savings25 {
    font-size: 18pt !important;
    font-weight: bold;
  }

  /* Water Usage Calculator */
  #dailyUsage,
  #perPerson {
    font-size: 16pt !important;
    font-weight: bold;
  }

  /* ========================================
     COLOR ADJUSTMENTS
     ======================================== */

  /* Ensure sufficient contrast for printing */
  .text-gray-600,
  .text-gray-700 {
    color: #374151 !important;
  }

  .text-gray-400,
  .text-gray-500 {
    color: #6b7280 !important;
  }

  .bg-green-50,
  .bg-emerald-50 {
    background: #f0fdf4 !important;
  }

  .bg-green-500,
  .bg-emerald-500 {
    background: #059669 !important;
  }

  /* ========================================
     PRINT SUMMARY BOX
     ======================================== */

  .print-summary {
    border: 2px solid #059669;
    padding: 15pt;
    margin: 15pt 0;
    background: #f0fdf4 !important;
    page-break-inside: avoid;
  }

  .print-summary h3 {
    margin-top: 0;
    color: #059669;
    font-size: 14pt;
  }

  .print-summary .summary-item {
    display: flex;
    justify-content: space-between;
    padding: 5pt 0;
    border-bottom: 1px solid #d1d5db;
  }

  .print-summary .summary-item:last-child {
    border-bottom: none;
  }

  .print-summary .summary-label {
    font-weight: bold;
  }

  .print-summary .summary-value {
    font-weight: bold;
    color: #059669;
  }
}
