/* 
 * سكرتيري - تنسيقات الطباعة الاحترافية
 * v2.5
 * 
 * يطبق فقط عند الطباعة (@media print)
 * يخفي العناصر غير الضرورية ويعرض الوثيقة بشكل احترافي
 */

@media print {
    
    /* ========== إعدادات الصفحة العامة ========== */
    @page {
        size: A4;
        margin: 1.5cm 1.2cm;
    }
    
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
    
    html, body {
        background: white !important;
        color: #000 !important;
        font-family: 'Tajawal', 'Arial', sans-serif !important;
        font-size: 11pt !important;
        line-height: 1.5 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    body * {
        visibility: visible;
    }
    
    main {
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .container {
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* ========== إخفاء العناصر غير الضرورية ========== */
    .navbar,
    .footer,
    nav,
    footer,
    .no-print,
    [data-bs-toggle="dropdown"],
    .dropdown-menu,
    .btn-floating-print,
    .alert-dismissible,
    .breadcrumb,
    .navbar-toggler,
    button:not(.print-keep),
    .btn:not(.print-keep),
    .theme-toggle-btn,
    #avatarModal,
    .modal,
    .modal-backdrop,
    .toast,
    form,
    input,
    select,
    textarea,
    .pagination,
    .alert-row .alert-arrow,
    [onclick],
    .input-group,
    .collapse:not(.show) {
        display: none !important;
    }
    
    /* ========== ترويسة الطباعة (Header) ========== */
    body::before {
        content: "📋 سكرتيري - منصة إدارة الوثائق الشخصية";
        display: block;
        text-align: center;
        font-size: 9pt;
        color: #555 !important;
        padding-bottom: 8px;
        margin-bottom: 16px;
        border-bottom: 2px solid #0a2540;
        font-weight: bold;
    }
    
    /* ========== تذييل الطباعة (Footer) ========== */
    body::after {
        content: "تم الطباعة من dhamani.nx7v.com - " attr(data-print-date);
        display: block;
        position: fixed;
        bottom: 0.5cm;
        left: 0;
        right: 0;
        text-align: center;
        font-size: 8pt;
        color: #999 !important;
        border-top: 1px solid #ddd;
        padding-top: 5px;
    }
    
    /* ========== تنسيق العناوين ========== */
    h1, h2, h3, h4, h5, h6 {
        color: #0a2540 !important;
        page-break-after: avoid;
        margin-top: 12px !important;
    }
    
    h1 { font-size: 20pt !important; }
    h2 { font-size: 16pt !important; }
    h3 { font-size: 14pt !important; }
    h4 { font-size: 13pt !important; }
    h5 { font-size: 12pt !important; }
    h6 { font-size: 11pt !important; }
    
    /* ========== البطاقات والكاردات ========== */
    .card {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        background: white !important;
        page-break-inside: avoid;
        margin-bottom: 12px !important;
        border-radius: 4px !important;
    }
    
    .card-header {
        background: #f5f5f5 !important;
        color: #0a2540 !important;
        border-bottom: 1px solid #ddd !important;
        padding: 8px 12px !important;
    }
    
    .card-body {
        padding: 12px !important;
        background: white !important;
        color: #000 !important;
    }
    
    /* إخفاء card-footer (عادةً فيه أزرار) */
    .card-footer {
        display: none !important;
    }
    
    /* ========== الـ Banner (الـ gradient header) ========== */
    .banner,
    [style*="gradient"] {
        background: #0a2540 !important;
        color: white !important;
        padding: 15px !important;
        border-radius: 4px !important;
        margin-bottom: 12px !important;
    }
    
    .banner * {
        color: white !important;
    }
    
    /* ========== الـ Tables ========== */
    table {
        width: 100% !important;
        border-collapse: collapse !important;
        margin-bottom: 12px !important;
        page-break-inside: avoid;
    }
    
    th {
        background: #f0f0f0 !important;
        color: #0a2540 !important;
        font-weight: bold !important;
        padding: 6px 8px !important;
        border: 1px solid #ccc !important;
        text-align: right;
    }
    
    td {
        padding: 6px 8px !important;
        border: 1px solid #ddd !important;
        background: white !important;
    }
    
    /* ========== الـ Badges ========== */
    .badge {
        background: #f0f0f0 !important;
        color: #000 !important;
        border: 1px solid #ccc !important;
        padding: 2px 8px !important;
        font-weight: 600 !important;
    }
    
    .badge.bg-success { background: #d4edda !important; color: #155724 !important; }
    .badge.bg-warning { background: #fff3cd !important; color: #856404 !important; }
    .badge.bg-danger { background: #f8d7da !important; color: #721c24 !important; }
    .badge.bg-info { background: #d1ecf1 !important; color: #0c5460 !important; }
    .badge.bg-primary { background: #cfe2ff !important; color: #084298 !important; }
    .badge.bg-secondary { background: #e2e3e5 !important; color: #41464b !important; }
    
    /* ========== الـ Alerts ========== */
    .alert {
        border: 1px solid #ddd !important;
        padding: 8px 12px !important;
        margin-bottom: 10px !important;
        page-break-inside: avoid;
    }
    
    .alert-success { background: #d4edda !important; color: #155724 !important; border-color: #c3e6cb !important; }
    .alert-warning { background: #fff3cd !important; color: #856404 !important; border-color: #ffeaa7 !important; }
    .alert-danger { background: #f8d7da !important; color: #721c24 !important; border-color: #f5c6cb !important; }
    .alert-info { background: #d1ecf1 !important; color: #0c5460 !important; border-color: #bee5eb !important; }
    
    /* ========== شريط التقدم ========== */
    .progress {
        background: #eee !important;
        height: 8px !important;
        border-radius: 4px !important;
        overflow: hidden !important;
        margin: 4px 0 !important;
    }
    
    .progress-bar {
        background: #0a2540 !important;
        color: white !important;
    }
    
    .progress-bar.bg-success { background: #28a745 !important; }
    .progress-bar.bg-warning { background: #ffc107 !important; }
    .progress-bar.bg-danger { background: #dc3545 !important; }
    
    /* ========== الصور ========== */
    img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }
    
    /* إخفاء الصور الكبيرة (المرفقات) - تطبع منفصلة لو احتاج */
    .attachment-preview {
        max-width: 200px !important;
        max-height: 150px !important;
    }
    
    /* ========== الـ Lists ========== */
    .list-group-item {
        border: 1px solid #ddd !important;
        padding: 8px 12px !important;
        background: white !important;
    }
    
    /* ========== Page breaks ========== */
    .page-break {
        page-break-after: always;
    }
    
    .avoid-break {
        page-break-inside: avoid;
    }
    
    /* ========== روابط ========== */
    a {
        color: #0a2540 !important;
        text-decoration: none !important;
    }
    
    /* لا نطبع الروابط لأنها داخلية */
    a::after {
        content: "" !important;
    }
    
    /* ========== الـ Icons ========== */
    .bi {
        color: #0a2540 !important;
    }
    
    /* ========== رفع جودة عرض البيانات ========== */
    .ocr-result-item,
    .info-row {
        border-right: 3px solid #0a2540 !important;
        padding: 6px 10px !important;
        background: #f9f9f9 !important;
        margin-bottom: 6px !important;
    }
    
    /* ========== الـ Avatar في navbar - مخفي ========== */
    .avatar-img,
    .brand-logo {
        display: none !important;
    }
    
    /* ========== عرض كامل للأعمدة ========== */
    .col-md-3, .col-md-4, .col-md-6, .col-md-8, .col-md-9,
    .col-lg-3, .col-lg-4, .col-lg-6, .col-lg-8, .col-lg-9 {
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
    
    /* الـ row الأساسي */
    .row {
        display: block !important;
    }
}

/* ========== الزر العائم للطباعة (يظهر فقط على الشاشة) ========== */
@media screen {
    .btn-floating-print {
        position: fixed;
        bottom: 30px;
        left: 30px;
        z-index: 999;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, #0a2540, #1e3a5f);
        color: white;
        border: none;
        box-shadow: 0 4px 20px rgba(10, 37, 64, 0.4);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
        cursor: pointer;
        transition: all 0.3s;
    }
    
    .btn-floating-print:hover {
        transform: translateY(-3px) scale(1.05);
        box-shadow: 0 6px 25px rgba(10, 37, 64, 0.5);
        color: white;
    }
    
    .btn-floating-print::after {
        content: "طباعة";
        position: absolute;
        right: 70px;
        background: #0a2540;
        color: white;
        padding: 6px 12px;
        border-radius: 6px;
        font-size: 0.85rem;
        white-space: nowrap;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
    }
    
    .btn-floating-print:hover::after {
        opacity: 1;
    }
    
    @media (max-width: 768px) {
        .btn-floating-print {
            bottom: 20px;
            left: 20px;
            width: 50px;
            height: 50px;
            font-size: 1.3rem;
        }
        .btn-floating-print::after {
            display: none;
        }
    }
}
