/* ============================================================
   RAHMA PRMS — responsive.css
   Desktop-first, max-width, descending: 1280 → 1024 → 860 → 768 → 480
   Mobile (≤860) turns the dashboard into an app layout:
   sidebar → off-canvas drawer, bottom tab bar appears.
   ============================================================ */

/* ---------- 1280 ---------- */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .analytics-grid { grid-template-columns: 1fr; }
}

/* ---------- 1024 ---------- */
@media (max-width: 1024px) {
  .app-content { padding: var(--space-5) 20px var(--space-10); }
  .topbar { padding: 0 20px; }
  .auth-split { grid-template-columns: 1fr 400px; }
  .topbar-search { width: 150px; }
  .topbar .page-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
  /* collapse multi-column app layouts */
  .split-3, .split-2, .split-2.rev { grid-template-columns: 1fr; }
  .form-section { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- 860 : switch dashboard to mobile-app shell ---------- */
@media (max-width: 860px) {
  /* auth pages stack */
  .auth-card { max-width: 440px; }
  .auth-split { grid-template-columns: 1fr; }
  .auth-hero { min-height: 168px; }
  .auth-hero h2 { font-size: 22px; }
  .auth-hero p { display: none; }
  .auth-form { padding: 34px 26px; }
  .form-grid { grid-template-columns: 1fr; }

  /* sidebar becomes an off-canvas drawer */
  .site-sidebar { transform: translateX(-100%); transition: transform .28s ease; box-shadow: var(--shadow-modal); }
  .app.nav-open .site-sidebar { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(24,1,24,.5); opacity: 0; visibility: hidden; transition: opacity .28s, visibility .28s; z-index: 35; }
  .app.nav-open .scrim { opacity: 1; visibility: visible; }

  /* topbar: show logo, hide desktop search */
  .topbar { padding: 0 16px; height: 60px; gap: 12px; }
  .topbar .mobile-logo { display: flex; }
  .topbar-search { display: none; }
  .topbar .divider { display: none; }
  .page-sub { display: none; }
  .page-title { font-size: 17px; }
  .profile-chip .who { display: none; }
  .profile-chip .chev { display: none; }

  .app-content { padding: 16px 14px 92px; }
  .kpi-grid { gap: 12px; }
  .data-table { min-width: 560px; }

  /* bottom tab bar */
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0;
    background: rgba(255,255,255,.96); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding: 9px 8px calc(9px + env(safe-area-inset-bottom));
    justify-content: space-around; z-index: 45;
    box-shadow: 0 -6px 22px rgba(42, 2, 48, .08);
  }
  .mobile-nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 1; color: var(--muted-2); font-size: 10px; }
  .mobile-nav a svg { width: 21px; height: 21px; }
  .mobile-nav a[aria-current="page"] { color: var(--plum-500); font-weight: 600; }
}

/* ---------- 768 ---------- */
@media (max-width: 768px) {
  :root { --fs-h1: 26px; --fs-h2: 22px; }
  .kpi-card .figure .val { font-size: 21px; }
  .form-section, .form-section.two { grid-template-columns: 1fr; }
}

/* ---------- 640 : requests table becomes stacked cards ---------- */
@media (max-width: 640px) {
  .table-head { flex-direction: column; align-items: stretch; }
  .table-tools { flex-direction: column; align-items: stretch; width: 100%; }
  .table-tools .pop-wrap { width: 100%; }
  .table-tools .input-group,
  .table-tools .btn { width: 100%; }
  .table-tools .popover { width: 100%; left: 0; right: 0; }
  .table-tools .popover::before { right: auto; left: 24px; }

  .table-wrap { overflow: visible; padding: 4px 0 10px; }
  .data-table { min-width: 0; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: auto; }
  .data-table tr { border: 1px solid var(--line); border-radius: var(--radius-lg); margin: 0 16px 14px; }
  .data-table tr:hover { background: var(--surface); }
  .data-table td { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 11px 16px; white-space: normal; border-top: 1px solid #f4eef3; }
  .data-table td::before { content: attr(data-label); font-size: 12px; font-weight: 600; color: var(--muted-2); }
  .data-table td.patient-cell { border-top: none; padding: 14px 16px; }
  .data-table td.patient-cell::before { display: none; }
  .data-table td.amt { font-size: 15px; }
}

/* ---------- 480 ---------- */
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .auth-shell { padding: 20px 14px; }
  .auth-form { padding: 28px 20px; }
  .otp-inputs input { width: 42px; height: 50px; font-size: 20px; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
