/**
 * TCS Repair Forum — Print Stylesheet
 *
 * Activated only when the user clicks "Print / Save as PDF" on a single
 * checklist page. Generates a clean technician-friendly PDF with:
 *   - TCS Pune logo header (top of every page)
 *   - TCS watermark (faint, behind content)
 *   - Checklist title + board part number + difficulty
 *   - Step-by-step procedure (printable checkboxes)
 *   - TCS contact footer (bottom of every page)
 *   - Page numbers
 *
 * Tip for users: When the browser print dialog opens, select "Save as PDF"
 * as the destination to download a PDF instead of printing on paper.
 */

/* Hide everything by default in print */
@media print {
    /* Hide all site chrome — header, footer, sidebar, nav, ads */
    header,
    footer,
    nav,
    aside,
    .preview-banner,
    .preview-tabs,
    .tcs-header-mock,
    .tcs-footer-mock,
    .tcs-forum-filter-bar,
    .tcs-forum-pagination,
    .tcs-forum-user-bar,
    .tcs-sidebar,
    .tcs-checklist-search-wrap,
    .tcs-checklist-filter-bar,
    .tcs-checklist-progress-wrap,
    .tcs-checklist-actions,
    .tcs-reply-vote-col,
    .tcs-mark-solution-btn,
    .tcs-reply-form,
    .tcs-upload-widget,
    .tcs-hp-field,
    .tcs-checklist-browse,
    .tcs-breadcrumb {
        display: none !important;
    }

    /* Show only print-only elements */
    .tcs-print-only {
        display: block !important;
    }

    /* Reset colors for ink-friendly print */
    body {
        background: #fff !important;
        color: #1f2a37 !important;
        font-size: 11pt !important;
        line-height: 1.5 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Use full page width */
    .tcs-container,
    .tcs-checklist-single,
    .tcs-checklist-header,
    .tcs-checklist-tools,
    .tcs-checklist-steps,
    .tcs-step-item {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        background: #fff !important;
    }

    /* Page setup — A4 with sensible margins */
    @page {
        size: A4;
        margin: 18mm 15mm 22mm 15mm;
    }

    /* === Print Header (top of first page) === */
    .tcs-print-header {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 12px;
        border-bottom: 3px solid #00a0e3;
        margin-bottom: 18px;
    }

    .tcs-print-logo {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .tcs-print-logo-badge {
        width: 42px;
        height: 42px;
        background: #00a0e3 !important;
        color: #fff !important;
        font-weight: 800;
        font-size: 16pt;
        border-radius: 6px;
        display: flex;
        align-items: center;
        justify-content: center;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .tcs-print-logo-name {
        font-size: 18pt;
        font-weight: 700;
        color: #00a0e3 !important;
        line-height: 1.1;
    }

    .tcs-print-logo-tag {
        font-size: 9pt;
        color: #6b7280 !important;
        font-weight: 500;
    }

    .tcs-print-meta {
        text-align: right;
    }

    .tcs-print-doc-type {
        font-size: 10pt;
        font-weight: 700;
        color: #1f2a37 !important;
        text-transform: uppercase;
        letter-spacing: 0.06em;
    }

    .tcs-print-date {
        font-size: 9pt;
        color: #6b7280 !important;
        margin-top: 2px;
    }

    /* === Title Block === */
    .tcs-print-title-block {
        margin-bottom: 18px;
        padding-bottom: 12px;
        border-bottom: 1px solid #e2e8f0;
    }

    .tcs-print-title {
        font-size: 18pt;
        font-weight: 700;
        color: #1f2a37 !important;
        margin: 0 0 8px 0;
        line-height: 1.3;
    }

    .tcs-print-subtitle {
        font-size: 10pt;
        color: #1f2a37 !important;
        margin: 2px 0;
    }

    .tcs-print-subtitle strong {
        color: #007bb0 !important;
    }

    .tcs-print-url {
        font-size: 8pt;
        color: #6b7280 !important;
        margin-top: 8px;
        font-style: italic;
    }

    /* === Watermark (faint, behind content, on every page) === */
    .tcs-print-watermark {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) rotate(-35deg);
        font-size: 120pt;
        font-weight: 900;
        color: #00a0e3 !important;
        opacity: 0.05;
        z-index: 0;
        pointer-events: none;
        letter-spacing: 0.1em;
        white-space: nowrap;
    }

    /* Make sure actual content sits above the watermark */
    .tcs-print-header,
    .tcs-print-title-block,
    .tcs-checklist-single,
    .tcs-print-footer {
        position: relative;
        z-index: 1;
    }

    /* === Safety block === */
    .tcs-checklist-safety {
        background: #fef3c7 !important;
        border-left: 4px solid #f59e0b !important;
        color: #78350f !important;
        padding: 10px 14px;
        border-radius: 4px;
        margin-bottom: 14px;
        font-size: 10pt;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* === Tools list === */
    .tcs-checklist-tools {
        margin-bottom: 14px !important;
        padding: 10px 14px !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: 4px;
    }

    .tcs-checklist-tools h3 {
        font-size: 11pt;
        margin: 0 0 6px 0;
        color: #1f2a37 !important;
    }

    .tcs-checklist-tools ul {
        margin: 0;
        padding-left: 18px;
        font-size: 10pt;
    }

    .tcs-checklist-tools li {
        margin-bottom: 2px;
    }

    /* === Steps — print as a checkable list === */
    .tcs-checklist-steps {
        margin-top: 6px;
    }

    .tcs-step-item {
        padding: 10px 0 !important;
        border-bottom: 1px solid #e2e8f0 !important;
        page-break-inside: avoid;
    }

    .tcs-step-item:last-child {
        border-bottom: none !important;
    }

    /* Show empty checkbox (printable) instead of interactive one */
    .tcs-step-item input[type="checkbox"] {
        appearance: none !important;
        -webkit-appearance: none !important;
        width: 16px !important;
        height: 16px !important;
        border: 1.5px solid #1f2a37 !important;
        border-radius: 2px;
        margin: 0 8px 0 0 !important;
        position: relative;
        background: #fff !important;
    }

    /* If the checkbox is checked, show a tick */
    .tcs-step-item.is-done input[type="checkbox"]::after {
        content: "✓";
        position: absolute;
        top: -3px;
        left: 2px;
        font-size: 14pt;
        font-weight: 900;
        color: #00a0e3 !important;
    }

    .tcs-step-checkbox {
        display: flex;
        align-items: flex-start;
        gap: 10px;
        cursor: default;
    }

    .tcs-step-num {
        width: 22px !important;
        height: 22px !important;
        background: #00a0e3 !important;
        color: #fff !important;
        border-radius: 50%;
        font-size: 10pt;
        font-weight: 700;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .tcs-step-content {
        flex: 1;
    }

    .tcs-step-title {
        font-size: 11pt;
        font-weight: 700;
        color: #1f2a37 !important;
        display: block;
        margin-bottom: 2px;
    }

    .tcs-step-desc {
        font-size: 10pt;
        color: #1f2a37 !important;
        line-height: 1.5;
        display: block;
        margin-bottom: 4px;
    }

    .tcs-step-warning {
        font-size: 9pt;
        color: #92400e !important;
        background: #fef3c7 !important;
        padding: 4px 8px;
        border-radius: 3px;
        border-left: 3px solid #f59e0b !important;
        display: block;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* === Footer (bottom of every page) === */
    .tcs-print-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 8px 15mm;
        border-top: 2px solid #00a0e3;
        background: #fff !important;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        font-size: 8pt;
        color: #6b7280 !important;
        z-index: 10;
    }

    .tcs-print-footer-left,
    .tcs-print-footer-right {
        line-height: 1.4;
    }

    .tcs-print-footer-left strong {
        color: #007bb0 !important;
    }

    /* === Hide other unnecessary stuff === */
    .tcs-checklist-card,
    .tcs-checklist-grid,
    .tcs-page-header,
    .tcs-flash,
    .tcs-form-row,
    .tcs-account-page,
    .tcs-auth-card,
    .tcs-thread-card,
    .tcs-reply-card {
        display: none !important;
    }

    /* Force page break before the checklist content if needed */
    .tcs-checklist-single {
        page-break-before: auto;
    }

    /* Avoid breaking inside a single step */
    .tcs-step-item,
    .tcs-checklist-safety,
    .tcs-checklist-tools {
        page-break-inside: avoid;
    }
}

/* === Screen styles for the print-only elements (hidden) === */
@media screen {
    .tcs-print-only {
        display: none !important;
    }
}

/* === Print button styling === */
.tcs-print-icon {
    margin-right: 4px;
}

#tcs-checklist-print {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
