/* ==========================================================================
   موبايل: شريط تنقّل سفلي زي التطبيقات + قائمة "المزيد" (Bottom Sheet)
   + ضبط لوحة الطالب على الفون + Toast تحديث الـ PWA
   ========================================================================== */
.mobile-nav, .sheet, .sheet-backdrop { display: none; }

@media (max-width: 960px) {
  :root { --mnav-h: 66px; --header-h: 66px; }
  body { padding-bottom: calc(var(--mnav-h) + env(safe-area-inset-bottom)); }
  .nav-toggle, .main-nav, .fab-wa { display: none !important; }
  .header-inner { height: 66px; }

  .mobile-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    position: fixed; z-index: 70; inset-inline: 0; bottom: 0;
    height: calc(var(--mnav-h) + env(safe-area-inset-bottom)); padding: 0 6px env(safe-area-inset-bottom);
    background: rgba(255,255,255,.96); backdrop-filter: saturate(160%) blur(14px);
    border-top: 1px solid var(--border); box-shadow: 0 -8px 30px rgba(12,52,131,.08);
  }
  .mobile-nav > a, .mobile-nav > button {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    height: var(--mnav-h); background: none; border: 0; padding: 0; cursor: pointer;
    color: var(--text-muted); font: 500 .7rem var(--font-sans); -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav svg { width: 23px; height: 23px; transition: transform .2s ease; }
  .mobile-nav > a.active, .mobile-nav > a:active { color: var(--blue-500); font-weight: 700; }
  .mobile-nav > a.active::before { content: ""; position: absolute; top: 0; width: 26px; height: 3px; border-radius: 0 0 4px 4px; background: var(--blue-500); }
  .mobile-nav > a.active svg { transform: translateY(-1px); }

  /* الزرار الأوسط البارز */
  .mobile-nav-main .fab-core {
    width: 56px; height: 56px; margin-top: -30px; border-radius: 18px; display: grid; place-items: center;
    background: var(--grad-gold); color: #fff; box-shadow: 0 0 0 5px #fff, var(--shadow-gold); transition: transform .2s ease;
  }
  .mobile-nav-main .fab-core svg { width: 25px; height: 25px; }
  .mobile-nav > a.mobile-nav-main.active::before { display: none; }
  .mobile-nav > a.mobile-nav-main.active { color: var(--gold-800); }
  .mobile-nav-main:active .fab-core { transform: scale(.94); }

  /* Bottom sheet */
  .sheet-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 80; background: rgba(7,28,69,.45); opacity: 0; transition: opacity .28s ease; }
  html.sheet-open .sheet-backdrop { opacity: 1; }
  html.sheet-open body { overflow: hidden; }
  .sheet:not([hidden]) {
    display: block; position: fixed; z-index: 81; inset-inline: 0; bottom: 0; max-height: 82vh; overflow-y: auto;
    padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); background: #fff; border-radius: 26px 26px 0 0;
    box-shadow: 0 -20px 60px rgba(7,28,69,.25); transform: translateY(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  }
  html.sheet-open .sheet { transform: translateY(0); }
  .sheet-handle { width: 44px; height: 5px; border-radius: 5px; background: var(--border); margin: 4px auto 16px; cursor: pointer; }
  .sheet-user { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 14px; border-radius: 16px; background: var(--blue-50); }
  .sheet-user strong { display: block; font-family: var(--font-display); color: var(--blue-700); line-height: 1.3; }
  .sheet-user small { color: var(--text-muted); font-size: .8rem; }
  .sheet-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 8px; margin-bottom: 18px; }
  .sheet-grid > a, .sheet-grid > button { display: flex; flex-direction: column; align-items: center; gap: 7px; background: none; border: 0; padding: 0; cursor: pointer; font: 500 .76rem var(--font-sans); color: var(--text-body); text-align: center; }
  .sheet-grid > [hidden] { display: none; }
  .sheet-grid .ic { width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center; background: var(--blue-100); color: var(--blue-600); }
  .sheet-grid .ic svg { width: 24px; height: 24px; }
  .sheet-grid .ic-wa { background: #E3F7E8; color: #1A8F47; }
  .sheet-grid .ic-gold { background: var(--gold-100); color: var(--gold-800); }

  /* ── لوحة الطالب على الموبايل ── */
  .dash { padding-block: 18px 32px; gap: 16px; }
  .dash-side { display: none; }               /* التنقّل بقى من الشريط السفلي */
  .dash-head { margin-bottom: 16px; }
  .dash-head h1 { font-size: 1.35rem; }
  .welcome { padding: 22px 20px; border-radius: 22px; gap: 16px; margin-bottom: 16px; }
  .welcome h1 { font-size: 1.25rem; }
  .welcome p { font-size: .9rem; }
  .welcome .btn { width: 100%; }
  .dash .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 12px !important; margin-bottom: 16px !important; }
  .dash .stat { padding: 14px; gap: 10px; border-radius: 20px; }
  .dash .stat .icon-circle { width: 40px; height: 40px; border-radius: 13px; }
  .dash .stat .icon-circle svg { width: 19px; height: 19px; }
  .dash .stat strong { font-size: 1.25rem; }
  .dash .card-pad { padding: 18px; border-radius: 22px; }
  .dash .card-title { font-size: 1.08rem; margin-bottom: 14px; }
  .dash .cur-item { padding: 12px; gap: 10px; flex-wrap: wrap; }
  .dash .cur-item .t { min-width: 60%; }
  .mini-course { padding: 12px; border-radius: 20px; }
  .mini-course .thumb { width: 66px; height: 60px; border-radius: 14px; }

  /* الجداول تتحول لكروت */
  .table thead { display: none; }
  .table, .table tbody, .table td { display: block; width: 100%; }
  .table tr { padding: 14px 0; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
  .table tr:last-child { border-bottom: 0; }
  .table td { padding: 0; border: 0; font-size: .88rem; }
  .table td[data-label]::before { content: attr(data-label); display: block; color: var(--text-muted); font-size: .72rem; font-weight: 600; }
  .table td:first-child { grid-column: 1 / -1; font-size: .98rem; }
  .table td:last-child { grid-column: 1 / -1; }
  .table td:last-child .btn { width: 100%; }

  /* الامتحان */
  .exam-bar { top: calc(var(--header-h) + 8px); padding: 10px 14px; border-radius: 18px; }
  .exam-bar .text-muted { display: none; }
  .question { padding: 18px; border-radius: 22px; }
  .q-body { font-size: 1rem; }
  .option { padding: 12px 14px; }
  .score-ring { width: 140px; height: 140px; }
  .score-ring > div { width: 110px; height: 110px; }
}

/* ── Toast تحديث النسخة ─────────────────────────────── */
.pwa-toast { position: fixed; z-index: 90; inset-inline: 16px; bottom: calc(var(--mnav-h, 0px) + 16px + env(safe-area-inset-bottom)); max-width: 420px; margin-inline: auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-radius: 16px; background: var(--blue-900); color: #fff; box-shadow: var(--shadow-lg); animation: slidein .35s ease; font-size: .9rem; }
.pwa-toast button { border: 0; border-radius: 10px; padding: 6px 14px; background: var(--gold-500); color: var(--blue-950); font: 700 .85rem var(--font-sans); cursor: pointer; }

/* التطبيق المثبّت (standalone) */
@media (display-mode: standalone) {
  .site-header { padding-top: env(safe-area-inset-top); }
}
