/* Hood Memorial Education - PWA Styles */

/* Install Banner */
.pwa-install-banner {
  position: fixed;
  bottom: -200px;
  left: 0;
  right: 0;
  background: var(--hmh-white);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
  padding: 1rem;
  z-index: 9999;
  transition: bottom 0.3s ease-out;
  border-top: 3px solid var(--hmh-blue);
}

.pwa-install-banner.show {
  bottom: 0;
}

.pwa-install-content {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.pwa-install-icon img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
}

.pwa-install-text {
  flex: 1;
}

.pwa-install-text strong {
  display: block;
  color: var(--hmh-dark-blue);
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.pwa-install-text p {
  color: var(--hmh-gray);
  font-size: 0.875rem;
  margin: 0;
}

.pwa-install-actions {
  display: flex;
  gap: 0.5rem;
}

/* Update notification */
.pwa-update-notification {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  min-width: 300px;
  max-width: 500px;
  animation: slideDown 0.3s ease-out;
}

/* Notification animations */
@keyframes slideDown {
  from {
    transform: translateX(-50%) translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* PWA Mode adjustments */
.pwa-mode {
  /* Add safe area insets for devices with notches */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.pwa-mode header {
  /* Adjust header for safe areas */
  padding-top: calc(1rem + env(safe-area-inset-top));
  padding-left: calc(1rem + env(safe-area-inset-left));
  padding-right: calc(1rem + env(safe-area-inset-right));
}

.pwa-mode footer {
  /* Adjust footer for safe areas */
  padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  padding-left: calc(1rem + env(safe-area-inset-left));
  padding-right: calc(1rem + env(safe-area-inset-right));
}

/* Touch targets - ensure minimum 44x44px for accessibility */
.btn,
nav a,
.class-card .btn {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Improved touch spacing */
nav ul {
  gap: 1rem;
}

nav li {
  padding: 0.25rem;
}

/* Button spacing for mobile */
.btn + .btn {
  margin-left: 0.5rem;
}

/* Form controls touch-friendly */
.form-control,
select.form-control,
button,
input[type="submit"],
input[type="button"] {
  min-height: 44px;
  font-size: 16px; /* Prevents zoom on iOS */
}

/* Table touch improvements */
.table {
  -webkit-overflow-scrolling: touch;
}

/* Card touch feedback */
.class-card,
.card {
  -webkit-tap-highlight-color: rgba(0, 87, 168, 0.1);
  tap-highlight-color: rgba(0, 87, 168, 0.1);
}

/* Disable pull-to-refresh in PWA mode */
.pwa-mode body {
  overscroll-behavior-y: contain;
}

/* Loading state for offline */
.loading-offline::after {
  content: ' (Cached)';
  font-size: 0.75rem;
  color: var(--hmh-gray);
  font-weight: normal;
}

/* Mobile optimizations */
@media (max-width: 768px) {
  .pwa-install-content {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }

  .pwa-install-actions {
    width: 100%;
    justify-content: center;
  }

  .pwa-install-banner {
    padding: 1.5rem 1rem;
  }

  /* Hide install prompt on very small screens */
  @media (max-height: 600px) {
    .pwa-install-banner {
      display: none;
    }
  }

  /* Improve button spacing on mobile */
  .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .btn + .btn {
    margin-left: 0;
  }

  /* Stack buttons vertically on mobile */
  .d-flex.gap-2 {
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* Desktop - hide install prompt */
@media (min-width: 1024px) {
  .pwa-install-banner {
    /* Show on desktop too, but make it less intrusive */
    max-width: 500px;
    left: auto;
    right: 20px;
    bottom: -200px;
    border-radius: 8px 8px 0 0;
  }

  .pwa-install-banner.show {
    bottom: 0;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .pwa-install-banner {
    border: 2px solid currentColor;
  }

  .btn {
    border: 2px solid currentColor;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .pwa-install-banner,
  .pwa-update-notification,
  .card,
  .class-card {
    transition: none;
    animation: none;
  }
}

/* Dark mode support (future enhancement) */
@media (prefers-color-scheme: dark) {
  .pwa-mode {
    /* This can be expanded when dark mode is implemented */
    color-scheme: light; /* Force light mode for now */
  }
}

/* Focus styles for keyboard navigation */
.btn:focus,
.form-control:focus,
a:focus {
  outline: 3px solid var(--hmh-blue);
  outline-offset: 2px;
}

/* Print styles - hide PWA UI when printing */
@media print {
  .pwa-install-banner,
  .pwa-update-notification {
    display: none !important;
  }
}

/* Connection indicator */
.connection-status {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 1000;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: none; /* Hidden by default, shown by JS when offline */
}

.connection-status.offline {
  background: #f8d7da;
  color: #721c24;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.connection-status.online {
  background: #d4edda;
  color: #155724;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Loading skeleton for slow connections */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Standalone app specific styles */
@media (display-mode: standalone) {
  /* Add visual indicator that app is installed */
  body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--hmh-blue) 0%, var(--hmh-hover-blue) 100%);
    z-index: 10000;
  }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
  /* iOS Safari */
  .pwa-mode {
    /* Fix for iOS safe areas */
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  input,
  textarea,
  select {
    /* Prevent iOS zoom on focus */
    font-size: 16px;
  }
}

/* Android specific fixes */
@media (display-mode: standalone) and (max-width: 768px) {
  /* Likely Android PWA */
  header {
    /* Account for possible system UI */
    padding-top: calc(1rem + 24px);
  }
}
