/**
 * ExploreX Analytics Dashboard Styles
 * 
 * Comprehensive styling for analytics dashboard featuring:
 * - Modern dashboard layout with cards and charts
 * - Performance metric color coding
 * - Responsive design for all screen sizes
 * - Data visualization styling
 * - Interactive elements and animations
 */

/* =============================================================================
   ANALYTICS DASHBOARD LAYOUT
   ============================================================================= */

.analytics-dashboard {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(10px);
  z-index: 10000;
  overflow-y: auto;
  padding: 2rem;
  animation: fadeInDashboard 0.3s ease;
}

.analytics-dashboard.hidden {
  display: none;
}

@keyframes fadeInDashboard {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* =============================================================================
   DASHBOARD HEADER
   ============================================================================= */

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid rgba(102, 126, 234, 0.3);
}

.dashboard-title {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.dashboard-title h2 {
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.dashboard-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ccc;
  font-size: 2rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: all 0.2s ease;
  line-height: 1;
}

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

.dashboard-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* =============================================================================
   TIME RANGE SELECTOR
   ============================================================================= */

.time-range-selector {
  display: flex;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0.25rem;
}

.time-range-btn {
  background: transparent;
  color: #ccc;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

.time-range-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.time-range-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.refresh-btn {
  background: rgba(76, 175, 80, 0.2);
  color: #4CAF50;
  border: 1px solid rgba(76, 175, 80, 0.3);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

.refresh-btn:hover {
  background: rgba(76, 175, 80, 0.3);
  color: #fff;
}

/* =============================================================================
   DASHBOARD CONTENT
   ============================================================================= */

.dashboard-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* =============================================================================
   METRICS GRID
   ============================================================================= */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.metric-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
  border-color: rgba(102, 126, 234, 0.3);
}

.metric-card h3 {
  color: #667eea;
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.metric-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.metrics-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.metric-item {
  text-align: center;
}

.metric-value {
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.25rem;
}

.metric-label {
  font-size: 0.8rem;
  color: #ccc;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Performance metric color coding */
.performance-good {
  color: #4CAF50 !important;
}

.performance-needs-improvement {
  color: #ff9800 !important;
}

.performance-poor {
  color: #f44336 !important;
}

/* =============================================================================
   CHARTS GRID
   ============================================================================= */

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
}

.chart-container {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.chart-container h3 {
  color: #667eea;
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
}

.chart-container canvas {
  width: 100% !important;
  height: 200px !important;
  border-radius: 8px;
}

/* =============================================================================
   TABLES GRID
   ============================================================================= */

.tables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.table-container {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.table-container h3 {
  color: #667eea;
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
}

/* =============================================================================
   DATA TABLES
   ============================================================================= */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th {
  background: rgba(102, 126, 234, 0.1);
  color: #667eea;
  padding: 0.75rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 1px solid rgba(102, 126, 234, 0.2);
}

.data-table td {
  padding: 0.75rem;
  color: #ddd;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.data-table tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

.no-data {
  text-align: center;
  color: #999;
  font-style: italic;
  padding: 2rem;
}

/* =============================================================================
   SEVERITY INDICATORS
   ============================================================================= */

.severity-low {
  background: rgba(76, 175, 80, 0.2);
  color: #4CAF50;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
}

.severity-medium {
  background: rgba(255, 152, 0, 0.2);
  color: #ff9800;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
}

.severity-high {
  background: rgba(244, 67, 54, 0.2);
  color: #f44336;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* =============================================================================
   LOADING STATES
   ============================================================================= */

.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #667eea;
  animation: spin 1s ease-in-out infinite;
}

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

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

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

@media (max-width: 1200px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
  
  .tables-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }
}

@media (max-width: 768px) {
  .analytics-dashboard {
    padding: 1rem;
  }
  
  .dashboard-header {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }
  
  .dashboard-controls {
    justify-content: center;
  }
  
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  
  .metrics-row {
    grid-template-columns: 1fr;
  }
  
  .charts-grid {
    grid-template-columns: 1fr;
  }
  
  .tables-grid {
    grid-template-columns: 1fr;
  }
  
  .chart-container {
    padding: 1rem;
  }
  
  .table-container {
    padding: 1rem;
  }
  
  .data-table {
    font-size: 0.8rem;
  }
  
  .data-table th,
  .data-table td {
    padding: 0.5rem;
  }
}

@media (max-width: 480px) {
  .dashboard-title h2 {
    font-size: 1.5rem;
  }
  
  .time-range-selector {
    flex-wrap: wrap;
  }
  
  .time-range-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
  }
  
  .metric-value {
    font-size: 1.5rem;
  }
  
  .metric-label {
    font-size: 0.7rem;
  }
}

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

/* High contrast mode */
@media (prefers-contrast: high) {
  .analytics-dashboard {
    background: #000;
    border: 2px solid #fff;
  }
  
  .metric-card,
  .chart-container,
  .table-container {
    border: 2px solid #fff;
    background: #000;
  }
  
  .data-table th {
    background: #333;
    color: #fff;
  }
  
  .data-table td {
    color: #fff;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .analytics-dashboard {
    animation: none;
  }
  
  .metric-card {
    transition: none;
  }
  
  .metric-card:hover {
    transform: none;
  }
  
  .loading-spinner {
    animation: none;
  }
}

/* Focus indicators */
.dashboard-close:focus,
.time-range-btn:focus,
.refresh-btn:focus {
  outline: 3px solid #667eea;
  outline-offset: 2px;
}

/* =============================================================================
   DARK MODE OPTIMIZATIONS
   ============================================================================= */

@media (prefers-color-scheme: dark) {
  .analytics-dashboard {
    background: rgba(0, 0, 0, 0.95);
  }
  
  .metric-card,
  .chart-container,
  .table-container {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.08);
  }
}

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

@media print {
  .analytics-dashboard {
    position: static;
    background: white;
    color: black;
    padding: 1rem;
  }
  
  .dashboard-close,
  .dashboard-controls {
    display: none;
  }
  
  .metric-card,
  .chart-container,
  .table-container {
    background: white;
    border: 1px solid #ccc;
    break-inside: avoid;
  }
  
  .dashboard-title h2 {
    color: black;
  }
  
  .metric-value {
    color: black;
  }
  
  .data-table th {
    background: #f5f5f5;
    color: black;
  }
  
  .data-table td {
    color: black;
  }
}