/**
 * PWA Styles for Broker Trading Platform
 * Includes install button, network status, and error boundary styles
 */

/* PWA Install Button */
.pwa-install-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--primary-color, #00D4AA) 0%, var(--primary-dark, #00A885) 100%);
  color: white;
  border: none;
  border-radius: 25px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 212, 170, 0.3);
  transition: all 0.3s ease;
}

.pwa-install-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 212, 170, 0.4);
}

.pwa-install-btn.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 4px 15px rgba(0, 212, 170, 0.3); }
  50% { box-shadow: 0 4px 25px rgba(0, 212, 170, 0.6); }
  100% { box-shadow: 0 4px 15px rgba(0, 212, 170, 0.3); }
}

/* Network Status Indicator */
.network-status {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

.network-status.offline {
  background: rgba(220, 53, 69, 0.1);
  border-color: rgba(220, 53, 69, 0.3);
  color: #dc3545;
}

.network-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}

.network-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #28a745;
  transition: all 0.3s ease;
}

.network-dot.online {
  background: #28a745;
  box-shadow: 0 0 8px rgba(40, 167, 69, 0.5);
}

.network-dot.offline {
  background: #dc3545;
  box-shadow: 0 0 8px rgba(220, 53, 69, 0.5);
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0.3; }
}

/* Error Boundary Modal */
.error-boundary-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
}

.error-boundary-modal.show {
  display: flex;
}

.error-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
}

.error-modal-content {
  position: relative;
  background: white;
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.error-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e9ecef;
}

.error-modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #dc3545;
}

.error-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #6c757d;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.error-modal-close:hover {
  background: #f8f9fa;
  color: #dc3545;
}

.error-modal-body {
  padding: 24px;
}

.error-icon {
  font-size: 48px;
  text-align: center;
  margin-bottom: 16px;
}

.error-modal-body p {
  margin: 0 0 16px 0;
  color: #495057;
  line-height: 1.5;
}

.error-details {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
}

.error-details p {
  margin: 0 0 8px 0;
  font-size: 14px;
}

.error-details strong {
  color: #495057;
}

.error-details details {
  margin-top: 12px;
}

.error-details summary {
  cursor: pointer;
  font-weight: 500;
  color: #007bff;
  outline: none;
}

.error-details summary:hover {
  color: #0056b3;
}

.error-details pre {
  background: #f1f3f4;
  border: 1px solid #e1e5e9;
  border-radius: 4px;
  padding: 12px;
  margin-top: 8px;
  font-size: 12px;
  overflow-x: auto;
  color: #5f6368;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.error-modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 20px 24px;
  border-top: 1px solid #e9ecef;
  background: #f8f9fa;
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
  .network-status {
    background: rgba(33, 37, 41, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
    color: #fff;
  }
  
  .network-status.offline {
    background: rgba(220, 53, 69, 0.2);
    border-color: rgba(220, 53, 69, 0.4);
  }
  
  .error-modal-content {
    background: #212529;
    color: #fff;
  }
  
  .error-modal-header {
    border-bottom-color: #343a40;
  }
  
  .error-modal-header h2 {
    color: #dc3545;
  }
  
  .error-modal-close {
    color: #adb5bd;
  }
  
  .error-modal-close:hover {
    background: #343a40;
    color: #dc3545;
  }
  
  .error-modal-body p {
    color: #adb5bd;
  }
  
  .error-details {
    background: #343a40;
  }
  
  .error-details strong {
    color: #adb5bd;
  }
  
  .error-details summary {
    color: #0d6efd;
  }
  
  .error-details summary:hover {
    color: #0b5ed7;
  }
  
  .error-details pre {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
  }
  
  .error-modal-footer {
    border-top-color: #343a40;
    background: #343a40;
  }
}

/* Mobile responsive */
@media (max-width: 768px) {
  .pwa-install-btn {
    bottom: 16px;
    right: 16px;
    padding: 10px 16px;
    font-size: 13px;
  }
  
  .network-status {
    top: 16px;
    right: 16px;
    padding: 6px 12px;
    font-size: 11px;
  }
  
  .error-modal-content {
    width: 95%;
    margin: 16px;
  }
  
  .error-modal-header,
  .error-modal-body,
  .error-modal-footer {
    padding: 16px;
  }
  
  .error-modal-header h2 {
    font-size: 18px;
  }
  
  .error-icon {
    font-size: 40px;
  }
}

/* PWA specific styles */
@media (display-mode: standalone) {
  .pwa-install-btn {
    display: none !important;
  }
  
  /* Add safe area insets for mobile devices */
  body {
    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);
  }
}

/* Offline mode styles */
.offline-mode .requires-online {
  opacity: 0.5;
  pointer-events: none;
}

.offline-mode .offline-indicator {
  display: block;
}

/* Loading states */
.pwa-loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
}

.pwa-loading .spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--primary-color, #00D4AA);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Focus management for accessibility */
.error-modal-content:focus {
  outline: 2px solid var(--primary-color, #00D4AA);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .error-modal-content {
    border: 2px solid;
  }
  
  .pwa-install-btn {
    border: 2px solid;
  }
  
  .network-status {
    border: 2px solid;
  }
}
