/**
 * PWA Styling - Notifications, offline mode, install prompts
 */

/* ====================== OFFLINE MODE ====================== */
body.offline-mode {
  position: relative;
  opacity: 0.95;
}

body.offline-mode::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #ff6b6b, #ff8c42);
  z-index: 10000;
  animation: pulse-offline 1.5s ease-in-out infinite;
}

@keyframes pulse-offline {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ====================== PWA NOTIFICATIONS ====================== */

/* In-app notifications */
.pwa-in-app-notification {
  margin: 1rem;
  padding: 1rem;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  animation: slideInNotification 0.3s ease-out;
}

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

.pwa-in-app-notification strong {
  font-weight: 600;
  margin-right: 0.5rem;
}

/* Update notification */
.pwa-update-notification {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  max-width: 400px;
  background: #16213e;
  border: 1px solid #0f3460;
  border-left: 4px solid #00d4ff;
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  animation: slideUpNotification 0.3s ease-out;
}

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

.pwa-notification-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.pwa-notification-text {
  color: #e0e0e0;
  font-weight: 500;
}

.pwa-btn-reload,
.pwa-btn-dismiss {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.pwa-btn-reload {
  background: #00d4ff;
  color: #000;
}

.pwa-btn-reload:hover {
  background: #00b8d4;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 212, 255, 0.3);
}

.pwa-btn-dismiss {
  background: transparent;
  color: #b0b0c0;
  border: 1px solid #b0b0c0;
}

.pwa-btn-dismiss:hover {
  color: #e0e0e0;
  border-color: #e0e0e0;
}

/* ====================== INSTALL BUTTON ====================== */

#pwa-install-btn {
  display: none;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, #00d4ff, #0099cc);
  color: #000;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 212, 255, 0.2);
}

#pwa-install-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 212, 255, 0.4);
}

#pwa-install-btn:active {
  transform: translateY(0);
}

/* ====================== SYNC STATUS INDICATOR ====================== */

.sync-status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  border-radius: 4px;
  background: rgba(0, 212, 255, 0.1);
  color: #00d4ff;
  animation: none;
}

.sync-status-indicator.syncing {
  animation: pulse 1.5s ease-in-out infinite;
}

.sync-status-indicator.offline {
  background: rgba(255, 107, 107, 0.1);
  color: #ff6b6b;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.sync-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.sync-dot.syncing {
  animation: pulse-dot 1s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}

/* ====================== RESPONSIVE ====================== */

@media (max-width: 768px) {
  .pwa-update-notification {
    left: 10px;
    right: 10px;
    bottom: 10px;
  }

  .pwa-notification-content {
    flex-direction: column;
    align-items: stretch;
  }

  .pwa-btn-reload,
  .pwa-btn-dismiss {
    flex: 1;
    text-align: center;
  }
}

/* ====================== DARK MODE SUPPORT ====================== */

@media (prefers-color-scheme: dark) {
  .pwa-update-notification {
    background: #0f1419;
    border-color: #1a1f2e;
  }

  .pwa-notification-text {
    color: #e0e0e0;
  }
}

@media (prefers-color-scheme: light) {
  .pwa-update-notification {
    background: #ffffff;
    border-color: #e0e0e0;
    color: #1a1a2e;
  }

  .pwa-notification-text {
    color: #333333;
  }

  .pwa-btn-reload {
    background: #00d4ff;
    color: #000;
  }

  .pwa-btn-reload:hover {
    background: #00b8d4;
  }

  .pwa-btn-dismiss {
    background: transparent;
    color: #666666;
    border-color: #666666;
  }

  .pwa-btn-dismiss:hover {
    color: #000;
    border-color: #000;
  }
}

/* ====================== ACCESSIBILITY ====================== */

@media (prefers-reduced-motion: reduce) {
  .pwa-update-notification,
  .pwa-in-app-notification {
    animation: none;
  }

  .sync-status-indicator.syncing,
  .sync-dot.syncing {
    animation: none;
  }

  .pwa-btn-reload:hover,
  #pwa-install-btn:hover {
    transform: none;
  }
}

/* ====================== PRINT ====================== */

@media print {
  .pwa-update-notification,
  .pwa-in-app-notification,
  .sync-status-indicator,
  #pwa-install-btn {
    display: none !important;
  }
}
