/* ═══════════════════════════════════════════════════════════════
   GLOBAL RESPONSIVE FIX — Mateen Academic Platform
   ═══════════════════════════════════════════════════════════════ */

/* ── 1. Base ── */
*, *::before, *::after { box-sizing: border-box; }
html, body { overflow-x: hidden; max-width: 100vw; }
img, video, iframe, table { max-width: 100%; }

/* ════════════════════════════════════════
   TABLET  (≤ 768px)
   ════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── Page layout ── */
  .page-wrapper, .main-wrapper, .content-wrapper {
    padding: 12px !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* ── Cards & sections ── */
  .card, .section-card, .box, .panel {
    padding: 14px !important;
    margin-bottom: 12px !important;
    border-radius: 10px !important;
  }

  /* ── Tables ── */
  .table-wrap, .table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Modals ── */
  .modal-inner, .modal-box, .modal-content,
  [id*="Modal"] > div {
    width: 95% !important;
    max-width: 95% !important;
    margin: 10px auto !important;
    padding: 16px !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
  }

  /* ── Stats bars ── */
  .stu-stats-row, .stats-row {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  /* ── Section head ── */
  .section-head {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }
  .section-head input,
  .section-head select {
    width: 100% !important;
    font-size: 13px !important;
  }
}

/* ════════════════════════════════════════
   MOBILE  (≤ 480px)
   ════════════════════════════════════════ */
@media (max-width: 480px) {

  /* ── Buttons ── */
  .btn, button { font-size: 12.5px !important; }

  /* ── Inputs ── */
  input[type="text"], input[type="email"], input[type="password"],
  input[type="number"], input[type="tel"], select, textarea {
    font-size: 14px !important;
    padding: 9px 10px !important;
    width: 100% !important;
    border-radius: 8px !important;
  }

  /* ── Stats → 2 col ── */
  .stu-stats-row, .stats-row {
    grid-template-columns: 1fr 1fr !important;
  }

  /* ── Modals full-screen on tiny screens ── */
  .modal-inner, .modal-box, .modal-content,
  [id*="Modal"] > div {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    min-height: 100vh !important;
  }

  /* ── Bulk bar ── */
  .stu-bulk-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
  .stu-bulk-fields { flex-wrap: wrap !important; gap: 6px !important; }
  .bulk-sel, .bulk-num { flex: 1 !important; min-width: 120px !important; }
}

/* ════════════════════════════════════════
   MESSAGES PAGE — slide panel on mobile
   ════════════════════════════════════════ */
@media (max-width: 700px) {
  .msg-layout {
    position: relative !important;
    height: calc(100vh - 56px) !important;
    overflow: hidden !important;
  }
  .msg-sidebar {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    min-width: 0 !important;
    z-index: 10 !important;
    transition: transform 0.25s ease !important;
  }
  .msg-sidebar.mob-hidden {
    transform: translateX(100%) !important;
  }
  .msg-main {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    z-index: 1 !important;
  }
  .msg-back-btn { display: flex !important; }
}

/* ════════════════════════════════════════
   ADMIN — tables → cards on mobile
   ════════════════════════════════════════ */
@media (max-width: 640px) {
  #allUsersTable thead            { display: none !important; }
  #allUsersTable,
  #allUsersTable tbody            { display: block !important; }
  #allUsersTable tr {
    display: block !important;
    background: #fff;
    border: 1px solid #e8e0d0;
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 12px 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
  }
  #allUsersTable td {
    display: flex !important;
    align-items: center;
    gap: 8px;
    border: none !important;
    padding: 3px 0 !important;
    font-size: 13px !important;
    flex-wrap: wrap;
    white-space: normal !important;
  }
  #allUsersTable td:nth-child(1) { display: none !important; }
  #allUsersTable td:nth-child(2) {
    font-size: 15px !important;
    font-weight: 700;
    color: #1a4a2e;
    padding-bottom: 8px !important;
    border-bottom: 1px solid #e8e0d0 !important;
    margin-bottom: 4px !important;
  }
  #allUsersTable td:last-child {
    border-top: 1px solid #e8e0d0 !important;
    padding-top: 10px !important;
    margin-top: 4px !important;
    justify-content: flex-end;
  }

  .pending-table thead            { display: none !important; }
  .pending-table,
  .pending-table tbody            { display: block !important; }
  .pending-table tr {
    display: block !important;
    background: #fff;
    border: 1px solid #e8e0d0;
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 12px 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
  }
  .pending-table td {
    display: flex !important;
    align-items: center;
    gap: 8px;
    border: none !important;
    padding: 3px 0 !important;
    font-size: 13px !important;
    flex-wrap: wrap;
  }
  .pending-table td:nth-child(1) { display: none !important; }
  .pending-table td:nth-child(2) {
    font-size: 15px !important;
    font-weight: 700;
    color: #1a4a2e;
    padding-bottom: 8px !important;
    border-bottom: 1px solid #e8e0d0 !important;
    margin-bottom: 4px !important;
  }
  .pending-table td:last-child {
    border-top: 1px solid #e8e0d0 !important;
    padding-top: 10px !important;
    margin-top: 4px !important;
    justify-content: flex-end;
  }
}
