/**
 * ExploreX Performance Optimization Styles
 * 
 * Styling for performance components including:
 * - Lazy loading placeholders and animations
 * - Performance monitoring dashboard
 * - Cache visualization and metrics
 * - Optimization indicators and controls
 */

/* =============================================================================
   LAZY LOADING STYLES
   ============================================================================= */

.lazy-loading {
  transition: opacity 0.3s ease;
  background-color: #f3f4f6;
}

.lazy-loading.loaded {
  opacity: 1;
}

.lazy-loading.error {
  opacity: 0.5;
  background-color: #fee2e2;
}

/* Lazy loading placeholder animation */
.lazy-loading:not(.loaded):not(.error) {
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

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

/* Lazy loading fade-in animation */
.lazy-fade-in {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lazy-fade-in.loaded {
  opacity: 1;
}

/* =============================================================================
   PERFORMANCE DASHBOARD
   ============================================================================= */

.performance-dashboard {
  position: fixed;
  top: 0;
  right: -400px;
  width: 400px;
  height: 100vh;
  background: white;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  transition: right 0.3s ease;
  overflow-y: auto;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.performance-dashboard.open {
  right: 0;
}

.performance-dashboard-header {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  padding: 20px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.performance-dashboard-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.performance-dashboard-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 5px;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.performance-dashboard-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.performance-dashboard-content {
  padding: 20px;
}

/* =============================================================================
   PERFORMANCE METRICS
   ============================================================================= */

.performance-section {
  margin-bottom: 30px;
}

.performance-section h3 {
  margin: 0 0 15px 0;
  color: #1e293b;
  font-size: 1.1rem;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 8px;
}

.performance-metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
}

.performance-metric:last-child {
  border-bottom: none;
}

.performance-metric-label {
  font-size: 0.9rem;
  color: #64748b;
}

.performance-metric-value {
  font-weight: 600;
  color: #1e293b;
}

.performance-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
}

.performance-status.excellent {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
}

.performance-status.good {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
}

.performance-status.needs-improvement {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
}

.performance-status.poor {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* =============================================================================
   CACHE VISUALIZATION
   ============================================================================= */

.cache-visualization {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
}

.cache-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 15px;
}

.cache-stat {
  text-align: center;
}

.cache-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 5px;
}

.cache-stat-label {
  font-size: 0.8rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cache-hit-rate {
  width: 100%;
  height: 8px;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
  margin: 10px 0;
}

.cache-hit-rate-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981 0%, #059669 100%);
  transition: width 0.3s ease;
  border-radius: 4px;
}

/* =============================================================================
   OPTIMIZATION CONTROLS
   ============================================================================= */

.optimization-controls {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.optimization-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.optimization-toggle:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.optimization-toggle.active {
  background: rgba(16, 185, 129, 0.1);
  border-color: #10b981;
}

.optimization-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: #374151;
}

.optimization-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: #cbd5e1;
  border-radius: 12px;
  transition: background 0.3s ease;
}

.optimization-switch.active {
  background: #10b981;
}

.optimization-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.optimization-switch.active::after {
  transform: translateX(20px);
}

/* =============================================================================
   PERFORMANCE INDICATORS
   ============================================================================= */

.performance-indicator {
  position: fixed;
  top: 20px;
  right: 20px;
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 15px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  cursor: pointer;
  transition: all 0.3s ease;
}

.performance-indicator:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.performance-indicator-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.performance-indicator-icon {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.performance-indicator-icon.excellent {
  background: #10b981;
}

.performance-indicator-icon.good {
  background: #22c55e;
}

.performance-indicator-icon.needs-improvement {
  background: #f59e0b;
}

.performance-indicator-icon.poor {
  background: #ef4444;
}

.performance-indicator-text {
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
}

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

/* =============================================================================
   OPTIMIZATION PROGRESS
   ============================================================================= */

.optimization-progress {
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.optimization-progress h4 {
  margin: 0 0 15px 0;
  color: #1e293b;
  font-size: 1rem;
}

.progress-item {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 15px;
}

.progress-item:last-child {
  margin-bottom: 0;
}

.progress-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: white;
}

.progress-icon.completed {
  background: #10b981;
}

.progress-icon.in-progress {
  background: #f59e0b;
  animation: spin 1s linear infinite;
}

.progress-icon.pending {
  background: #cbd5e1;
  color: #64748b;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.progress-info {
  flex: 1;
}

.progress-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 2px;
}

.progress-description {
  font-size: 0.8rem;
  color: #64748b;
}

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

@media (max-width: 768px) {
  .performance-dashboard {
    width: 100%;
    right: -100%;
  }
  
  .performance-indicator {
    top: 10px;
    right: 10px;
    padding: 8px 12px;
  }
  
  .cache-stats {
    grid-template-columns: 1fr;
  }
  
  .optimization-controls {
    gap: 10px;
  }
}

/* =============================================================================
   DARK THEME SUPPORT
   ============================================================================= */

body.dark .performance-dashboard {
  background: #1e293b;
  color: #f8fafc;
}

body.dark .performance-section h3 {
  color: #f8fafc;
  border-bottom-color: #475569;
}

body.dark .performance-metric {
  border-bottom-color: #334155;
}

body.dark .performance-metric-label {
  color: #cbd5e1;
}

body.dark .performance-metric-value {
  color: #f8fafc;
}

body.dark .cache-visualization {
  background: #334155;
  border-color: #475569;
}

body.dark .cache-stat-value {
  color: #f8fafc;
}

body.dark .optimization-toggle {
  background: #334155;
  border-color: #475569;
}

body.dark .optimization-toggle:hover {
  background: #475569;
}

body.dark .optimization-label {
  color: #cbd5e1;
}

body.dark .performance-indicator {
  background: #334155;
  border-color: #475569;
  color: #f8fafc;
}

body.dark .optimization-progress {
  background: #334155;
  border-color: #475569;
}

body.dark .optimization-progress h4 {
  color: #f8fafc;
}

body.dark .progress-title {
  color: #cbd5e1;
}

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

.performance-dashboard:focus-within {
  outline: 2px solid #10b981;
  outline-offset: -2px;
}

.optimization-toggle:focus {
  outline: 2px solid #10b981;
  outline-offset: 2px;
}

.performance-indicator:focus {
  outline: 2px solid #10b981;
  outline-offset: 2px;
}

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .performance-dashboard {
    border: 2px solid;
  }
  
  .cache-visualization,
  .optimization-toggle,
  .optimization-progress {
    border-width: 3px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .lazy-loading,
  .lazy-fade-in,
  .performance-dashboard,
  .optimization-switch,
  .performance-indicator {
    transition: none;
  }
  
  .shimmer,
  .pulse,
  .spin {
    animation: none;
  }
}