/* =============================================
   Print CSS - All Pages
   ============================================= */

@media print {

    /* ---- إعدادات عامة ---- */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    @page {
        size: A4;
        margin: 1cm;
    }

    body {
        font-family: 'Arial', 'Tahoma', sans-serif;
        font-size: 10pt;
        line-height: 1.4;
        margin: 0;
        padding: 0;
        direction: rtl;
        background: white !important;
        color: #000 !important;
    }

    /* ---- إخفاء عناصر الشاشة ---- */
    .no-print,
    .sidebar,
    .sidebar-overlay,
    .mobile-menu-btn,
    .top-header-bar,
    .navbar,
    .btn,
    .alert,
    .modal,
    .modal-backdrop,
    .dropdown-menu,
    .print-controls,
    nav,
    #mobileMenuBtn,
    #sidebarCloseBtn,
    .notification-bell {
        display: none !important;
    }

    /* ---- إصلاح الـ layout للطباعة ---- */
    .main-wrapper {
        display: block !important;
    }

    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        padding-top: 0 !important;
        width: 100% !important;
        min-height: auto !important;
        background: white !important;
    }

    .container-fluid {
        padding: 0 !important;
    }

    /* ---- هيدر الطباعة ---- */
    .print-header,
    .icu-report-header {
        text-align: center;
        border-bottom: 2px solid #000 !important;
        margin-bottom: 15px;
        padding-bottom: 10px;
        page-break-after: avoid;
    }

    .print-header h1,
    .icu-report-header h1 {
        font-size: 16pt;
        font-weight: bold;
        color: #000 !important;
        margin: 0 0 5px 0;
    }

    .print-header h2,
    .icu-report-header h2 {
        font-size: 13pt;
        color: #333 !important;
        margin: 0 0 3px 0;
    }

    .print-header p,
    .icu-report-header p {
        font-size: 9pt;
        color: #555 !important;
        margin: 2px 0;
    }

    /* ---- الجداول ---- */
    table {
        width: 100% !important;
        border-collapse: collapse !important;
        margin-bottom: 10px;
        page-break-inside: auto;
    }

    thead {
        display: table-header-group;
    }

    tr {
        page-break-inside: avoid;
    }

    th {
        background-color: #e0e0e0 !important;
        color: #000 !important;
        font-weight: bold;
        font-size: 9pt;
        padding: 5px 4px;
        border: 1px solid #000 !important;
        text-align: center;
    }

    td {
        font-size: 8.5pt;
        padding: 4px;
        border: 1px solid #555 !important;
        text-align: center;
        vertical-align: middle;
        color: #000 !important;
    }

    /* ---- جدول المراقبة ---- */
    .monitoring-table th {
        background-color: #4472C4 !important;
        color: #fff !important;
        font-size: 8pt;
        padding: 3px;
    }

    .monitoring-table td {
        height: 18px;
        font-size: 8pt;
    }

    /* ---- جدول المرضى ---- */
    .patients-table th {
        background-color: #e0e0e0 !important;
        font-size: 9pt;
    }

    .patients-table td:first-child {
        text-align: right !important;
    }

    /* ---- عناوين الأقسام ---- */
    .section-title,
    .section-header {
        background-color: #e0e0e0 !important;
        color: #000 !important;
        font-weight: bold;
        font-size: 11pt;
        padding: 5px 8px;
        margin: 10px 0 5px 0;
        border: 1px solid #000 !important;
        page-break-after: avoid;
    }

    /* ---- الأقسام ---- */
    .section {
        margin: 6px 0;
        border: 1px solid #ccc;
        padding: 5px;
        page-break-inside: avoid;
    }

    /* ---- التوقيعات والفوتر ---- */
    .signature-section,
    .footer,
    .print-footer,
    .report-footer {
        page-break-inside: avoid;
        margin-top: 15px;
    }

    .signature-line {
        border-bottom: 1px solid #000 !important;
        width: 150px;
        height: 20px;
        margin: 5px auto;
        display: inline-block;
    }

    .print-footer,
    .report-footer {
        text-align: center;
        font-size: 8pt;
        color: #555 !important;
        border-top: 1px solid #000 !important;
        padding-top: 5px;
        margin-top: 15px;
    }

    /* ---- ICU Report specific ---- */
    .info-section {
        margin-bottom: 15px;
        page-break-inside: avoid;
    }

    .info-row {
        display: flex;
        justify-content: space-between;
        margin-bottom: 8px;
        border-bottom: 1px solid #ccc !important;
        padding-bottom: 4px;
        align-items: center;
    }

    .info-label {
        font-weight: bold;
        min-width: 160px;
        font-size: 10pt;
        color: #000 !important;
    }

    .info-value {
        flex: 1;
        border-bottom: 1px dotted #000 !important;
        min-height: 18px;
        padding: 2px 5px;
        font-size: 10pt;
        color: #000 !important;
    }

    .notes-section {
        border: 1px solid #000 !important;
        padding: 10px;
        min-height: 80px;
        page-break-inside: avoid;
        background: white !important;
        margin-top: 15px;
    }

    .isolation-list li {
        margin-bottom: 6px;
        border-bottom: 1px dotted #ccc !important;
        padding-bottom: 4px;
        min-height: 20px;
        font-size: 10pt;
    }

    /* ---- Checkboxes للطباعة ---- */
    .checkbox-print {
        width: 14px !important;
        height: 14px !important;
        border: 1px solid #000 !important;
        display: inline-block !important;
        text-align: center !important;
        line-height: 12px !important;
        font-size: 11pt !important;
        background: white !important;
        vertical-align: middle;
    }

    .checkbox-print.checked::after {
        content: '✓' !important;
        font-weight: bold !important;
        color: #000 !important;
    }

    /* ---- page breaks ---- */
    .no-break       { page-break-inside: avoid !important; }
    .break-before   { page-break-before: always !important; }
    .break-after    { page-break-after: always !important; }

    /* ---- مسافات ---- */
    .mb-3, .mb-4 { margin-bottom: 6px !important; }
    .mt-3, .mt-4 { margin-top: 6px !important; }
    p { margin: 2px 0; }
    ul, ol { margin: 3px 0; padding-right: 15px; }
    li { margin-bottom: 2px; font-size: 9pt; }

    /* ---- إخفاء الـ Bootstrap grid gutter ---- */
    .row { margin: 0 !important; }
    [class*="col-"] { padding: 0 2px !important; }
}

/* =============================================
   Screen-only: print preview
   ============================================= */
@media screen {
    .print-preview {
        max-width: 210mm;
        margin: 20px auto;
        padding: 20px;
        background: white;
        box-shadow: 0 0 15px rgba(0,0,0,0.15);
        border-radius: 4px;
    }
}
