/* ==========================================================
   تقرير الأداء المدرسي - نظام الطباعة الرسمي
   الهوية الحكومية السعودية
   ========================================================== */

@media print {
  @page {
    size: A4 portrait;
    margin: 1.8cm 1.5cm 1.8cm 1.5cm;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body {
    background: white !important;
    font-family: 'Cairo', 'Tajawal', sans-serif !important;
    line-height: 1.5 !important;
    color: #1a1a1a !important;
  }

  /* إخفاء العناصر التفاعلية */
  .sidebar, .topbar, .menu-toggle, .toolbar, .actions, 
  .no-print, #modal, .toast-container, .btn, .nav-item,
  .export-buttons, button:not(.keep-button) {
    display: none !important;
  }

  /* إظهار عناصر الطباعة */
  .print-header, .print-footer {
    display: block !important;
  }

  .main {
    margin: 0 !important;
    padding: 0 !important;
  }

  .content {
    padding: 0 !important;
  }

  /* الترويسة */
  .print-header {
    text-align: center;
    padding: 0 0 15px 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #492a81;
  }

  .print-header .logos {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
  }

  .print-header .logo-placeholder {
    font-size: 11px;
    text-align: center;
    color: #492a81;
    font-weight: bold;
  }

  .print-header h1 {
    font-size: 24px;
    font-weight: 800;
    color: #492a81;
    margin: 10px 0;
  }

  .print-header .subtitle {
    font-size: 13px;
    color: #555;
  }

  .print-header .school-info {
    font-size: 14px;
    font-weight: 600;
    color: #492a81;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #ddd;
  }

  /* التذييل */
  .print-footer {
    text-align: center;
    padding: 10px 0 0 0;
    margin-top: 20px;
    border-top: 1px solid #ccc;
    font-size: 9px;
    color: #666;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
  }

  /* الغلاف */
  .cover-page {
    text-align: center;
    padding: 60px 20px;
    page-break-after: always;
    margin-bottom: 30px;
  }

  .cover-page .logo-container {
    display: flex;
    justify-content: space-between;
    margin-bottom: 80px;
  }

  .cover-page h1 {
    font-size: 32px;
    color: #492a81;
    margin: 50px 0;
  }

  .cover-page h2 {
    font-size: 22px;
    color: #492a81;
  }

  .cover-page .report-date {
    margin-top: 100px;
    color: #666;
  }

  /* جدول المحتويات */
  .table-of-contents {
    page-break-after: always;
    margin-bottom: 30px;
  }

  .table-of-contents h2 {
    background: #492a81;
    color: white;
    padding: 10px;
    text-align: center;
    border-radius: 8px;
  }

  .toc-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px dotted #ccc;
  }

  /* العناوين */
  .section-title, h2.section-title {
    background: linear-gradient(135deg, #492a81 0%, #492a81 100%);
    color: white !important;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    margin: 15px 0 10px 0;
    page-break-after: avoid;
  }

  h3 {
    color: #492a81;
    font-size: 15px;
    border-right: 3px solid #c9a227;
    padding-right: 10px;
    margin: 10px 0;
  }

  /* البطاقات */
  .card, .plan-card, .stat-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 10px;
    background: white;
  }

  /* الجداول */
  table.data, .data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
  }

  table.data th, .data-table th {
    background: #492a81 !important;
    color: white !important;
    padding: 6px;
    border: 1px solid #492a81;
  }

  table.data td, .data-table td {
    padding: 5px;
    border: 1px solid #ddd;
  }

  table.data tr:nth-child(even) {
    background-color: #f9f9f9;
  }

  table.data thead {
    display: table-header-group;
  }

  /* الرسوم البيانية */
  .chart-wrap {
    break-inside: avoid;
    page-break-inside: avoid;
    margin: 10px 0;
  }

  canvas {
    max-width: 100%;
    height: auto !important;
  }

  /* الشبكات */
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  /* الخطط */
  .plan-card {
    break-inside: auto;
  }

  .plan-card.intensive { border-right: 3px solid #dc2626; }
  .plan-card.developmental { border-right: 3px solid #c9a227; }
  .plan-card.sustain { border-right: 3px solid #15803d; }

  /* شريط التقدم */
  .bar {
    background: #e5e7eb;
    border-radius: 10px;
  }

  .bar span {
    background: #15803d;
    height: 5px;
  }

  /* مستويات الأداء */
  .lvl-excellence { color: #15803d; }
  .lvl-progress { color: #a16207; }
  .lvl-launch { color: #c2410c; }
  .lvl-prepare { color: #b91c1c; }

  /* منع تكسر النصوص */
  p, div, section {
    orphans: 3;
    widows: 3;
  }
}

/* إخفاء عناصر الطباعة في الشاشة */
.print-header, .print-footer, .cover-page, .table-of-contents {
  display: none;
}
