/* ==========================================================
   FLUX Reports - A4 Printable Report & PDF Export Stylesheet
   Agency: Flux Ads
   Strictly engineered for A4 paper print / PDF rendering
   ========================================================== */

/* إعدادات الشاشة للمعاينة الفورية */
.print-preview-container {
  background: #0B0F19;
  min-height: 100vh;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  direction: rtl;
  font-family: 'Cairo', sans-serif;
}

/* شريط أدوات المعاينة والتحكم (يختفي عند الطباعة) */
.preview-toolbar {
  width: 100%;
  max-width: 210mm;
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.preview-toolbar-title {
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ورقة التقرير A4 */
.a4-page {
  width: 210mm;
  min-height: 297mm;
  background: #FFFFFF !important;
  color: #111827 !important;
  padding: 15mm 16mm;
  margin: 0 auto;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* 1. ترويسة التقرير (Header) بتنسيق راقٍ ومتوازن */
.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #F8FAFC;
  border: 1.5px solid #E2E8F0;
  border-radius: 14px;
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
}

/* شريط زخرفي علوي باللون الأزرق المعتمد */
.report-header::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, #2563EB 0%, #06B6D4 100%);
}

/* شعار واسم الوكالة على اليسار */
.report-header-logo-box {
  order: 2; /* يظهر يساراً في الاتجاه العربي */
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
}

.report-header-logo {
  max-height: 46px;
  width: auto;
  object-fit: contain;
  display: block;
}

.agency-corporate-name {
  font-size: 0.98rem;
  font-weight: 900;
  color: #0F172A;
  margin-top: 2px;
  text-align: left;
  width: 100%;
}

.agency-tagline {
  font-size: 0.73rem;
  color: #64748B;
  font-weight: 600;
  text-align: left;
  width: 100%;
}

/* بيانات التقرير والعميل على اليمين */
.report-header-meta {
  order: 1; /* يظهر يميناً */
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.report-meta-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.report-badge-id {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #EFF6FF;
  color: #1D4ED8;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid #BFDBFE;
  letter-spacing: 0.5px;
}

.report-badge-date {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #FFFFFF;
  color: #475569;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #CBD5E1;
}

.client-info-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.client-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #94A3B8;
}

.report-client-name {
  font-size: 1.25rem;
  font-weight: 900;
  color: #0F172A;
  margin: 0;
  line-height: 1.3;
}

.report-client-contact {
  font-size: 0.82rem;
  color: #64748B;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* 2. بطاقات ملخص الأداء العلوية (3 بطاقات) */
.kpi-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.kpi-card {
  background: #F8FAFC;
  border: 1.5px solid #E2E8F0;
  border-radius: 12px;
  padding: 14px 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
  background: #2563EB;
}

.kpi-card.green::before { background: #059669; }
.kpi-card.purple::before { background: #7C3AED; }

.kpi-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #64748B;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 1.45rem;
  font-weight: 900;
  color: #0F172A;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
}

.kpi-currency {
  font-size: 0.85rem;
  font-weight: 700;
  color: #64748B;
}

.kpi-subtext {
  font-size: 0.72rem;
  color: #94A3B8;
  font-weight: 600;
  margin-top: 4px;
}

/* 3. قسم الملاحظات الفنية */
.report-notes-section {
  background: #F1F5F9;
  border-right: 4px solid #3B82F6;
  border-radius: 8px;
  padding: 12px 18px;
  margin-bottom: 22px;
}

.report-notes-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: #1E3A8A;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.report-notes-text {
  font-size: 0.85rem;
  line-height: 1.7;
  color: #334155;
  white-space: pre-line;
}

/* 4. الرسوم البيانية (Charts) */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 16px;
  margin-bottom: 22px;
}

.chart-box {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}

.chart-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #334155;
  margin-bottom: 10px;
}

.chart-canvas-container {
  position: relative;
  height: 185px;
  width: 100%;
}

/* 5. الجدول التفصيلي لأداء المنصات */
.table-section {
  margin-bottom: 22px;
}

.table-section-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #0F172A;
  margin-bottom: 10px;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  text-align: center;
}

.print-table th {
  background: #0F172A;
  color: #FFFFFF;
  padding: 10px 10px;
  font-weight: 800;
  border: 1px solid #0F172A;
  white-space: nowrap !important;
  font-size: 0.82rem;
  letter-spacing: -0.2px;
}

.print-table td {
  padding: 8px 10px;
  border: 1px solid #E2E8F0;
  font-weight: 700;
  color: #334155;
  white-space: nowrap !important;
  vertical-align: middle;
}

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

.print-table tfoot td {
  background: #F1F5F9;
  font-weight: 900;
  color: #0F172A;
  border-top: 2px solid #CBD5E1;
  white-space: nowrap !important;
}

.platform-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 0;
}

.platform-cell img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  border-radius: 6px;
  display: block;
}

/* 6. التذييل والختم الرسمي (Footer & Official Stamp) */
.report-footer-section {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-top: 18px;
  border-top: 2px solid #E5E7EB;
  margin-top: auto;
  page-break-inside: avoid;
}

.official-verification-info {
  font-size: 0.78rem;
  color: #64748B;
  line-height: 1.6;
}

.verification-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ECFDF5;
  color: #059669;
  font-weight: 800;
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid #A7F3D0;
  margin-bottom: 6px;
}

.stamp-box-wrapper {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stamp-sign-title {
  font-size: 0.8rem;
  font-weight: 800;
  color: #334155;
  margin-bottom: 6px;
}

/* ختم فلوكس الرسمي بمساحة وحجم متناسق */
.stamp-image {
  width: 120px;
  height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,0.1));
}

.signature-line {
  margin-top: 4px;
  font-size: 0.72rem;
  color: #94A3B8;
  border-top: 1px dashed #CBD5E1;
  padding-top: 4px;
  width: 130px;
}

/* ==========================================================
   قواعد الطباعة الصارمة (@media print) لمتصفحات الويب و PDF
   ========================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 10mm 12mm 10mm 12mm;
  }

  /* إخفاء عناصر التحكم وأزرار النظام كلياً أثناء الطباعة */
  .preview-toolbar,
  .navbar,
  .fixed-bottom-bar,
  .btn,
  .no-print {
    display: none !important;
  }

  body {
    background: #FFFFFF !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .print-preview-container {
    background: #FFFFFF !important;
    padding: 0 !important;
  }

  .a4-page {
    width: 100% !important;
    min-height: auto !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    page-break-after: avoid;
  }

  /* ضمان ظهور الألوان والخلفيات في الطباعة */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  .charts-grid,
  .table-section,
  .report-footer-section {
    page-break-inside: avoid;
  }
}
