/* ═══════════════════════════════════════════════════════════
   EduPortal — Mobile responsive layer
   Loads AFTER style.css. Overrides desktop layout < 768px.
   ═══════════════════════════════════════════════════════════ */

/* ── HAMBURGER BUTTON (hidden on desktop) ── */
.mobile-menu-btn {
  display: none;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  color: white;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  padding: 0;
  margin-right: 4px;
}

/* ── BOTTOM NAV (hidden on desktop) ── */
.mobile-bottom-nav {
  display: none;
}

/* ═══════════════════ TABLET (≤ 900px) ═══════════════════ */
@media (max-width: 900px) {
  .portal-topbar { padding: 0 16px; height: 54px; }
  .topbar-name { font-size: 13px; }
  .topbar-school-abbr { display: none; }
  .topbar-session { display: none; }
  .topbar-username { display: none; }
}

/* ═══════════════════ MOBILE (≤ 768px) ═══════════════════ */
@media (max-width: 768px) {

  /* TOPBAR */
  .portal-topbar {
    padding: 0 12px;
    gap: 8px;
  }
  .mobile-menu-btn { display: inline-flex; }
  .topbar-role-badge { font-size: 10px; padding: 2px 7px; }
  .logout-btn { padding: 5px 10px; font-size: 11px; }
  .topbar-avatar { width: 28px; height: 28px; font-size: 11px; }

  /* SIDEBAR — slide-in drawer */
  .sidebar {
    position: fixed;
    top: 54px;
    left: -260px;
    width: 240px;
    height: calc(100vh - 54px);
    background: white;
    z-index: 300;
    box-shadow: 4px 0 16px rgba(0,0,0,.12);
    transition: left 0.25s ease;
    padding: 12px 0;
  }
  .sidebar.open { left: 0; }
  .sidebar-section { display: block !important; padding: 12px 16px 4px; }
  .nav-link { padding: 11px 16px; justify-content: flex-start !important; font-size: 14px; }
  .nav-badge { display: inline-flex !important; }

  /* SIDEBAR BACKDROP */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 54px 0 0 0;
    background: rgba(15,31,92,.35);
    z-index: 250;
  }
  .sidebar-backdrop.show { display: block; }

  /* MAIN CONTENT — full width, breathing room for bottom nav */
  .portal-main {
    padding: 16px 12px 80px 12px;
    width: 100%;
  }

  /* PAGE HEADER */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
  }
  .page-title { font-size: 22px; }
  .page-subtitle { font-size: 12px; }

  /* STATS — single column, smaller */
  .stats-row { gap: 10px; margin-bottom: 16px; }
  .stats-4, .stats-3 { grid-template-columns: 1fr 1fr !important; }
  .stat-card { padding: 12px 14px; gap: 10px; }
  .stat-icon { width: 36px; height: 36px; font-size: 16px; }
  .stat-lbl { font-size: 10.5px; }
  .stat-val { font-size: 19px; }

  /* CARDS */
  .card { padding: 14px 16px; margin-bottom: 14px; border-radius: 10px; }
  .card-head { flex-direction: column; align-items: flex-start; gap: 6px; }
  .card-title { font-size: 13px; }

  /* GRIDS — collapse */
  .g2, .g3, .form-grid { grid-template-columns: 1fr !important; }

  /* TABLES — convert to cards */
  .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl-wrap table { min-width: 480px; }

  /* WELCOME STRIP */
  .welcome-strip { flex-direction: column; align-items: flex-start; padding: 16px 18px; gap: 12px; }
  .ws-logo { width: 44px; height: 44px; }
  .ws-title { font-size: 17px; }
  .ws-sub { font-size: 11.5px; }
  .ws-pill { font-size: 10px; padding: 2px 8px; }

  /* BUTTONS — thumb-sized */
  .btn { padding: 9px 14px; font-size: 13px; min-height: 38px; }
  .btn-sm { padding: 6px 10px; font-size: 12px; min-height: 32px; }

  /* INPUTS — bigger tap targets, prevent iOS zoom */
  .fg input, .fg select, .fg textarea,
  .form-field input,
  .result-controls input, .result-controls select {
    font-size: 16px !important;
    padding: 11px 14px;
    min-height: 42px;
  }

  /* MODAL — fullscreen on mobile */
  #modal-overlay { padding: 12px; }
  #modal-box {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92vh !important;
    border-radius: 12px;
  }
  #modal-body { padding: 16px !important; }

  /* LOGIN — stack vertically (already in your style.css but reinforce) */
  #login-screen { flex-direction: column !important; }
  .login-left { width: 100% !important; padding: 28px 24px !important; min-height: 220px !important; }
  .login-right { padding: 28px 24px !important; }
  .login-greeting { font-size: 24px !important; }
  .login-school-name { font-size: 18px !important; }

  /* TOAST — wider, thumb reach */
  #toast {
    bottom: 80px !important;
    right: 16px !important;
    left: 16px !important;
    text-align: center;
  }

  /* RESULT CONTROLS — wrap */
  .result-controls { flex-direction: column; align-items: stretch; gap: 8px; }
  .result-controls select, .result-controls input { width: 100%; }

  /* BOTTOM NAV */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: white;
    border-top: 1px solid var(--gray-100);
    z-index: 200;
    box-shadow: 0 -2px 12px rgba(15,31,92,.06);
  }
  .mobile-bottom-nav button {
    flex: 1;
    background: none;
    border: none;
    padding: 9px 4px 7px;
    cursor: pointer;
    color: var(--gray-400);
    font-family: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 10.5px;
    font-weight: 500;
    min-height: 56px;
  }
  .mobile-bottom-nav button.active { color: var(--navy); }
  .mobile-bottom-nav button .mbn-icon { font-size: 19px; line-height: 1; }
}

/* ═══════════════════ SMALL PHONES (≤ 480px) ═══════════════════ */
@media (max-width: 480px) {
  .stats-4, .stats-3 { grid-template-columns: 1fr !important; }
  .page-title { font-size: 19px; }
  .stat-val { font-size: 21px; }
  .topbar-name { font-size: 12px; }
}

/* ═══════════════════ PRINT ═══════════════════ */
@media print {
  .mobile-menu-btn, .mobile-bottom-nav, .sidebar-backdrop { display: none !important; }
}