/* PWA Styles - Aplicación Web Progresiva */

/* PWA Mode Detection */
body.pwa-mode {
  padding-top: 0 !important;
}

body.pwa-mode .navbar {
  border-radius: 0 !important;
}

/* Install Button Styles */
.pwa-install-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #1e40af;
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 50px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(30, 64, 175, 0.3);
  cursor: pointer;
  z-index: 1050;
  transition: all 0.3s ease;
  display: none;
}

.pwa-install-btn:hover {
  background: #1e3a8a;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(30, 64, 175, 0.4);
}

.pwa-install-btn i {
  margin-right: 8px;
}

/* PWA Splash Screen */
.pwa-splash {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  color: white;
}

.pwa-splash-logo {
  width: 120px;
  height: 120px;
  background: white;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  animation: logoFloat 2s ease-in-out infinite alternate;
}

.pwa-splash-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.pwa-splash-subtitle {
  font-size: 16px;
  opacity: 0.9;
  margin-bottom: 32px;
}

.pwa-splash-loader {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes logoFloat {
  0% { transform: translateY(0px); }
  100% { transform: translateY(-10px); }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Offline Styles */
.offline-mode {
  filter: grayscale(20%);
}

.offline-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #f59e0b;
  color: white;
  text-align: center;
  padding: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1060;
}

/* Update Available Notification */
.update-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #10b981;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1060;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.update-notification:hover {
  background: #059669;
  transform: translateY(-2px);
}

/* PWA Navigation Enhancements */
@media (display-mode: standalone) {
  /* Estilos específicos para modo standalone */
  .navbar {
    position: sticky;
    top: 0;
    z-index: 1030;
  }
  
  /* Agregar padding para compensar el notch en iOS */
  @supports (padding: max(0px)) {
    .navbar {
      padding-top: max(8px, env(safe-area-inset-top));
    }
  }
  
  /* Ocultar elementos innecesarios en modo app */
  .browser-only {
    display: none !important;
  }
  
  /* Mejorar tap targets para touch */
  .btn, .nav-link, .navbar-brand {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* PWA Loading States */
.pwa-loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.95);
  padding: 32px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  text-align: center;
  z-index: 1070;
}

.pwa-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e5e7eb;
  border-top: 3px solid #1e40af;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

.pwa-loading-text {
  color: #64748b;
  font-size: 14px;
  font-weight: 500;
}

/* PWA Cache Status */
.cache-status {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  z-index: 1040;
  display: none;
}

.cache-status.show {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* PWA Safe Areas */
.pwa-safe-area {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.pwa-safe-area-bottom {
  padding-bottom: env(safe-area-inset-bottom);
}

/* PWA App-like Scrolling */
@media (display-mode: standalone) {
  body {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Prevent bounce scrolling on iOS */
  .content-container {
    overflow: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* PWA Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .pwa-install-btn {
    background: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  }
  
  .pwa-install-btn:hover {
    background: #2563eb;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
  }
  
  .pwa-splash {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  }
}

/* PWA Responsive Enhancements */
@media (max-width: 768px) {
  .pwa-install-btn {
    bottom: 16px;
    right: 16px;
    padding: 10px 16px;
    font-size: 13px;
  }
  
  .update-notification {
    top: 16px;
    right: 16px;
    left: 16px;
    text-align: center;
  }
  
  .cache-status {
    bottom: 16px;
    left: 16px;
    font-size: 11px;
  }
}

/* PWA Accessibility */
@media (prefers-reduced-motion: reduce) {
  .pwa-splash-logo {
    animation: none;
  }
  
  .pwa-splash-loader,
  .pwa-loading-spinner {
    animation: none;
  }
  
  .pwa-install-btn {
    transition: none;
  }
}

/* PWA Print Styles */
@media print {
  .pwa-install-btn,
  .offline-indicator,
  .update-notification,
  .cache-status {
    display: none !important;
  }
}

/* PWA Focus Management */
.pwa-focus-trap {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1080;
}

/* PWA Gesture Hints */
.pwa-gesture-hint {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.pwa-gesture-hint.show {
  opacity: 1;
  animation: gestureHint 3s ease;
}

@keyframes gestureHint {
  0%, 100% { opacity: 0; }
  10%, 90% { opacity: 1; }
}
