﻿/* Basic page setup for print vs screen */
.printdiv {
    display: none !important;
}

@media print {
    /* General page configuration */
    @page {
        size: A4 portrait;
        margin: 0.8cm;
    }

    body, html {
        width: 210mm;
        height: 297mm;
        margin: 0 !important;
        padding: 0 !important;
        font-family: 'Arial', 'Tahoma', sans-serif !important;
        font-size: 10pt !important;
        background-color: #fff !important;
        color: #000 !important;
        direction: rtl !important;
        height: auto !important;
        max-height: 100vh !important;
        overflow: visible !important;
    }

    /* Hide all non-print elements */
    .no-print, .navbar, .sidebar, .footer, .btn, .card,
    .nav, header:not(.print-header), button,
    #sidebar, #content > nav, form, .alert, .panel {
        display: none !important;
    }

    /* Show only the print div */
    #printdiv {
        display: block !important;
        page-break-after: avoid !important;
        page-break-before: avoid !important;
        page-break-inside: avoid !important;
        break-after: avoid-page !important;
        break-before: avoid-page !important;
        break-inside: avoid-page !important;
        width: 100% !important;
        position: relative !important;
        margin: 0 auto !important;
        padding: 0 !important;
        color: #000 !important;
    }

    /* Header section styling - FIXED POSITIONING */
    .print-header {
        position: relative;
        width: 100%;
        margin-bottom: 0.2cm;
        height: 2.5cm;
    }

    .print-logo-container {
        position: absolute;
        top: 0 !important;
        margin-top: 0 !important;
        right: 9cm;
        text-align: center;
        z-index: 5;
    }

    .print-logo {
        width: 70px;
        height: 70px;
    }

    .print-qrcode-container {
        position: absolute;
        top: 0;
        right: 17cm;
        z-index: 5;
    }

    .print-qrcode {
        width: 90px;
        height: 90px;
    }

    .print-watermark-container {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        z-index: 10;
        width: 100%;
        text-align: center;
        pointer-events: none; /* Let clicks go through */
        user-select: none;
        white-space: nowrap;
    }

    .print-watermark-container2 {
        content: "الاستمارة بطالة";
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) rotate(-30deg);
        font-size: 6rem;
        color: #900 !important;
        z-index: 10;
        width: 100%;
        text-align: center;
        pointer-events: none; /* Let clicks go through */
        user-select: none;
        white-space: nowrap;
        opacity: 0.1;
    }

    .print-watermark {
        width: 650px;
        height: 650px;
        opacity: 0.1;
    }

    .print-title-container {
        position: absolute;
        top: 0;
        right: 0cm;
        text-align: center;
        z-index: 5;
    }

    .print-title {
        font-size: 9pt;
        font-weight: 600;
        margin: 0.01cm 0;
    }

    .print-meta-container {
        position: absolute;
        top: 0.2cm;
        right: 13.9cm;
        text-align: left;
        z-index: 5;
    }

    .print-meta {
        font-size: 9pt;
        font-weight: 600;
        margin: 0.01cm 0;
        padding-left: 1cm;
    }

    .print-divider {
        position: absolute;
        width: 100%;
        bottom: 0; /* Fixed: Position at bottom of header */
        left: 0;
        border: none;
        border-top: 2px solid #000;
        margin: 0;
        z-index: 6;
    }

    /* Student photo */
    .print-photo-container {
        position: absolute;
        top: 2.7cm;
        right: 0cm;
        z-index: 1;
    }

    .print-photo {
        width: 80px;
        height: 100px;
        border: 1px solid #ddd;
    }

    /* Verification stamp */
    .print-stamp {
        position: fixed;
        top: 2.8cm;
        right: 14.5cm;
        z-index: 2;
        width: 200px;
    }

    .stamp-content {
        width: 180px;
        border: 2px solid #900;
        border-radius: 5px;
        padding: 8px;
        text-align: center;
        color: #900 !important;
        font-size: 9pt;
        font-weight: bold;
        line-height: 1.2;
        background-color: #fff;
        -webkit-print-color-adjust: exact;
    }

    /* Section styling */
    .print-section-for-personal-info {
        background-color: #ffd800 !important;
        position: relative;
        width: 100%;
        margin-top: 0cm;
        margin-bottom: 0.5cm;
        padding-right: 2.4cm;
        page-break-inside: avoid;
        clear: both;
    }

    .print-section {
        background-color: #ffd800 !important;
        position: relative;
        width: 100%;
        margin-top: 0cm;
        margin-bottom: 0.2cm;
        padding-right: 0cm;
        page-break-inside: avoid;
        clear: both;
    }

    /* Start personal info section further down to avoid overlap */
    .print-personal-info {
        margin-top: 0cm; /* Increased from original value */
    }

    .print-section-title {
        font-size: 12pt;
        font-weight: bold;
        margin-bottom: 0.2cm;
        padding: 2px 15px;
        background-color: #696969 !important;
        color: white !important;
        -webkit-print-color-adjust: exact;
    }

    .print-field {
        font-size: 9pt;
        font-weight: 600;
        line-height: 1.2;
        margin: 0.1cm 0;
        text-align: right;
    }

    /* Warning for incomplete data */
    .print-warning {
        position: relative;
        margin-top: 3cm;
        font-size: 12pt;
        font-weight: bold;
        text-align: center;
        color: #900 !important;
    }

    /* Special text styling */
    .print-highlight {
        color: #900 !important;
        -webkit-print-color-adjust: exact;
    }

    .print-underline {
        text-decoration: underline !important;
    }

    .print-commitment {
        color: #900 !important;
        -webkit-print-color-adjust: exact;
        font-weight: 600;
    }

    /* Signature area */
    .print-signature {
        position: relative;
        margin-top: 1cm;
        text-align: center;
        padding-right: 7cm;
    }

    .signature-label {
        font-size: 10pt;
        font-weight: 600;
    }

    .signature-name {
        font-size: 10pt;
        font-weight: 600;
        margin-top: 0.1cm;
    }

    /* Force all elements to be visible */
    * {
        visibility: visible !important;
        overflow: visible !important;
    }

    .no-print, footer, nav, .navbar, .sidebar, .panel-heading, .panel-footer {
        display: none !important;
    }
}
