/* ════════════════════════════════════════════════════════════
   OTTIMA — responsive.css
   تجاوبية الموبايل والشاشات الصغيرة
   جزء من main.css الأصلي، اتقسّم لملفات أصغر للصيانة الأسهل.
   ════════════════════════════════════════════════════════════ */

/* ══════════ RESPONSIVE ══════════ */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open ~ .sidebar-backdrop,
  .sidebar.open + .sidebar-backdrop { opacity: 1; pointer-events: all; }
  .main-area { margin-right: 0; }
  .menu-btn { display: flex; }
  .kanban { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid-2, .grid-3, .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .main-content { padding: 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .topbar { padding: 0 14px; padding-top: env(safe-area-inset-top); }
  .topbar .subtitle { display: none; }
  .page-header h1 { font-size: 16px; }
  .page-header { margin-bottom: 14px; }
  .card-header { padding: 14px 16px; }
  .card-body { padding: 16px; }

  /* منع تكبير سفاري التلقائي عند فتح أي حقل إدخال (يتطلب 16px كحد أدنى) */
  .form-control, .login-input, select.form-control, textarea.form-control { font-size: 16px; }

  /* أهداف لمس أوضح */
  .icon-btn { width: 40px; height: 40px; }
  .nav-link { padding: 11px 12px; font-size: 14px; }
  .btn { padding: 9px 16px; min-height: 40px; }
  .btn-sm { padding: 7px 12px; min-height: 34px; }
  .ftab { padding: 7px 14px; }

  /* الجداول: تمرير أفقي سلس باللمس مع تلميح بصري */
  .table-wrap { -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; width: calc(100% + 32px); }
  table { font-size: 12.5px; }
  thead th, tbody td { padding: 9px 10px; }

  /* المودال: يمتد قرب حواف الشاشة ويفضل قابل للطي بارتياح */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; width: 100%; max-height: 92dvh; border-radius: var(--rl) var(--rl) 0 0; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; min-width: 120px; }

  .login-wrap { padding: 24px 14px; }
  .login-body { padding: 26px 20px 22px; }
  .login-footer { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }

  #toast-container { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); max-width: none; }
  .toast { min-width: 0; width: 100%; }

  .app-footer { padding: 12px 14px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); font-size: 11px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 22px; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters .form-control { width: 100%; }
  .page-header .actions { width: 100%; }
  .page-header .actions .btn { flex: 1; }
  .login-title h1 { font-size: 19px; }
}

/* أجهزة اللمس: كبّر مساحات الضغط للأزرار والروابط بغض النظر عن حجم الشاشة */
@media (hover: none) and (pointer: coarse) {
  .btn, .icon-btn, .nav-link, .ftab { min-height: 40px; }
}

/* احترام تفضيل تقليل الحركة (إمكانية الوصول) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; scroll-behavior: auto !important;
  }
}

