/* ==========================================================================
   Mobile — چیدمان گوشی (کلاس is-mobile روی <html> را app.js می‌گذارد)
   فقط وقتی فعال است که App.mobile درست باشد؛ نسخه رایانه دست‌نخورده می‌ماند.
   ========================================================================== */

.is-mobile { --tabbar-h: 64px; --topbar-h: 56px; -webkit-text-size-adjust: 100%; }
.is-mobile body { overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent; }
.is-mobile #app { height: 100vh; height: 100dvh; }
.is-mobile .auth-shell { height: 100vh; height: 100dvh; padding: var(--s-4); place-items: start center; }
.is-mobile .auth-card { padding: var(--s-5); }

/* iOS روی فیلدهای کوچک‌تر از ۱۶px زوم می‌کند */
.is-mobile input, .is-mobile select, .is-mobile textarea { font-size: 16px !important; }
.is-mobile .btn, .is-mobile .menu-item, .is-mobile .nav-item { min-height: 40px; }
.is-mobile .btn-sm { min-height: 34px; }
.is-mobile .icon-btn { width: 40px; height: 40px; }

/* ---------- پوسته: تاپ‌بار ساده + تب‌بار پایین ---------- */
.is-mobile .m-shell { flex-direction: column; }
.is-mobile .m-shell .main { flex: 1; }
.is-mobile .m-topbar { padding: 0 var(--s-3); gap: var(--s-2); padding-top: env(safe-area-inset-top); height: calc(var(--topbar-h) + env(safe-area-inset-top)); }
.is-mobile .m-topbar .org-switch { flex: 0 1 auto; max-width: 70%; font-size: var(--fs-lg); }
.is-mobile .m-topbar .icon-btn .dot { top: 4px; left: 4px; }
.is-mobile .view { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

.is-mobile .m-tabbar {
  flex-shrink: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 50;
}
.is-mobile .m-tab {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-3);
  font-size: 12px; font-weight: 600;
}
.is-mobile .m-tab.active { color: var(--primary-text); }
.is-mobile .m-ico { position: relative; display: grid; place-items: center; }
.is-mobile .m-badge {
  position: absolute; top: -5px; left: -9px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: var(--r-full);
  background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}

/* ---------- صفحه‌ها ---------- */
.is-mobile .page { padding: var(--s-4) var(--s-3) var(--s-8); }
.is-mobile .page-head { margin-bottom: var(--s-4); }
.is-mobile .page-title h1 { font-size: var(--fs-xl); }
.is-mobile .page-head > .row, .is-mobile .page-title { flex-wrap: wrap; }
.is-mobile .page-head .btn { flex: 1 1 auto; justify-content: center; }
.is-mobile .page-head > .row-between > *,
.is-mobile .page .card-head > * { min-width: 0; max-width: 100%; }
.is-mobile .page .seg, .is-mobile .modal .seg, .is-mobile .drawer .seg { flex-wrap: wrap; max-width: 100%; }
.is-mobile .seg button { min-height: 34px; }
.is-mobile .breadcrumb { display: none; }

/* همه گریدها تک‌ستونه؛ آمارها دوتایی */
.is-mobile .grid-2, .is-mobile .grid-3, .is-mobile .grid-main-side, .is-mobile .grid-auto, .is-mobile .split {
  grid-template-columns: minmax(0, 1fr);
}
.is-mobile .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
.is-mobile .page [style*="grid-template-columns"]:not([style*="repeat(7"]) { grid-template-columns: minmax(0, 1fr) !important; }
.is-mobile .page [style*="min-width"] { min-width: 0 !important; }
.is-mobile .card-body.row { flex-wrap: wrap; }
.is-mobile .kv { grid-template-columns: 96px minmax(0, 1fr); }
.is-mobile .page-sub { overflow-wrap: anywhere; }
.is-mobile .card-body { padding: var(--s-3); }

.is-mobile .page [style*="width:"][style*="px"] { max-width: 100%; }
.is-mobile .page input, .is-mobile .page select { max-width: 100%; }

/* جدول‌ها: اسکرول افقی داخل کارت، نه کل صفحه */
.is-mobile .card, .is-mobile .table-wrap, .is-mobile .tbl-wrap { min-width: 0; max-width: 100%; }
.is-mobile .card:has(> table.tbl), .is-mobile .card:has(> .card-body > table.tbl), .is-mobile .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.is-mobile table.tbl { min-width: 520px; }
.is-mobile .matrix { min-width: 0; }

.is-mobile .tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
.is-mobile .tabs::-webkit-scrollbar { display: none; }
.is-mobile .tabs button { flex-shrink: 0; white-space: nowrap; }
.is-mobile .page > .tabs { flex-wrap: wrap; overflow: visible; }
.is-mobile .page > .tabs button { min-height: 40px; }

/* برد کانبان: ستون‌ها کنار هم با اسکرول افقی و گیرِ نرم */
.is-mobile .board-scroll { padding: 0 var(--s-3) var(--s-4); scroll-snap-type: x proximity; }
.is-mobile .board-scroll > * { scroll-snap-align: center; max-width: 86vw; }

/* ---------- مودال / دراور: تمام‌صفحه ---------- */
.is-mobile .modal, .is-mobile .modal.md, .is-mobile .modal.lg, .is-mobile .modal.xl {
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%; max-height: none; height: 100%;
  transform: none; border: 0; border-radius: 0;
  animation: mFadeIn var(--t-med) forwards;
}
.is-mobile .modal-head { padding: var(--s-3) var(--s-4); padding-top: calc(var(--s-3) + env(safe-area-inset-top)); }
.is-mobile .modal-body { padding: var(--s-4); }
.is-mobile .modal-foot { border-radius: 0; padding-bottom: calc(var(--s-3) + env(safe-area-inset-bottom)); flex-wrap: wrap; }
@keyframes mFadeIn { from { opacity: 0; } to { opacity: 1; } }

.is-mobile .drawer { width: 100vw; }
.is-mobile .drawer-head { padding: var(--s-3) var(--s-4); padding-top: calc(var(--s-3) + env(safe-area-inset-top)); }
.is-mobile .drawer-body { padding: var(--s-4); }

/* ---------- منوها: ورقه پایین صفحه ---------- */
.is-mobile .menu {
  left: 0 !important; right: 0 !important; top: auto !important; bottom: 0;
  width: 100%; min-width: 0 !important; max-width: 100% !important;
  max-height: 75vh; max-height: 75dvh; overscroll-behavior: contain;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--s-2) var(--s-2) calc(var(--s-2) + env(safe-area-inset-bottom));
  animation: mSheetUp var(--t-med);
}
.is-mobile .menu-item { padding: 10px var(--s-3); font-size: var(--fs-lg); }
.is-mobile .m-sections { max-height: 86vh; max-height: 86dvh; }
.is-mobile .m-sections .menu-title { padding-block: var(--s-3) var(--s-1); }
@keyframes mSheetUp { from { transform: translateY(40%); opacity: 0; } to { transform: none; opacity: 1; } }

/* جستجو */
.is-mobile .cmdk { top: 0; left: 0; right: 0; transform: none; width: 100%; max-height: 100vh; max-height: 100dvh; height: 100%; border-radius: 0; border: 0; }
.is-mobile .cmdk input { padding-top: calc(var(--s-4) + env(safe-area-inset-top)); }

/* اعلان‌ها بالای تب‌بار */
.is-mobile #toasts { left: var(--s-3); right: var(--s-3); bottom: calc(var(--tabbar-h) + var(--s-3) + env(safe-area-inset-bottom)); }
.is-mobile .toast { max-width: none; }

/* ---------- نسخه سبک: بخش‌های سنگین و کم‌کاربرد پنهان می‌شوند ---------- */
.is-mobile .desktop-only { display: none !important; }
.is-mobile kbd { display: none; }

/* کاشی‌های آمار: فشرده و کنار هم */
.is-mobile .grid:has(> .stat) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.is-mobile .grid-3:has(> .stat) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.is-mobile .stat { padding: var(--s-3); }
.is-mobile .stat-value { font-size: var(--fs-2xl); }
.is-mobile .stat-label { font-size: var(--fs-xs); }
.is-mobile .stat-meta { display: none; }

/* نوار ابزار صفحه‌ها: اجازه شکستن خط */
.is-mobile .page .row-between { flex-wrap: wrap; }
.is-mobile .cal-grid, .is-mobile .cal-head { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.is-mobile .cal-head > div { padding-inline: 1px; overflow-wrap: anywhere; }
.is-mobile .cal-cell { min-width: 0; min-height: 44px; padding: 3px; }
.is-mobile .cal-cell .cal-day { flex-wrap: wrap; gap: 1px 3px; }
.is-mobile .cal-cell .cal-alt { align-items: flex-start; font-size: 9px; }
.is-mobile .cal-cell .badge, .is-mobile .cal-cell .xs { font-size: 10.5px; }
.is-mobile .cal-cell .badge, .is-mobile .calendar-request { white-space: normal; overflow-wrap: anywhere; }
.is-mobile .cal-cell .ltr { white-space: normal; overflow-wrap: anywhere; }
