/**
 * Neopaed Voice — Professional Print Stylesheet
 * ────────────────────────────────────────────────
 * Shared across all printable pages.
 * Design: Teal (#00695C) accent, clean sans-serif, A4 portrait.
 * Include via: <link rel="stylesheet" href="print-styles.css" media="print">
 */

@media print {

    /* ── Page setup ── */
    @page {
        size: A4 portrait;
        margin: 15mm 12mm 20mm 12mm;
    }

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

    body {
        background: #fff !important;
        margin: 0;
        padding: 0;
        font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
        font-size: 11pt;
        color: #1a1a1a;
        line-height: 1.5;
    }

    /* ── Hide all UI chrome ── */
    .nav-bar,
    .sidebar,
    .no-print,
    .btn-mic,
    .recording-pulse,
    .voice-controls,
    .status-msg,
    .collapse-icon {
        display: none !important;
    }

    .page-layout {
        display: block !important;
    }

    .container,
    .page-content {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }


    /* ═══════════════════════════════════════════
       PRINT HEADER — Hospital Branding
       ═══════════════════════════════════════════ */

    .rx-print-header,
    .print-header-container {
        display: flex !important;
        align-items: center;
        gap: 16px;
        padding-bottom: 10px;
        border-bottom: 3px solid #00695C;
        margin-bottom: 6px;
    }

    .rx-print-header img,
    .print-header-container img {
        max-height: 55px;
        max-width: 55px;
        border-radius: 50%;
        object-fit: contain;
    }

    .print-header-text {
        flex: 1;
    }

    .print-hospital-name {
        font-size: 20pt;
        font-weight: 800;
        color: #00695C;
        letter-spacing: 0.5px;
        margin: 0;
        line-height: 1.2;
    }

    .print-hospital-dept {
        font-size: 10pt;
        color: #37474F;
        font-weight: 600;
        margin: 2px 0 0 0;
    }

    .print-hospital-addr {
        font-size: 8pt;
        color: #666;
        margin: 2px 0 0 0;
    }

    /* Doctors Listing */
    .print-doctors-section {
        margin: 6px 0 4px 0;
    }

    .print-doctors-title {
        font-size: 9pt;
        font-weight: 700;
        color: #333;
        text-decoration: underline;
        margin-bottom: 3px;
    }

    .print-doctors-list {
        font-size: 9pt;
        line-height: 1.6;
        color: #1a1a1a;
    }

    .print-doctor-line {
        margin: 0;
    }

    .print-doctor-line .doc-name {
        font-weight: 700;
    }

    .print-doctor-line .doc-quals {
        font-weight: 400;
    }

    /* Print-only Diagnosis section */
    .print-diagnosis-section {
        margin: 10px 0;
    }

    .print-diagnosis-title {
        font-size: 11pt;
        margin-bottom: 4px;
    }

    .print-diagnosis-content {
        font-size: 10pt;
        padding-left: 20px;
        line-height: 1.6;
        white-space: pre-wrap;
    }

    /* Hide in-body diagnosis on print (already shown after baby details) */
    #diagnosisSectionInBody {
        display: none !important;
    }

    /* Document Title Banner */
    .print-doc-title {
        font-size: 12pt;
        font-weight: 700;
        color: #00695C;
        text-align: center;
        text-transform: uppercase;
        letter-spacing: 1px;
        margin: 8px 0 10px 0;
        padding: 4px 0;
        border-top: 1px solid #B2DFDB;
        border-bottom: 1px solid #B2DFDB;
    }


    /* ═══════════════════════════════════════════
       PATIENT DEMOGRAPHICS — Grid Table
       ═══════════════════════════════════════════ */

    .print-demographics,
    .op-patient-card {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr);
        gap: 0;
        background: #fff !important;
        border: 1.5px solid #00695C;
        border-radius: 0;
        padding: 0 !important;
        margin-bottom: 10px !important;
        font-size: 9pt;
    }

    .print-demographics .pg-item,
    .op-patient-card .pg-item {
        padding: 4px 8px;
        border-bottom: 1px solid #e0e0e0;
        border-right: 1px solid #e0e0e0;
    }

    .print-demographics .pg-item:nth-child(4n),
    .op-patient-card .pg-item:nth-child(4n) {
        border-right: none;
    }

    .print-demographics .pg-label,
    .op-patient-card .pg-label {
        font-weight: 700;
        color: #00695C !important;
        font-size: 7pt;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .print-demographics input,
    .op-patient-card input {
        border: none !important;
        padding: 0 !important;
        font-weight: 600;
        font-size: 9pt;
        color: #1a1a1a;
        background: transparent !important;
    }


    /* ═══════════════════════════════════════════
       CLINICAL SECTIONS — Teal left-border
       ═══════════════════════════════════════════ */

    .print-section {
        margin-bottom: 8px;
        page-break-inside: avoid;
    }

    .print-section-title {
        color: #00695C;
        font-size: 10pt;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        border-left: 4px solid #00695C;
        padding: 4px 12px;
        margin-bottom: 2px;
    }

    .print-section-body {
        padding: 2px 12px 6px 20px;
        font-size: 10pt;
        line-height: 1.5;
        color: #333;
    }

    .print-section-body p {
        margin: 0;
    }

    /* For pages using op-section class */
    .op-section {
        border: none !important;
        border-radius: 0 !important;
        margin-bottom: 4px !important;
        page-break-inside: avoid;
    }

    .op-section-header {
        background: #fff !important;
        color: #00695C !important;
        border-bottom: none !important;
        border-left: 4px solid #00695C !important;
        padding: 4px 12px !important;
        font-size: 10pt;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .op-section-body {
        padding: 2px 12px 6px 20px !important;
    }

    .op-section-body textarea,
    .print-section textarea {
        border: none !important;
        padding: 0 !important;
        box-shadow: none !important;
        resize: none !important;
        font-size: 10pt;
        color: #333;
        min-height: auto !important;
        height: auto !important;
        overflow: hidden;
        line-height: 1.5;
        background: transparent !important;
        width: 100%;
    }


    /* ═══════════════════════════════════════════
       TABLES — Medication, Investigations, etc.
       ═══════════════════════════════════════════ */

    .print-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 9pt;
        margin-bottom: 10px;
    }

    .print-table thead tr {
        background: #00695C !important;
        color: #fff !important;
    }

    .print-table th {
        padding: 5px 8px;
        font-weight: 600;
        text-align: left;
        font-size: 8pt;
        text-transform: uppercase;
    }

    .print-table td {
        padding: 4px 8px;
        border-bottom: 1px solid #e0e0e0;
    }

    .print-table tbody tr:nth-child(even) {
        background: #f9f9f9;
    }

    /* Medication rx-cards */
    .rx-card {
        border: 1px solid #ddd !important;
        border-radius: 0 !important;
        padding: 4px 8px !important;
        margin-bottom: 4px !important;
        background: #fff !important;
        page-break-inside: avoid;
    }

    .rx-row {
        gap: 4px !important;
        margin-bottom: 2px !important;
        font-size: 9pt;
    }

    .rx-row label {
        font-size: 7pt;
        color: #00695C !important;
        font-weight: 700;
    }

    .rx-row input,
    .rx-row select {
        border: none !important;
        padding: 0 !important;
        font-size: 9pt;
        font-weight: 500;
        background: transparent !important;
    }

    .rx-instructions-input {
        border: none !important;
        padding: 0 !important;
        font-size: 9pt;
        background: transparent !important;
    }


    /* ═══════════════════════════════════════════
       PRINT FOOTER — Signature & Stamp
       ═══════════════════════════════════════════ */

    .rx-print-footer,
    .print-footer-container {
        display: block !important;
        margin-top: 30px;
        border-top: 2px solid #00695C;
        padding-top: 12px;
    }

    .print-footer-content {
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
    }

    .print-stamp-area {
        border: 1.5px dashed #aaa;
        width: 120px;
        height: 60px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 7pt;
        color: #aaa;
    }

    .print-confidential {
        text-align: center;
        font-size: 7pt;
        color: #999;
        font-style: italic;
    }

    .print-signature-block {
        text-align: center;
        min-width: 200px;
    }

    .print-signature-line {
        border-top: 1px solid #333;
        padding-top: 6px;
        margin-top: 30px;
    }

    .print-doc-name {
        font-weight: 700;
        font-size: 10pt;
        color: #1a1a1a;
    }

    .print-doc-qual,
    .print-doc-reg {
        font-size: 8pt;
        color: #555;
    }


    /* ═══════════════════════════════════════════
       DIAGNOSIS CODES
       ═══════════════════════════════════════════ */

    #diagnosisCodes {
        margin-bottom: 4px !important;
    }

    #diagnosisCodes .snomed-badge {
        background: #E0F2F1 !important;
        color: #00695C !important;
        padding: 1px 6px;
        margin: 1px;
        font-size: 8pt;
        border-radius: 3px;
    }


    /* ═══════════════════════════════════════════
       DISCHARGE SUMMARY SPECIFIC
       ═══════════════════════════════════════════ */

    .discharge-section {
        border: none !important;
        border-radius: 0 !important;
        margin-bottom: 4px !important;
        page-break-inside: avoid;
    }

    .discharge-section-header {
        background: #fff !important;
        color: #00695C !important;
        border-left: 4px solid #00695C !important;
        padding: 4px 12px !important;
        font-size: 10pt;
        font-weight: 700;
        text-transform: uppercase;
    }

    .discharge-section-body {
        padding: 2px 12px 6px 20px !important;
        font-size: 10pt;
    }

    /* Sub-sections (Systems Review) */
    .print-subsection-title {
        font-weight: 700;
        color: #37474F;
        font-size: 9pt;
        text-transform: uppercase;
        margin-top: 6px;
        margin-bottom: 2px;
    }


    /* ═══════════════════════════════════════════
       PRESCRIPTION / CPOE SPECIFIC
       ═══════════════════════════════════════════ */

    .prescription-drug-table {
        width: 100%;
        border-collapse: collapse;
        margin-top: 10px;
    }

    .prescription-drug-table th {
        background: #00695C !important;
        color: #fff !important;
        padding: 6px 10px;
        font-size: 8pt;
        text-transform: uppercase;
        font-weight: 700;
    }

    .prescription-drug-table td {
        padding: 5px 10px;
        border-bottom: 1px solid #e0e0e0;
        font-size: 9pt;
    }


    /* ═══════════════════════════════════════════
       HELPER — Hide empty sections
       ═══════════════════════════════════════════ */

    .op-section:has(textarea:placeholder-shown:not(:focus)) {
        display: none !important;
    }


    /* ═══════════════════════════════════════════
       BABY DETAILS TABLE — Discharge Summaries
       ═══════════════════════════════════════════ */

    .no-screen {
        display: block !important;
    }

    .baby-details-table {
        width: 100%;
        border-collapse: collapse;
        border: 1.5px solid #333;
        margin-bottom: 12px;
        font-size: 10pt;
    }

    .baby-details-title-row td {
        padding: 6px 10px;
        border-bottom: 1.5px solid #333;
        font-size: 11pt;
    }

    .baby-details-table td {
        padding: 4px 10px;
        border-bottom: 1px solid #ddd;
        vertical-align: top;
    }

    .baby-details-table .bd-label {
        font-weight: 700;
        color: #333;
        width: 22%;
        white-space: nowrap;
    }

    .baby-details-table .bd-value {
        font-weight: 400;
        color: #1a1a1a;
        width: 28%;
    }


    /* ═══════════════════════════════════════════
       PRINT HEADER (injected by print-header.js)
       ═══════════════════════════════════════════ */
    .print-header {
        display: block !important;
        margin-bottom: 12px;
    }
}

/* Screen-only: hide print-only blocks */
.no-screen {
    display: none;
}

/* Screen-only: hide print header (shown only when printing) */
.print-header {
    display: none;
}
