/* ── SwasthPath Smooth App & Native Mobile Experience Engine ── */

/* 1. Global Viewport Lock: Prevents page zoom-out & eliminates horizontal scroll on mobile */
html, body {
  max-width: 100vw !important;
  width: 100% !important;
  overflow-x: hidden !important;
  position: relative;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

*, *::before, *::after {
  box-sizing: border-box;
}

/* 2. Responsive Safety for Dashboards & Containers */
.layout, .main, .content, .panel, .section-card, .table-wrap, #logsTableWrap, 
.hero, .qa-grid, .hm-grid, .cat-grid, .stat-grid, .grid-2 {
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* 3. Responsive Tables: Scroll smoothly on mobile rather than stretching the viewport */
table {
  max-width: 100%;
}
.table-wrap, #logsTableWrap, .table-responsive {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  max-width: 100% !important;
  display: block !important;
  width: 100% !important;
}

/* 4. Top Progress Bar for transitions (ultra fast & non-blocking) */
#sp-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, #0B7B6B, #2563c0, #6d28d9, #e07b1a);
  z-index: 999999;
  transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
  pointer-events: none;
  box-shadow: 0 0 10px rgba(11, 123, 107, 0.5);
}

/* 5. Offline Indicator (Hidden by default, only shown if connection is ACTUALLY lost) */
#sp-offline-indicator {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: #1e293b;
  color: #f8fafc;
  padding: 8px 18px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 999999;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  max-width: calc(100vw - 32px) !important;
  box-sizing: border-box !important;
  text-align: center;
}
#sp-offline-indicator.show {
  transform: translateX(-50%) translateY(0);
}
#sp-offline-indicator.online {
  background: #0B7B6B;
}

/* 6. App Install Banner for mobile users (strictly sized to mobile screen) */
#sp-install-prompt {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(140px);
  background: white;
  border: 1px solid rgba(11, 123, 107, 0.2);
  padding: 12px 16px;
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.16);
  z-index: 99998;
  display: flex;
  align-items: center;
  gap: 12px;
  width: calc(100vw - 24px) !important;
  max-width: 380px !important;
  box-sizing: border-box !important;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#sp-install-prompt.show {
  transform: translateX(-50%) translateY(0);
}
#sp-install-prompt .sp-inst-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #E6F5F2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
#sp-install-prompt .sp-inst-text {
  flex: 1;
  min-width: 0;
}
#sp-install-prompt .sp-inst-title {
  font-size: 13px;
  font-weight: 700;
  color: #1A1A2E;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#sp-install-prompt .sp-inst-sub {
  font-size: 11px;
  color: #5A5A6E;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#sp-install-prompt .sp-inst-btn {
  background: #0B7B6B;
  color: white;
  border: none;
  padding: 8px 13px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
#sp-install-prompt .sp-inst-btn:hover {
  background: #085041;
}
#sp-install-prompt .sp-inst-close {
  background: none;
  border: none;
  font-size: 18px;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}

/* 7. Fast-click Touch feedback */
button:active, .nav-i:active, .btn:active, .qa-card:active, .cat-card:active {
  transform: scale(0.985);
  transition: transform 0.06s ease;
}
