/* ═══════════════════════════════════════════════════════════════════
   mob-theme.css  –  Shared design system for MSPEDUCARE PWA
   Include on every inner page.  mob-ui.js sets --primary from school.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Design tokens ─────────────────────────────────────────────── */
:root {
  /* School brand – overwritten per school by mob-ui.js */
  --primary:      #4f46e5;
  --primary-dk:   #4338ca;
  --primary-lt:   #eef2ff;
  --primary-rgb:  79, 70, 229;

  /* Semantic */
  --success:  #10b981;
  --danger:   #ef4444;
  --warning:  #f59e0b;
  --info:     #3b82f6;

  /* Neutral scale */
  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Elevation */
  --shadow-xs: 0 1px 3px rgba(0,0,0,.06);
  --shadow-sm: 0 2px 8px  rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 28px rgba(0,0,0,.12);

  /* Layout */
  --bottom-nav-h: 60px;
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
  --safe-top:     env(safe-area-inset-top, 0px);

  /* Motion */
  --ease:        cubic-bezier(.4, 0, .2, 1);
  --ease-out:    cubic-bezier( 0, 0, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}

/* ── Base reset additions ────────────────────────────────────────── */
*, *::before, *::after { -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Page enter animation ───────────────────────────────────────── */
@keyframes mob-fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.mob-page-in { animation: mob-fade-up .28s var(--ease-out) both; }

/* ── Skeleton shimmer ───────────────────────────────────────────── */
@keyframes mob-shimmer {
  from { background-position: -600px 0; }
  to   { background-position:  600px 0; }
}
.mob-skel {
  border-radius: 10px;
  background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
  background-size: 1200px 100%;
  animation: mob-shimmer 1.5s ease-in-out infinite;
}

/* ── Ripple ─────────────────────────────────────────────────────── */
.mob-ripple { position: relative; overflow: hidden; }
.mob-ripple-wave {
  position: absolute; border-radius: 50%;
  background: rgba(255,255,255,.32);
  transform: scale(0);
  animation: mob-ripple-anim .55s linear;
  pointer-events: none;
}
@keyframes mob-ripple-anim { to { transform: scale(4.5); opacity: 0; } }

/* ── Header ─────────────────────────────────────────────────────── */
.mob-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dk) 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 200;
  padding-top: var(--safe-top);
  box-shadow: 0 2px 16px rgba(var(--primary-rgb), .30);
}
.mob-header__inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: 58px;
}
.mob-header__back,
.mob-header__action {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  border: none;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s;
}
.mob-header__back:active,
.mob-header__action:active { background: rgba(255,255,255,.30); }
.mob-header__title {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mob-header__subtitle {
  font-size: 11px;
  opacity: .8;
  font-weight: 400;
}

/* ── Bottom navigation ──────────────────────────────────────────── */
.mob-bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: stretch;
  z-index: 1000;
  box-shadow: 0 -3px 20px rgba(0,0,0,.07);
}
.mob-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  padding: 6px 4px;
  border-radius: 12px;
  margin: 4px 3px;
  position: relative;
  transition: background .15s;
  user-select: none;
}
.mob-nav-item:active { background: var(--gray-100); }
.mob-nav-item__icon  {
  font-size: 22px;
  line-height: 1;
  transition: transform .22s var(--ease-spring);
}
.mob-nav-item__label {
  font-size: 10px;
  font-weight: 500;
  color: var(--gray-400);
  white-space: nowrap;
  transition: color .15s;
}
/* Active state */
.mob-nav-item.is-active::before {
  content: '';
  position: absolute;
  top: 4px;
  width: 22px; height: 3px;
  border-radius: 3px;
  background: var(--primary);
}
.mob-nav-item.is-active .mob-nav-item__label { color: var(--primary); font-weight: 700; }
.mob-nav-item.is-active .mob-nav-item__icon  { transform: translateY(-3px); }

@media (min-width: 769px) { .mob-bottom-nav { display: none; } }

/* ── Toast ──────────────────────────────────────────────────────── */
#mob-toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(64px);
  background: var(--gray-800);
  color: #fff;
  padding: 12px 22px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9000;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  max-width: 88vw;
  text-align: center;
  box-shadow: var(--shadow-lg);
  transition: transform .26s var(--ease-out), opacity .26s;
}
#mob-toast.is-show  { transform: translateX(-50%) translateY(0); opacity: 1; }
#mob-toast.is-success { background: var(--success); }
#mob-toast.is-error   { background: var(--danger);  }
#mob-toast.is-warning { background: var(--warning);  color: #111; }
#mob-toast.is-info    { background: var(--info);    }

/* ── Full-page loader overlay ───────────────────────────────────── */
#mob-loader {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.90);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 8500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s;
}
#mob-loader.is-show { opacity: 1; pointer-events: auto; }
.mob-loader__ring {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 4px solid var(--gray-200);
  border-top-color: var(--primary);
  animation: mob-spin .75s linear infinite;
}
@keyframes mob-spin { to { transform: rotate(360deg); } }
.mob-loader__text { font-size: 14px; color: var(--gray-500); font-weight: 500; }

/* ── Pull-to-refresh bar ────────────────────────────────────────── */
#mob-ptr {
  display: flex; align-items: center; justify-content: center;
  height: 0; overflow: hidden; opacity: 0;
  transition: height .2s, opacity .2s;
  color: var(--primary); font-size: 22px;
}
#mob-ptr.is-pulling { height: 52px; opacity: 1; }
#mob-ptr.is-loading { height: 52px; opacity: 1; }
#mob-ptr.is-loading .ptr-arrow { animation: mob-spin .8s linear infinite; display: inline-block; }

/* ── Empty state ────────────────────────────────────────────────── */
.mob-empty {
  text-align: center;
  padding: 52px 24px;
  color: var(--gray-400);
}
.mob-empty__icon  { font-size: 52px; margin-bottom: 14px; }
.mob-empty__title { font-size: 16px; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }
.mob-empty__sub   { font-size: 14px; line-height: 1.6; }

/* ── Error state ────────────────────────────────────────────────── */
.mob-error { text-align: center; padding: 36px 24px; }
.mob-error__icon  { font-size: 44px; margin-bottom: 12px; }
.mob-error__title { font-size: 15px; font-weight: 600; color: var(--danger); margin-bottom: 6px; }
.mob-error__sub   { font-size: 13px; color: var(--gray-500); margin-bottom: 16px; line-height: 1.5; }
.mob-retry-btn {
  background: var(--primary); color: #fff;
  border: none; border-radius: 10px;
  padding: 10px 28px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: opacity .15s;
}
.mob-retry-btn:active { opacity: .8; }

/* ── Logout confirm sheet ───────────────────────────────────────── */
#mob-logout-sheet {
  position: fixed; inset: 0;
  z-index: 8000;
  display: flex; align-items: flex-end;
  opacity: 0; pointer-events: none;
  transition: opacity .24s;
}
#mob-logout-sheet.is-show { opacity: 1; pointer-events: auto; }
.mob-sheet__backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.mob-sheet__card {
  position: relative;
  width: 100%;
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 12px 24px calc(24px + var(--safe-bottom));
  box-shadow: var(--shadow-xl);
  transform: translateY(100%);
  transition: transform .28s var(--ease-out);
}
#mob-logout-sheet.is-show .mob-sheet__card { transform: translateY(0); }
.mob-sheet__handle {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--gray-300);
  margin: 0 auto 20px;
}
.mob-sheet__title { font-size: 18px; font-weight: 700; color: var(--gray-900); margin-bottom: 6px; }
.mob-sheet__sub   { font-size: 14px; color: var(--gray-500); margin-bottom: 24px; }
.mob-sheet__actions { display: flex; flex-direction: column; gap: 10px; }
.mob-sheet__btn {
  width: 100%; padding: 15px; border-radius: 14px;
  font-size: 16px; font-weight: 600; cursor: pointer; border: none;
  transition: opacity .15s;
}
.mob-sheet__btn:active { opacity: .85; }
.mob-sheet__btn--danger  { background: var(--danger);  color: #fff; }
.mob-sheet__btn--cancel  { background: var(--gray-100); color: var(--gray-700); }

/* ── Dashboard skeleton ─────────────────────────────────────────── */
.dash-skel { padding: 0 0 24px; }
.dash-skel__welcome {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 20px;
  background: #fff;
  margin-bottom: 16px;
}
.dash-skel__avatar { width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; }
.dash-skel__welcome-lines { flex: 1; }
.dash-skel__line { height: 14px; margin-bottom: 8px; }
.dash-skel__attendance {
  margin: 0 16px 16px;
  height: 130px;
  border-radius: 20px;
}
.dash-skel__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 16px;
}
.dash-skel__module { height: 90px; border-radius: 16px; }

/* ── Stat card improvements ─────────────────────────────────────── */
.mob-stat-card {
  background: #fff;
  border-radius: 16px;
  padding: 18px 14px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border-bottom: 3px solid transparent;
}
.mob-stat-value {
  font-size: 28px; font-weight: 800;
  margin: 4px 0;
  line-height: 1;
}
.mob-stat-label {
  font-size: 11px; font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .5px;
}
