/* Mobile / tablet layer for the admin panel and every dashboard (admin, staff, agent, vendor, member).
   Loaded last; only acts on small screens. Menu becomes a slide-in drawer, tables become cards. */
html { -webkit-text-size-adjust: 100%; }
img, video, canvas, svg { max-width: 100%; }
.admin-main, .admin-main > *, .bo-main { min-width: 0; }
.mnav-btn, .mnav-backdrop, .mnav-close { display: none; }

/* ---------- tablets and phones: drawer menu ---------- */
@media (max-width: 991.98px) {
  .admin-shell, body.bo .admin-shell { display: block !important; min-height: 0; }
  .admin-main { padding: 1rem !important; }
  .agent-main, .admin-shell > :not(.admin-sidebar):not(.mnav-backdrop) { min-width: 0; }

  .mnav-btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; height: 40px; min-width: 40px; padding: 0 .75rem; border: 1px solid var(--line, #e6dcc8); border-radius: 12px; background: #fff; color: var(--crimson, #97161a); font-weight: 700; font-size: .85rem; cursor: pointer; }
  .mnav-btn i { font-size: 1.25rem; line-height: 1; }
  body:not(.mnav-has) .mnav-btn { display: none; }

  body.mnav-has .admin-sidebar,
  body.bo.mnav-has .admin-sidebar {
    position: fixed !important; top: 0 !important; left: 0; bottom: 0; z-index: 1060;
    width: min(86vw, 320px); max-height: none !important; height: 100dvh; margin: 0 !important;
    border-radius: 0 22px 22px 0 !important; padding: 1rem .75rem 2rem !important;
    display: block !important; overflow-y: auto; overscroll-behavior: contain;
    transform: translateX(-105%); visibility: hidden; transition: transform .26s ease, visibility 0s linear .26s;
    box-shadow: none;
  }
  body.mnav-has.mnav-open .admin-sidebar, body.bo.mnav-has.mnav-open .admin-sidebar { transform: none; visibility: visible; transition: transform .26s ease; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  body.mnav-has .admin-sidebar a { display: block; text-align: left !important; flex: none; padding: .8rem 1rem; font-size: .98rem; margin-bottom: .2rem; }
  body.mnav-has .admin-sidebar a:hover { padding-left: 1rem; }
  .mnav-close { display: flex; align-items: center; justify-content: space-between; position: sticky; top: -1rem; z-index: 2; margin: -1rem -.75rem .6rem; padding: .8rem 1rem; background: var(--crimson-dark, #6d0d10); color: #fff; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,.18); }
  .mnav-close button { background: rgba(255,255,255,.16); border: 0; color: #fff; width: 38px; height: 38px; border-radius: 50%; font-size: 1.1rem; }
  .mnav-backdrop { display: block; position: fixed; inset: 0; z-index: 1055; background: rgba(30,12,12,.55); opacity: 0; pointer-events: none; transition: opacity .26s ease; }
  body.mnav-open .mnav-backdrop { opacity: 1; pointer-events: auto; }
  body.mnav-open { overflow: hidden; }

  /* top bar stays one tidy line */
  .bo-bar { gap: .55rem; padding: .45rem .8rem; }
  .bo-role { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bo-user { display: none !important; }
}

/* ---------- phones ---------- */
@media (max-width: 767.98px) {
  .admin-main { padding: .8rem !important; }
  h1, .section-title { font-size: clamp(1.3rem, 6vw, 1.7rem); line-height: 1.25; overflow-wrap: anywhere; }
  h2 { font-size: 1.15rem; } h3 { font-size: 1.02rem; }
  .section-eyebrow { font-size: .68rem; }
  .container, .container-fluid { padding-left: .85rem; padding-right: .85rem; }

  /* forms: 16px stops iOS zoom; bigger touch targets; one field per row */
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]), select, textarea, .form-control, .form-select { font-size: 16px !important; min-height: 44px; }
  textarea.form-control { min-height: 96px; }
  .form-check-input { width: 1.25em; height: 1.25em; }
  .form-check-label { padding-left: .15rem; }
  .btn { min-height: 42px; padding-top: .5rem; padding-bottom: .5rem; }
  .btn-sm { min-height: 36px; }
  .input-group { flex-wrap: nowrap; }
  form .row > [class*="col-"]:not(.col-6):not(.col-4):not(.col-3):not(.col-5):not(.col-7):not(.col-8) { flex: 0 0 100%; max-width: 100%; }
  form .btn-cta, form .btn-primary, .form-actions .btn { width: 100%; }
  .d-flex.justify-content-between.align-items-center, .d-flex.justify-content-between.align-items-end { flex-wrap: wrap; gap: .5rem; }
  .panel, .card, .dr-card, .hr-card { padding-left: .9rem; padding-right: .9rem; }
  .panel, .hr-card { overflow-wrap: anywhere; }

  /* tabs and chip rows scroll sideways instead of wrapping into a tall block */
  .nav-tabs, .nav-pills, .ac-tabs, .hr-tabs, .ac-sub, .tabs-scroll { flex-wrap: nowrap !important; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .nav-tabs::-webkit-scrollbar, .nav-pills::-webkit-scrollbar, .ac-tabs::-webkit-scrollbar, .hr-tabs::-webkit-scrollbar { display: none; }
  .nav-tabs .nav-link, .nav-pills .nav-link, .ac-tabs a, .hr-tabs a { white-space: nowrap; }

  /* stat tiles: two per row */
  .ac-grid, .hr-grid, .nv-stats, .mf-stats, .lmsadm-stats, .kbadm-stats, .stat-grid, .dr-stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: .6rem !important; }
  .ac-stat b, .hr-k b, .ac-card b { font-size: 1.15rem !important; overflow-wrap: anywhere; }
  .hr-two, .detail-grid, .dr-page, .mk-grid2, .kb-two, .lms-two { grid-template-columns: minmax(0, 1fr) !important; }

  /* modals become full-width sheets */
  .modal-dialog { margin: .5rem; max-width: none; }
  .modal-dialog-scrollable .modal-content, .modal-content { max-height: calc(100dvh - 1rem); }
  .modal-body { overflow-y: auto; }
  .modal-footer { flex-wrap: wrap; } .modal-footer .btn { flex: 1 1 auto; }
  .dropdown-menu { max-width: 92vw; }

  /* tables: wide ones scroll; simple ones become cards (set by mobile.js) */
  .tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; border-radius: 12px; }
  .tbl-scroll > table { min-width: 560px; margin-bottom: 0; }
  table.tbl-stack { min-width: 0 !important; width: 100%; border: 0; }
  table.tbl-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.tbl-stack, table.tbl-stack tbody { display: block; }
  table.tbl-stack tr { display: block; background: #fff; border: 1px solid var(--line, #e6dcc8); border-radius: 14px; padding: .35rem .85rem; margin-bottom: .7rem; box-shadow: 0 1px 0 rgba(0,0,0,.02); }
  table.tbl-stack td, table.tbl-stack th { display: flex; justify-content: space-between; align-items: flex-start; gap: .9rem; text-align: right; border: 0 !important; border-bottom: 1px dashed var(--line, #e6dcc8) !important; padding: .5rem 0 !important; width: auto !important; overflow-wrap: anywhere; background: transparent !important; }
  table.tbl-stack tr > :last-child { border-bottom: 0 !important; }
  table.tbl-stack td::before, table.tbl-stack th[scope=row]::before { content: attr(data-label); flex: 0 0 38%; max-width: 38%; text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: #8a7a64; font-weight: 700; padding-top: .15rem; }
  table.tbl-stack td[data-label=""]::before { display: none; }
  table.tbl-stack td:empty { display: none; }
  table.tbl-stack td .btn, table.tbl-stack td form { margin-left: .25rem; }
  table.tbl-stack td > .d-flex, table.tbl-stack td > div { justify-content: flex-end; }
  table.tbl-stack tfoot, table.tbl-stack tfoot tr { display: block; }
  table.tbl-stack tr.tbl-span td { display: block; text-align: center; border: 0 !important; }
  table.tbl-stack tr.tbl-span td::before { display: none; }

  pre, code { white-space: pre-wrap; overflow-wrap: anywhere; }
  .alert { font-size: .92rem; }
  .pagination { flex-wrap: wrap; justify-content: center; gap: .15rem; }
}

/* small phones */
@media (max-width: 380px) {
  .admin-main { padding: .6rem !important; }
  .bo-role { display: none; }
  .ac-grid, .hr-grid, .nv-stats { gap: .45rem !important; }
}
@media print { .mnav-btn, .mnav-backdrop, .mnav-close { display: none !important; } }
@media (max-width:767.98px){input[type=date],input[type=month],input[type=time],input[type=datetime-local]{min-width:11.5rem}}
