/* ─── PWA UI Components ─── */
/* Online/Offline Status Bar */
.pwa-status-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 12px;
  transform: translateY(-100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.02em;
}
.pwa-status-bar.show {
  transform: translateY(0);
}
.pwa-status-bar.online {
  background: #198754;
  color: #fff;
}
.pwa-status-bar.offline {
  background: #dc3545;
  color: #fff;
}

/* Install Banner */
.pwa-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9998;
  background: #fff;
  border-top: 1px solid #e0e6ef;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.08);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}
.pwa-install-banner.show {
  transform: translateY(0);
}
.pwa-install-banner .pwa-install-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex-shrink: 0;
}
.pwa-install-banner .pwa-install-info {
  flex: 1;
  min-width: 0;
}
.pwa-install-banner .pwa-install-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.3;
}
.pwa-install-banner .pwa-install-desc {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 2px;
}
.pwa-install-banner .pwa-install-btn {
  background: #0d6efd;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.pwa-install-banner .pwa-install-btn:hover {
  background: #0b5ed7;
}
.pwa-install-banner .pwa-install-btn:active {
  transform: scale(0.97);
}
.pwa-install-banner .pwa-install-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.15s;
}
.pwa-install-banner .pwa-install-close:hover {
  background: #f1f5f9;
  color: #64748b;
}

/* Update Notification */
.pwa-update-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  z-index: 9999;
  background: #1e293b;
  color: #fff;
  border-radius: 14px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 420px;
  width: calc(100% - 32px);
}
.pwa-update-toast.show {
  transform: translateX(-50%) translateY(0);
}
.pwa-update-toast .pwa-update-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}
.pwa-update-toast .pwa-update-text {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.4;
}
.pwa-update-toast .pwa-update-btn {
  background: #0d6efd;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
  transition: background 0.2s;
}
.pwa-update-toast .pwa-update-btn:hover {
  background: #0b5ed7;
}
.pwa-update-toast .pwa-update-dismiss {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

/* Install Instructions Modal */
.pwa-install-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}
.pwa-install-modal-overlay.show {
  opacity: 1;
  visibility: visible;
}
.pwa-install-modal {
  background: #fff;
  border-radius: 16px;
  padding: 28px 24px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 48px rgba(0,0,0,0.15);
}
.pwa-install-modal .pwa-install-modal-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin-bottom: 16px;
}
.pwa-install-modal h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 8px;
}
.pwa-install-modal p {
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 20px;
  line-height: 1.5;
}
.pwa-install-modal .pwa-install-modal-steps {
  text-align: left;
  background: #f8fafc;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 20px;
}
.pwa-install-modal .pwa-install-modal-steps .step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.82rem;
  color: #475569;
  padding: 6px 0;
}
.pwa-install-modal .pwa-install-modal-steps .step .step-num {
  background: #0d6efd;
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}
.pwa-install-modal .pwa-install-modal-close {
  background: #0d6efd;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 32px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.2s;
}
.pwa-install-modal .pwa-install-modal-close:hover {
  background: #0b5ed7;
}

/* Loading spinner for PWA install */
.pwa-install-btn.loading {
  pointer-events: none;
  opacity: 0.7;
}
.pwa-install-btn .spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: pwa-spin 0.6s linear infinite;
}
@keyframes pwa-spin {
  to { transform: rotate(360deg); }
}

/* Safe area support for notched devices */
@supports (padding: env(safe-area-inset-bottom)) {
  .pwa-install-banner {
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
  .pwa-update-toast {
    bottom: calc(24px + env(safe-area-inset-bottom));
  }
}

/* Dark mode */
[data-bs-theme="dark"] .pwa-install-banner {
  background: #1a2233;
  border-color: #2a3447;
}
[data-bs-theme="dark"] .pwa-install-banner .pwa-install-title {
  color: #e0e6ef;
}
[data-bs-theme="dark"] .pwa-install-banner .pwa-install-desc {
  color: #94a3b8;
}
[data-bs-theme="dark"] .pwa-install-banner .pwa-install-close:hover {
  background: #2a3447;
  color: #e0e6ef;
}
[data-bs-theme="dark"] .pwa-install-modal {
  background: #1a2233;
}
[data-bs-theme="dark"] .pwa-install-modal h3 {
  color: #e0e6ef;
}
[data-bs-theme="dark"] .pwa-install-modal .pwa-install-modal-steps {
  background: #12181f;
}
[data-bs-theme="dark"] .pwa-install-modal .pwa-install-modal-steps .step {
  color: #94a3b8;
}

/* Desktop standalone window adjustments */
@media (display-mode: standalone) {
  body {
    -webkit-user-select: none;
    user-select: none;
  }
  input, textarea, select, [contenteditable] {
    -webkit-user-select: text;
    user-select: text;
  }
}

/* Reduces motion preference */
@media (prefers-reduced-motion: reduce) {
  .pwa-status-bar,
  .pwa-install-banner,
  .pwa-update-toast {
    transition: none;
  }
}

/* Touch feedback */
@media (pointer: coarse) {
  .pwa-install-btn:active,
  .pwa-update-btn:active {
    transform: scale(0.95);
  }
}