/* ============================================================
   assets/css/mobile.css
   Mobile-first overrides.
   Base styles are mobile. These add complexity for larger screens.
   Breakpoints: 640px (tablet), 1024px (desktop), 1280px (wide)
   ============================================================ */

/* ─── TOUCH TARGET ENFORCEMENT ─────────────────────────────── */
/* All interactive elements: minimum 44×44px touch targets */
.btn, .nav-item, .topbar-btn, .tab, .ptab,
.hospital-item, .hd-upvote-btn, .notif-item,
.admin-user-row, .pending-user-item, .override-row {
  min-height: 44px;
}
.topbar-btn {
  width: 44px;
  height: 44px;
}

/* ─── FONT SIZE — iOS ZOOM PREVENTION ───────────────────────── */
/* Inputs must be ≥16px on iOS to prevent auto-zoom on focus */
input, select, textarea {
  font-size: 16px !important;
}
/* Exception: read-only display values can be smaller */
.review-val, .field-hint, .char-counter { font-size: 13px !important; }

/* ─── SIDEBAR — OFF-CANVAS ON MOBILE ────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 300;
  width: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sidebar.open {
  transform: translateX(0);
  box-shadow: 4px 0 40px rgba(0,0,0,0.4);
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 299;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-overlay.on {
  display: block;
}
.topbar-hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--white);
  flex-shrink: 0;
  border-radius: 8px;
  transition: background 0.15s;
}
.topbar-hamburger:hover { background: var(--white-faint); }

/* ─── TOPBAR ────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 56px;
  background: rgba(13,13,13,0.96);
  backdrop-filter: blur(12px);
  border-bottom: 0.5px solid var(--border);
}
.topbar-greeting {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.greeting-text {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--white);
}
.greeting-date {
  font-size: 10px;
  color: var(--white-dim);
  display: none; /* Hidden on mobile — too cramped */
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* ─── MAIN CONTENT ──────────────────────────────────────────── */
.main {
  min-height: calc(100vh - 56px);
  padding-bottom: env(safe-area-inset-bottom, 16px);
  overflow-x: hidden;
}
.page-wrap {
  padding: 20px 16px;
}

/* ─── GRIDS → STACK ON MOBILE ───────────────────────────────── */
.grid-2-1,
.grid-2,
.grid-3,
.field-row {
  grid-template-columns: 1fr !important;
}

/* ─── CARDS ─────────────────────────────────────────────────── */
.card { border-radius: 12px; }
.card-header { padding: 14px 16px; }
.card-body { padding: 14px 16px; }

/* ─── METRIC CARDS ──────────────────────────────────────────── */
.metric-row,
[style*="grid-template-columns:repeat(4"] {
  grid-template-columns: repeat(2, 1fr) !important;
}

/* ─── SECTION HEADER ────────────────────────────────────────── */
.section-hdr {
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.section-hdr h2 { font-size: 22px; }
.section-hdr .btn { font-size: 12px; padding: 7px 14px; }

/* ─── PAGE TABS ─────────────────────────────────────────────── */
.page-tabs {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
  padding-bottom: 4px;
  margin-bottom: 16px;
  scrollbar-width: none;
}
.page-tabs::-webkit-scrollbar { display: none; }
.ptab { display: inline-flex; font-size: 12px; padding: 7px 12px; }

/* ─── CHAT ──────────────────────────────────────────────────── */
.chat-layout {
  flex-direction: column !important;
}
.chat-sidebar-panel {
  width: 100% !important;
  max-height: 200px;
  border-right: none !important;
  border-bottom: 0.5px solid var(--border);
}
#chatMessages {
  min-height: 300px;
}
.chat-input-area {
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

/* ─── HOSPITAL LIST ─────────────────────────────────────────── */
.hospital-item {
  padding: 12px 14px;
  flex-wrap: wrap;
  gap: 10px;
}

/* ─── MODALS ────────────────────────────────────────────────── */
.modal-overlay {
  padding: 12px;
  align-items: flex-end; /* Mobile: sheet from bottom */
}
.modal-box {
  max-width: 100%;
  width: 100%;
  max-height: 92vh;
  border-radius: 16px 16px 0 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Tablet+ */
@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: 24px; }
  .modal-box { 
    border-radius: 16px; 
    max-width: 560px;
    width: 90%;
  }
}

/* ─── PERMISSIONS TABLE ─────────────────────────────────────── */
.perm-table {
  font-size: 11px;
}
.perm-key-col { min-width: 140px; }
.perm-role-col { min-width: 80px; }

/* ─── ADMIN USER ROWS ───────────────────────────────────────── */
.admin-user-row {
  flex-wrap: wrap;
  gap: 8px;
}
.admin-user-row .btn { font-size: 11px; padding: 5px 10px; }

/* ─── PENDING APPROVAL CARDS ────────────────────────────────── */
.pending-user-item > div {
  flex-direction: column !important;
}
.pending-user-item [style*="grid-template-columns:1fr 1fr"] {
  grid-template-columns: 1fr !important;
}

@media (max-width: 768px) {
  /* Ensure all text elements use theme variables */
  .nav-section-label,
  .notif-ts,
  .field-hint,
  .search-input-wrap input::placeholder {
    color: var(--text-dim, rgba(245, 242, 238, 0.35));
  }
}

/* ─── HELPDESK ──────────────────────────────────────────────── */
.hd-card-top { flex-direction: column; gap: 8px; }
.hd-card { padding: 14px; }
.hd-admin-row { flex-wrap: wrap; gap: 6px; }

/* ─── SIGN-UP PAGE ──────────────────────────────────────────── */
.left-panel { display: none; } /* hidden on mobile */
.right-panel { padding: 24px 16px !important; }
.step-label { display: none; } /* Labels hidden — circles only */
.step-line { min-width: 12px; }

/* ─── SAFE AREA (iPhone notch/home bar) ─────────────────────── */
.sidebar { padding-top: max(20px, env(safe-area-inset-top)); }
.topbar  { padding-top: env(safe-area-inset-top, 0); height: calc(56px + env(safe-area-inset-top, 0)); }
.chat-input-area { padding-bottom: max(10px, env(safe-area-inset-bottom)); }

/* ─── TABLET (640px+) ───────────────────────────────────────── */
@media (min-width: 640px) {
  .field-row {
    grid-template-columns: 1fr 1fr !important;
  }
  .metric-row,
  [style*="grid-template-columns:repeat(4"] {
    grid-template-columns: repeat(4, 1fr) !important;
  }
  .page-wrap { padding: 24px 24px; }
  .greeting-date { display: block; }
  .modal-overlay { align-items: center; padding: 24px; }
  .modal-box { border-radius: 16px; }
  .left-panel { display: flex; }
  .step-label { display: inline; }
}

/* ─── DESKTOP (1024px+) ─────────────────────────────────────── */
@media (min-width: 1024px) {
  .sidebar {
    position: sticky;
    top: 0;
    transform: none !important;
    height: 100vh;
    z-index: auto;
    flex-shrink: 0;
  }
  .sidebar-overlay { display: none !important; }
  .topbar-hamburger { display: none; }
  .main {
    flex: 1;
    overflow-x: hidden;
  }
  .page-wrap { padding: 32px; }
  .grid-2-1 {
    grid-template-columns: 1.6fr 1fr !important;
  }
  .grid-2 {
    grid-template-columns: 1fr 1fr !important;
  }
  .grid-3 {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  .chat-layout {
    flex-direction: row !important;
  }
  .chat-sidebar-panel {
    width: 280px !important;
    max-height: none;
    border-right: 0.5px solid var(--border) !important;
    border-bottom: none !important;
  }
  .pending-user-item > div {
    flex-direction: row !important;
  }
  input, select, textarea {
    font-size: 13px !important;
  }
  .field-hint, .char-counter { font-size: 11px !important; }
}

/* ─── WIDE (1280px+) ────────────────────────────────────────── */
@media (min-width: 1280px) {
  .page-wrap { padding: 40px; }
}


/* ─── Mobile: time below name ──────────────────────────── */
@media (max-width: 640px) {
  .time-mobile {
    display: block !important;
    margin-top: 2px;
    font-size: 10px !important;
  }
}
@media (min-width: 641px) {
  .time-mobile {
    display: inline !important;
  }
}

/* ─── Projects: mobile Kanban ─────────────────────────────── */
@media (max-width: 768px) {
  #kanbanBoard {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    overflow-x: visible !important;
  }
  .kanban-col {
    width: 100% !important;
    min-height: auto !important;
  }
  .kanban-tasks {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
  }
  .task-card {
    padding: 10px 14px !important;
    font-size: 13px !important;
  }
  .kanban-col .kanban-tasks .empty-state {
    display: block;
    text-align: center;
    padding: 8px;
    font-size: 12px;
    color: rgba(245, 242, 238, 0.3);
  }
}

/* ─── Tablet: 3 columns ─────────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
  #kanbanBoard {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 10px !important;
  }
  .kanban-col {
    min-height: 140px !important;
  }
}

