/* ============================================================
   أونكس — طبقة التجاوب للجوال (تُحمّل بعد theme.css)
   تعالج الأعمدة المفروضة داخل القوالب، والرأس، والجداول، والحقول.
   ============================================================ */
@media (max-width: 980px) {
  html, body { overflow-x: hidden !important; }
  main, .dash-container { width: 100% !important; max-width: 100% !important; }

  /* الرأس: اسم مختصر بسطر واحد + زر القائمة يبقى ظاهراً */
  header { flex-wrap: wrap !important; gap: 8px !important; padding: 8px 12px !important; position: sticky; top: 0; z-index: 950; }
  header > div:first-child { min-width: 0; flex: 1 1 auto; }
  header .brand {
    display: block !important; min-width: 0; max-width: 100%;
    font-size: 12.5px !important; line-height: 1.35 !important;
    white-space: nowrap !important; overflow: hidden; text-overflow: ellipsis;
  }
  .mobile-menu-btn { flex: none !important; }
  .conn { flex-wrap: wrap; gap: 6px 10px; width: 100%; }

  /* كل شبكات القوالب — عمود واحد بلا تجاوز أفقي (يتفوق على الـinline style) */
  .charts-main-grid, .style-dual-section, .perf-tables-grid, .metrics-grid,
  .settings-grid, .settings-grid-equal, .reports-grid, .dash-grid,
  .kpi-grid, .perf-grid, .report-grid,
  [style*="grid-template-columns"] {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100% !important;
  }
  .widget-card, .panel-card, .metric-card { min-width: 0 !important; max-width: 100% !important; width: 100% !important; }
  .widget-card *, .panel-card * { min-width: 0; }
  canvas { max-width: 100% !important; }
  .chart-box { height: 220px; }

  /* الجداول: تمرير أفقي داخل حاوية بدل تمزيق الصفحة */
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  table { max-width: 100%; }
  th, td { overflow-wrap: anywhere; }

  /* النماذج: حقل لكل سطر + خط 16px يمنع تكبير iOS التلقائي */
  .form-row, .form-grid { grid-template-columns: minmax(0, 1fr) !important; }
  input, select, textarea { max-width: 100%; font-size: 16px !important; }
  .actions-bar, .dash-subbar, .quick-links { flex-wrap: wrap !important; }
  .tabs-nav { overflow-x: auto !important; flex-wrap: nowrap !important; -webkit-overflow-scrolling: touch; }
  .tabs-nav button { flex: none !important; white-space: nowrap !important; }
}

@media (max-width: 600px) {
  header .conn-user, header .logout-txt { display: none !important; }
  .metric-val { font-size: 1.65rem !important; }
  .widget-card-header h3, .panel-title { font-size: 1rem !important; }
  .form-group label { font-size: .85rem; }
  .q-btn { font-size: .8rem !important; padding: 7px 9px !important; }
}
