/* ===== Print Constraints (A4 Layout) ===== */

/* ── Screen-only: print area styling ── */
#print-area {
    font-size: 11px;
    line-height: 1.4;
    overflow-x: auto;
}

.print-header {
    text-align: center;
    margin-bottom: 8px;
}

.print-header h4 {
    margin: 0;
    font-size: 16px;
}

.print-header small {
    color: #777;
}

/* 5-column Doctor Order grid */
.order-grid-5col {
    display: grid;
    grid-template-columns: 2fr 1fr 3fr 1fr 3fr;
    border: 1px solid #000;
    min-width: 900px; /* Keep table format intact on screen */
    background: #fff;
    color: #000;
}

.grid-header {
    font-weight: bold;
    background-color: #e9ecef;
    padding: 6px 4px;
    border-bottom: 1px solid #000;
    border-right: 1px solid #000;
    text-align: center;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.3;
}

.grid-header:last-child {
    border-right: none;
}

.grid-cell {
    padding: 6px 5px;
    border-right: 1px solid #000;
    border-bottom: 1px solid #000;
    vertical-align: top;
    font-size: 10.5px;
    background: #fff;
    color: #000;
}

.order-cell-flex {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.order-row-spacer {
    height: 16.5em;
}

.grid-cell:nth-child(5n) {
    border-right: none;
}

.grid-cell:nth-child(5n+2),
.grid-cell:nth-child(5n+4) {
    text-align: center;
    vertical-align: top;
    padding-top: 8px; /* Top-aligned with .order-list first item (padding-top 6px + margin-top 2px) */
}

.highlight {
    font-weight: bold;
    color: #c0392b;
}

.order-list {
    padding-left: 15px;
    margin: 2px 0;
}

.order-list li {
    margin-bottom: 2px;
    line-height: 1.4;
}

.divider {
    border-top: 1px solid #ddd;
    margin: 5px 0;
}

.dotted-line {
    border-bottom: 1px dotted #000;
    display: inline-block;
    min-width: 70px;
}

/* Fibrinolysis and Anticoagulant choice print cards */
.fib-order-box, .ac-opt {
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 6px 8px;
    margin-top: 4px;
    font-size: 10.5px;
}

.fib-order-box.chosen, .ac-opt.recommended {
    border: 2px solid #c0392b;
    background: #fff8f8;
}

.ac-opt.na {
    opacity: 0.55;
    font-size: 9.5px;
}

.monitor-alert {
    margin-top: 4px;
    padding: 5px 7px;
    background: #fff3cd;
    border-left: 3px solid #e67e22;
    font-size: 9.5px;
    line-height: 1.5;
}

/* Patient Sticker Box */
.sticker-box-container {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}

.sticker-area {
    border: 1px dashed #999;
    padding: 4px 8px;
    width: 170px;
    height: 46px;
    text-align: center;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    box-sizing: border-box;
}

/* Version attribution default hidden */
.version-attribution {
    display: none;
}

/* ── Authentic Stroke Fast Track Order Header ── */
.stroke-print-header {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-bottom: 8px;
    min-height: 48px;
}

.stroke-logo-box {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

.stroke-print-logo {
    height: 46px;
    width: auto;
    max-width: 65px;
    object-fit: contain;
    display: block;
}

.stroke-title-box {
    text-align: center;
    width: 100%;
}

.stroke-main-title {
    font-size: 14pt;
    font-weight: bold;
    line-height: 1.2;
    color: #000;
    margin: 0;
}

.stroke-sub-title {
    font-size: 11pt;
    font-weight: bold;
    line-height: 1.2;
    color: #000;
    margin-top: 2px;
}

/* ═══════════════════════════════════════════
   PRINT OVERRIDES — A4 (210mm × 297mm)
   ═══════════════════════════════════════════ */
@media print {
    @page {
        size: A4 portrait;
        margin: 0;
    }

    /* ── Global resets ── */
    html, body {
        margin: 0 !important;
        padding: 0 !important;
        width: 210mm !important;
        background: #fff !important;
        color: #000 !important;
        display: block !important;
        font-size: 10pt;
    }

    /* ── Hide screen-only elements ── */
    .form-container,
    .summary-banner,
    .grace-summary,
    .results-container > h3,
    .btn-print,
    .btn-clear,
    .btn-calculate,
    #print-btn,
    #print-blank-btn,
    #clear-btn,
    header,
    nav,
    .header,
    form,
    .top-nav,
    .skip-link,
    .float-print-bar,
    a[href*="index.html"] {
        display: none !important;
    }

    /* ── Container: full-width, no chrome ── */
    .container {
        box-shadow: none !important;
        max-width: 100% !important;
        width: 100% !important;
        border-radius: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        background: #fff !important;
    }

    /* ── Results area ── */
    .results-container {
        margin: 0 !important;
        padding: 5mm !important;
        border-top: none !important;
        background: #fff !important;
    }


    /* ── Print area ── */
    #print-area {
        border: none !important;
        font-size: 9pt;
        line-height: 1.3;
        overflow: visible !important;
    }

    /* ── 5-col grid: fit A4 width ── */
    .order-grid-5col {
        min-width: auto !important;
        width: 100% !important;
        border: 1px solid #000;
        page-break-inside: avoid;
        font-size: 8.5pt;
    }

    .grid-header {
        padding: 3px;
        font-size: 8pt;
        line-height: 1.1;
        background: transparent !important;
        background-color: transparent !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .order-grid-5col .grid-header:first-child {
        padding-top: 5px;
        padding-bottom: 5px;
    }

    .grid-cell {
        padding: 3px;
        font-size: 8pt;
        line-height: 1.3;
    }

    .grid-cell:nth-child(5n+2),
    .grid-cell:nth-child(5n+4) {
        font-size: 8pt;
        text-align: center;
        vertical-align: top;
        padding-top: 4px !important; /* Top-aligned with .order-list first item (padding-top 3px + margin-top 1px) */
    }

    /* ── Print header ── */
    .print-header h4 {
        font-size: 12pt;
        margin-bottom: 2px;
    }

    .print-header small {
        font-size: 8pt;
    }

    /* ── Stroke Fast Track authentic print header ── */
    .stroke-print-header {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        position: relative !important;
        margin-bottom: 6px !important;
        min-height: 44px !important;
    }

    .stroke-logo-box {
        position: absolute !important;
        left: 0 !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
    }

    .stroke-print-logo {
        height: 42px !important;
        width: auto !important;
        max-width: 60px !important;
        display: block !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .stroke-title-box {
        text-align: center !important;
        width: 100% !important;
    }

    .stroke-main-title {
        font-size: 13pt !important;
        font-weight: bold !important;
        line-height: 1.2 !important;
        color: #000 !important;
        margin: 0 !important;
    }

    .stroke-sub-title {
        font-size: 10.5pt !important;
        font-weight: bold !important;
        line-height: 1.2 !important;
        color: #000 !important;
        margin-top: 1px !important;
    }

    /* ── Order content ── */
    .order-list {
        padding-left: 12px;
    }

    .order-list li {
        margin-bottom: 3px;
        line-height: 1.3;
    }

    .highlight {
        color: #000 !important;
        font-weight: bold;
    }

    .divider {
        border-top: 1px solid #000;
        margin: 3px 0;
    }

    .dotted-line {
        border-bottom: 1px dotted #000;
    }

    /* ── Fib/AC boxes ── */
    .fib-order-box, .ac-opt {
        font-size: 8pt;
        padding: 4px 6px;
    }

    .fib-order-box.chosen, .ac-opt.recommended {
        border: 2px solid #000 !important;
        background: #f4f4f4 !important;
    }

    .ac-opt.na {
        font-size: 7.5pt;
    }

    .monitor-alert {
        font-size: 7.5pt;
        padding: 3px 5px;
        background: #f9f9f9 !important;
        border-left: 3px solid #000 !important;
    }

    /* ── Sticker box ── */
    .sticker-area {
        width: 48mm;
        height: 16mm;
        font-size: 7pt;
        border: 1px dashed #000 !important;
        padding: 1px 3px;
        line-height: 1.15;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
    }

    .sticker-area strong {
        font-size: 7pt;
        line-height: 1.1;
    }

    .sticker-area small {
        font-size: 5.5pt;
        line-height: 1.1;
    }

    .sticker-area #sticker-hn-text {
        font-size: 7.5pt !important;
        margin-top: 1px !important;
        line-height: 1.1;
    }

    .sticker-box-container {
        margin-top: 2px !important;
        page-break-inside: avoid;
    }

    /* ── TNK reference table ── */
    .tnk-table {
        font-size: 7.5pt;
        width: 100%;
        border-collapse: collapse;
    }

    .tnk-table td, .tnk-table th {
        border: 1px solid #000;
        padding: 2px 4px;
    }

    .tnk-table tr.active-row {
        background: #ddd !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* ── Stroke-specific pages ── */
    .theme-stroke #print-area {
        width: 195mm !important;
        margin: 0 auto !important;
        padding: 3mm 0 !important;
        box-sizing: border-box !important;
    }

    .theme-stroke .grid-header {
        background: transparent !important;
        background-color: transparent !important;
    }

    .stroke-page {
        display: block !important;
        page-break-before: always;
        width: 195mm;
        margin: 0 auto;
        padding: 3mm 0;
        box-sizing: border-box;
    }

    .stroke-checklist {
        font-size: 8.5pt;
        line-height: 1.3;
    }

    .stroke-checklist li::before {
        font-size: 8.5pt;
    }

    .stroke-section-title {
        font-size: 9pt;
        margin-top: 3px;
        padding-top: 3px;
    }

    .stroke-page-header h4 {
        font-size: 12pt;
    }

    .stroke-page-header p {
        font-size: 10pt;
    }

    .consent-text {
        font-size: 9.5pt;
        line-height: 1.5;
    }

    .sig-grid {
        font-size: 9pt;
    }

    .stroke-footnote {
        font-size: 7pt;
        line-height: 1.3;
    }

    .stroke-sticker {
        border: 1px solid #000 !important;
    }

    .p3-table {
        font-size: 9pt;
    }

    /* ── NSTEMI-specific ── */
    .sub-section {
        font-size: 8pt;
    }

    .killip-group,
    .killip-group-vertical {
        display: none !important;
    }

    /* ── General print hygiene ── */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Prevent orphans */
    .grid-cell, .fib-order-box, .ac-opt, .sticker-box-container {
        page-break-inside: avoid;
    }

    .order-row-spacer {
        height: 11.5em !important;
    }

    /* Ensure black text on white */
    .grid-cell, .grid-header, .print-header, .order-list, .fib-order-box, .ac-opt {
        color: #000 !important;
        background: #fff !important;
    }

    .grid-header {
        background: transparent !important;
        background-color: transparent !important;
    }

    .version-attribution {
        display: block !important;
        font-size: 8pt;
        color: #666 !important;
        text-align: left;
        padding-top: 4px;
        border-top: 0.5px solid #ccc;
    }
}
