/**
 * Print Stylesheet for Financial Calculators
 * Optimized for clean, professional printed reports
 * Version: 1.0.0
 */

@media print {
    /* Print report header */
    .print-report-title h1 {
        font-size: 20pt !important;
        font-weight: bold !important;
        margin: 0 0 0.1in 0 !important;
        color: #000 !important;
        border-bottom: 2pt solid #000 !important;
        padding-bottom: 0.1in !important;
        text-align: center !important;
    }

    .print-timestamp {
        text-align: right !important;
        font-size: 9pt !important;
        color: #666 !important;
        margin-bottom: 0.2in !important;
    }

    .print-value {
        float: right !important;
        font-weight: bold !important;
        color: #000 !important;
        padding-left: 0.1in !important;
    }

    /* Page Setup */
    @page {
        margin: 0.5in;
        size: letter portrait;
    }

    /* Hide non-essential elements */
    header nav,
    footer,
    .skip-link,
    .calculate-btn,
    button,
    .search-box,
    .tree-navigation,
    .hero,
    input[type="range"],
    .form-group label input[type="checkbox"],
    .expand-icon,
    .calc-card-badge,
    .print-btn,
    .share-btn-container,
    #invMonteCarloSection,
    #monteCarloSection,
    #divMonteCarloSection {
        display: none !important;
    }
    
    /* Page ordering */
    .input-section {
        order: 1;
        page-break-after: auto;
    }
    
    .results-section {
        order: 2;
        page-break-before: auto;
    }
    
    .breakdown-section {
        order: 3;
    }

    /* Reset colors for print */
    * {
        color: #000 !important;
        background: #fff !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    /* Page breaks */
    .calculator-grid,
    .breakdown-section,
    .chart-container {
        page-break-inside: avoid;
    }

    h1, h2, h3 {
        page-break-after: avoid;
    }

    /* Body */
    body {
        font-family: 'Times New Roman', serif;
        font-size: 11pt;
        line-height: 1.4;
        color: #000;
        background: #fff;
    }

    /* Container */
    .container {
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 0;
    }

    /* Header - Keep title but hide navigation */
    header {
        page-break-after: avoid;
    }
    
    header h1 {
        font-size: 18pt;
        font-weight: bold;
        margin: 0 0 0.1in 0;
        border-bottom: 2pt solid #000;
        padding-bottom: 0.05in;
        text-align: center;
    }
    
    h1 {
        font-size: 16pt;
        font-weight: bold;
        margin-bottom: 0.15in;
    }

    h2 {
        font-size: 14pt;
        font-weight: bold;
        margin-top: 0.2in;
        margin-bottom: 0.1in;
        border-bottom: 1pt solid #666;
        padding-bottom: 0.05in;
    }

    h3 {
        font-size: 12pt;
        font-weight: bold;
        margin-top: 0.15in;
        margin-bottom: 0.1in;
    }

    /* Subtitle */
    .subtitle {
        font-size: 10pt;
        font-style: italic;
        text-align: center;
        margin-bottom: 0.2in;
    }

    /* Input Section - Show values */
    .input-section {
        border: 1pt solid #000;
        padding: 0.1in;
        margin-bottom: 0.2in;
    }

    .input-columns {
        display: block !important;
    }

    .input-column {
        display: block;
        margin-bottom: 0.1in;
    }

    /* Input display as table for clean alignment */
    .form-group {
        display: table;
        width: 100%;
        margin-bottom: 0.05in;
        padding: 0.03in 0;
        border-bottom: 0.5pt dotted #ddd;
    }

    .form-group label {
        display: table-cell;
        font-weight: bold;
        font-size: 10pt;
        width: 70%;
        padding-right: 0.2in;
        vertical-align: middle;
    }

    .form-group input,
    .form-group select {
        display: table-cell !important;
        font-size: 10pt;
        border: none !important;
        background: transparent !important;
        text-align: right;
        font-weight: bold;
        width: 30%;
        color: #000 !important;
        vertical-align: middle;
    }
    
    .form-group input::after {
        content: attr(value);
        font-weight: bold;
    }
    
    .form-group .input-wrapper {
        display: table-cell;
        width: 30%;
        text-align: right;
        vertical-align: middle;
    }
    
    .form-group .currency {
        color: #000 !important;
        font-weight: normal;
        margin-right: 2px;
    }

    .form-group small {
        display: none;
    }

    /* Results Section */
    .results-section {
        margin-top: 0.2in;
    }

    .results-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.1in !important;
        margin: 0.1in 0;
    }

    .result-card {
        border: 1pt solid #000;
        padding: 0.1in;
        text-align: center;
    }

    .result-label {
        font-size: 9pt;
        font-weight: normal;
        margin-bottom: 0.05in;
        text-transform: uppercase;
    }

    .result-value {
        font-size: 14pt;
        font-weight: bold;
    }

    .result-card small {
        font-size: 8pt;
        display: block;
        margin-top: 0.05in;
    }

    /* Breakdown Section */
    .breakdown-section {
        margin: 0.15in 0;
        border: 1pt solid #666;
        padding: 0.1in;
    }

    /* Tables */
    table {
        width: 100%;
        border-collapse: collapse;
        margin: 0.1in 0;
        font-size: 9pt;
    }

    thead {
        background: #f0f0f0 !important;
        font-weight: bold;
    }

    th, td {
        border: 0.5pt solid #666;
        padding: 0.05in;
        text-align: right;
    }

    th:first-child,
    td:first-child {
        text-align: left;
    }

    tbody tr:nth-child(even) {
        background: #f8f8f8 !important;
    }

    /* Charts */
    .chart-container {
        margin: 0.2in 0;
        page-break-inside: avoid;
    }

    .chart-container canvas {
        max-width: 100%;
        height: auto !important;
    }

    /* Scenario columns */
    .scenario-column {
        border: 1pt solid #000;
        padding: 0.1in;
        margin-bottom: 0.1in;
    }

    /* Print-specific content */
    .print-only {
        display: block !important;
    }

    .no-print {
        display: none !important;
    }

    /* Report Header (add with JS) */
    .print-header {
        text-align: center;
        margin-bottom: 0.2in;
        border-bottom: 2pt solid #000;
        padding-bottom: 0.1in;
    }

    .print-header h1 {
        margin: 0;
        border: none;
    }

    .print-date {
        font-size: 9pt;
        font-style: italic;
        margin-top: 0.05in;
    }

    /* Disclaimer */
    .print-disclaimer {
        border-top: 1pt solid #000;
        margin-top: 0.3in;
        padding-top: 0.1in;
        font-size: 8pt;
        text-align: center;
    }

    /* Links */
    a {
        text-decoration: none;
    }

    a[href]:after {
        content: "";
    }

    /* Force black text on important elements */
    .result-value,
    h1, h2, h3,
    th,
    strong {
        color: #000 !important;
    }

    /* Fix gradient text (highlight class) not showing in print */
    .result-value.highlight,
    .highlight,
    header h1 {
        background: none !important;
        -webkit-text-fill-color: #000 !important;
        background-clip: unset !important;
        -webkit-background-clip: unset !important;
        color: #000 !important;
    }

    /* Monte Carlo parameter header boxes - clean print style */
    #invMonteCarloInputs > div:first-child,
    #monteCarloInputs > div:first-child,
    #divMonteCarloInputs > div:first-child {
        background: none !important;
        border: 1pt solid #999 !important;
        padding: 0.08in !important;
        margin-bottom: 0.08in !important;
    }

    #invMonteCarloInputs > div:first-child h4,
    #monteCarloInputs > div:first-child h4,
    #divMonteCarloInputs > div:first-child h4 {
        color: #000 !important;
        font-size: 10pt !important;
        margin: 0 0 0.05in 0 !important;
    }

    #invMonteCarloInputs > div:first-child p,
    #monteCarloInputs > div:first-child p,
    #divMonteCarloInputs > div:first-child p {
        color: #000 !important;
        font-size: 9pt !important;
        line-height: 1.3 !important;
        margin: 0 !important;
    }

    /* Remove shadows and gradients */
    .calc-card,
    .result-card,
    .breakdown-section,
    .hero {
        background: #fff !important;
        background-image: none !important;
    }

    /* Optimize for space */
    .calculator-grid {
        display: block !important;
    }

    .input-section,
    .results-section {
        width: 100% !important;
        margin: 0 !important;
    }

    /* Chart.js specific */
    canvas {
        max-height: 3in !important;
    }

    /* Utility classes */
    .page-break-before {
        page-break-before: always;
    }

    .page-break-after {
        page-break-after: always;
    }

    .keep-together {
        page-break-inside: avoid;
    }

    /* Comparison tables (scenario comparison) */
    #comparisonTable {
        font-size: 8pt;
    }

    #comparisonTable > div {
        display: table !important;
        width: 100%;
        border-collapse: collapse;
    }

    #comparisonTable > div > div {
        display: table-row !important;
        border: 0.5pt solid #666 !important;
    }

    #comparisonTable > div > div > div {
        display: table-cell !important;
        padding: 0.05in;
        border: 0.5pt solid #666;
    }

    /* Winner section */
    #winnerSection {
        border: 2pt solid #000 !important;
        padding: 0.15in !important;
        margin-bottom: 0.2in !important;
        text-align: center;
    }

    /* Ensure readable font sizes */
    p, li, td, th, span, div {
        font-size: 10pt;
    }

    small {
        font-size: 8pt;
    }
}

/* Print button styles (not in print) */
@media screen {
    .print-btn {
        position: fixed;
        bottom: 20px;
        right: 20px;
        background: linear-gradient(135deg, #00d4ff 0%, #06ffa5 100%);
        color: #18181b;
        border: none;
        padding: 12px 24px;
        border-radius: 8px;
        font-weight: 600;
        font-size: 14px;
        cursor: pointer;
        box-shadow: 0 4px 12px rgba(0, 212, 255, 0.3);
        transition: all 0.3s;
        z-index: 1000;
    }

    .print-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 16px rgba(0, 212, 255, 0.4);
    }

    .print-btn:active {
        transform: translateY(0);
    }

    .print-btn::before {
        content: "🖨️ ";
    }
}

    /* Better page break control */
    .input-section {
        page-break-after: auto;
        page-break-inside: avoid;
    }

    .results-section {
        page-break-before: auto;
        page-break-inside: avoid;
    }

    h2 {
        page-break-after: avoid;
    }

    .breakdown-section,
    .chart-container,
    table {
        page-break-inside: avoid;
        page-break-before: auto;
    }

    /* Ensure first page has content */
    main {
        page-break-before: avoid;
    }

    .print-report-title,
    .print-timestamp {
        page-break-after: avoid;
    }
}
