/**
 * أنماط الطباعة العامة
 * يتم تحميل هذا الملف في صفحة HTML عند الطباعة
 */

@media print {
  @page {
    size: A4;
    margin: 0.5cm;
  }

  body, * {
    -webkit-print-color-adjust: exact !important; /* Chrome, Safari, Edge */
    color-adjust: exact !important; /* Standard */
    print-color-adjust: exact !important; /* Firefox */
  }

  body {
    font-family: 'Arial', 'Helvetica', sans-serif !important;
    background-color: white !important;
    color: black !important;
    font-size: 12px !important;
    line-height: 1.4 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* ألوان الخلفية - موفرة للحبر */
  .bg-gray-100 {
    background-color: #f3f4f6 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .bg-slate-100 {
    background-color: #f1f5f9 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* ألوان النص */
  .text-gray-800 {
    color: #1f2937 !important;
  }

  .text-gray-900 {
    color: #111827 !important;
  }

  .text-gray-700 {
    color: #374151 !important;
  }

  .text-gray-600 {
    color: #4b5563 !important;
  }

  /* ألوان النص */
  .text-white {
    color: white !important;
  }

  .text-gray-800 {
    color: #1f2937 !important;
  }

  .text-gray-500 {
    color: #6b7280 !important;
  }

  /* الحدود */
  .border-blue-300 {
    border-color: #93c5fd !important;
  }

  .border-gray-200 {
    border-color: #e5e7eb !important;
  }

  .border-gray-300 {
    border-color: #d1d5db !important;
  }

  .border-b-2 {
    border-bottom-width: 2px !important;
  }

  .border {
    border-width: 1px !important;
  }

  /* الجداول */
  table {
    border-collapse: collapse;
    width: 100%;
  }

  table, th, td {
    border: 1px solid #e2e8f0 !important;
  }

  th, td {
    padding: 8px;
    text-align: left;
  }

  th {
    background-color: #f8fafc !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* تخطيط الصفحة */
  .p-6 {
    padding: 1.5rem !important;
  }

  .p-4 {
    padding: 1rem !important;
  }

  .p-3 {
    padding: 0.75rem !important;
  }

  .p-2 {
    padding: 0.5rem !important;
  }

  .m-4 {
    margin: 1rem !important;
  }

  .mb-4 {
    margin-bottom: 1rem !important;
  }

  .mt-4 {
    margin-top: 1rem !important;
  }

  /* إخفاء عناصر معينة عند الطباعة */
  .print\:hidden {
    display: none !important;
  }

  /* أنماط TailwindCSS للطباعة */
  .text-3xl {
    font-size: 1.875rem !important;
    font-weight: bold !important;
  }

  .text-2xl {
    font-size: 1.5rem !important;
    font-weight: bold !important;
  }

  .text-xl {
    font-size: 1.25rem !important;
    font-weight: bold !important;
  }

  .text-lg {
    font-size: 1.125rem !important;
  }

  .text-sm {
    font-size: 0.875rem !important;
  }

  .text-xs {
    font-size: 0.75rem !important;
  }

  .font-bold {
    font-weight: bold !important;
  }

  .text-center {
    text-align: center !important;
  }

  .text-right {
    text-align: right !important;
  }

  .text-left {
    text-align: left !important;
  }

  /* تخطيط Flexbox */
  .flex {
    display: flex !important;
  }

  .justify-between {
    justify-content: space-between !important;
  }

  .justify-center {
    justify-content: center !important;
  }

  .items-center {
    align-items: center !important;
  }

  .items-start {
    align-items: flex-start !important;
  }

  /* الحدود والزوايا */
  .rounded-t-md {
    border-top-left-radius: 0.375rem !important;
    border-top-right-radius: 0.375rem !important;
  }

  .rounded-b-md {
    border-bottom-left-radius: 0.375rem !important;
    border-bottom-right-radius: 0.375rem !important;
  }

  .border-t {
    border-top: 1px solid #e5e7eb !important;
  }

  .border-b {
    border-bottom: 1px solid #e5e7eb !important;
  }

  /* تحسين الجداول */
  .table-auto {
    table-layout: auto !important;
  }

  .w-full {
    width: 100% !important;
  }

  /* إخفاء عناصر التحكم */
  button, .print\:hidden, [class*="print:hidden"] {
    display: none !important;
  }

  /* تحسينات إضافية */
  .max-w-4xl {
    max-width: 56rem !important;
  }

  .mx-auto {
    margin-left: auto !important;
    margin-right: auto !important;
  }

  .overflow-y-auto {
    overflow-y: visible !important;
  }

  .overflow-auto, .overflow-x-auto {
    overflow: visible !important;
  }

  .max-h-\[calc\(100vh-12rem\)\] {
    max-height: none !important;
  }

  /* إصلاح مشكلة شريط التمرير والمساحة الفارغة في الجداول */
  .relative.w-full.overflow-auto {
    position: static !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    display: block !important;
  }

  /* ضمان التوزيع المتوازن للجدول */
  table {
    margin: 0 !important;
    border-collapse: collapse !important;
    width: 100% !important;
    table-layout: auto !important;
  }

  /* تحديد الحد الأدنى والأقصى للأعمدة مع التكيف التلقائي */
  table th:nth-child(1), table td:nth-child(1) {
    width: auto !important;
    min-width: 60px !important;
    max-width: 100px !important;
    white-space: nowrap !important;
  }

  table th:nth-child(2), table td:nth-child(2) {
    width: auto !important;
    min-width: 80px !important;
    max-width: 150px !important;
  }

  table th:nth-child(3), table td:nth-child(3) {
    width: auto !important;
    min-width: 150px !important;
  }

  table th:nth-child(4), table td:nth-child(4) {
    width: auto !important;
    min-width: 70px !important;
    max-width: 120px !important;
    white-space: nowrap !important;
  }

  table th:nth-child(5), table td:nth-child(5) {
    width: auto !important;
    min-width: 70px !important;
    max-width: 120px !important;
    white-space: nowrap !important;
  }

  table th:nth-child(6), table td:nth-child(6) {
    width: auto !important;
    min-width: 80px !important;
    max-width: 130px !important;
    white-space: nowrap !important;
  }

  /* إصلاح مشكلة التوسيط والمساحات الجانبية */
  .print-content, .print-container {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* إصلاح مشكلة الـ padding في المحتوى */
  .p-6 {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
  }

  /* ضمان التوزيع المثالي عند margin: none */
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100% !important;
  }

  /* إصلاح مشكلة التصاق الجدول بالجانب الأيمن */
  th, td {
    padding-left: 8px !important;
    padding-right: 8px !important;
    text-align: left !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
    vertical-align: top !important;
  }

  /* معالجة خاصة لكل عمود حسب طبيعة المحتوى */

  /* عمود Quantité - أرقام قصيرة */
  table th:nth-child(1), table td:nth-child(1) {
    text-align: center !important;
    padding: 4px 8px !important;
  }

  /* عمود N° d'article - قد يكون طويل */
  table th:nth-child(2), table td:nth-child(2) {
    white-space: normal !important;
    word-break: break-word !important;
    padding: 4px 8px !important;
  }

  /* عمود Description - نص طويل */
  table th:nth-child(3), table td:nth-child(3) {
    white-space: normal !important;
    word-break: break-word !important;
    hyphens: auto !important;
    line-height: 1.3 !important;
    padding: 4px 8px !important;
  }

  /* أعمدة الأسعار - أرقام */
  table th:nth-child(4), table td:nth-child(4),
  table th:nth-child(5), table td:nth-child(5),
  table th:nth-child(6), table td:nth-child(6) {
    text-align: right !important;
    padding: 4px 8px !important;
  }

  .text-right {
    text-align: right !important;
  }

  .text-center {
    text-align: center !important;
  }

  /* تثبيت footer الشركة في أسفل الصفحة */
  .print\:min-h-screen {
    min-height: 100vh !important;
  }

  .print\:flex {
    display: flex !important;
  }

  .print\:flex-col {
    flex-direction: column !important;
  }

  .print\:flex-1 {
    flex: 1 !important;
    padding-bottom: 80px !important;
  }

  .print\:mt-auto {
    margin-top: auto !important;
  }

  .print\:fixed {
    position: fixed !important;
  }

  .print\:bottom-0 {
    bottom: 0 !important;
  }

  .print\:left-0 {
    left: 0 !important;
  }

  .print\:right-0 {
    right: 0 !important;
  }

  .print\:rounded-none {
    border-radius: 0 !important;
  }

  .print\:bg-slate-100 {
    background-color: #f1f5f9 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}
