@import "/imports/ui/styles/wcag-colors.css";

/**
 * Unified Analytics Dashboard - Styles
 * Cross-channel, AI-powered analytics visualization
 */

/* Full-screen Panel Styles */
.panel-fullscreen-enabled {
  position: relative;
  transition: all 0.3s ease;
}

.panel-fullscreen-enabled.fullscreen-active {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background: white;
  padding: 20px;
  overflow: auto;
  animation: fadeIn 0.3s ease;
}

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

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.section-header h3 {
  margin: 0;
  flex: 1;
}

.fullscreen-btn {
  background: transparent;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 16px;
  color: #666;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
}

.fullscreen-btn:hover {
  background: #f5f5f5;
  border-color: #1565c0;
  color: #1565c0;
  transform: scale(1.05);
}

.fullscreen-btn:active {
  transform: scale(0.95);
}

.fullscreen-active .fullscreen-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 10000;
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.fullscreen-active .fullscreen-btn::after {
  content: ' ESC';
  font-size: 10px;
  margin-left: 4px;
  opacity: 0.7;
}

/* Full-screen adjustments for charts */
.fullscreen-active #funnelChart,
.fullscreen-active #cohortChart,
.fullscreen-active #behaviorFlow {
  height: calc(100vh - 120px);
  min-height: 600px;
}

.fullscreen-active #realtimeMap {
  display: flex;
  justify-content: center;
  align-items: center;
  height: calc(100vh - 120px);
  min-height: 600px;
  width: 100%;
}

.fullscreen-active .chart-row {
  display: flex;
  gap: 20px;
  height: calc(100vh - 150px);
}

.fullscreen-active .chart-container {
  flex: 1;
  height: 100%;
}

/* Map container centering */
.realtime-map-container {
  width: 100%;
  min-height: 500px;
  height: 500px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #f8f9fa;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.realtime-map-container svg {
  display: block;
  width: 100%;
  height: 100%;
}

.fullscreen-active .realtime-map-container {
  height: calc(100vh - 120px);
  min-height: calc(100vh - 120px);
}

/* Map styling enhancements */
.realtime-map-container .country {
  transition: fill 0.3s ease, opacity 0.2s ease;
}

.realtime-map-container .country:hover {
  fill: #cbd5e1 !important;
}

/* Session pins on map */
.realtime-map-container circle.session-pin {
  transition: all 0.3s ease;
  cursor: pointer;
}

.realtime-map-container circle.session-pin:hover {
  filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.8));
}

/* Fallback map styles */
.map-layer.fallback rect {
  transition: all 0.3s ease;
}

.map-layer.fallback rect:hover {
  filter: brightness(1.1);
}

/* Loading State */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  padding: 60px 20px;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(21, 101, 192, 0.1);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 20px;
}

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

.loading-container p {
  color: var(--color-text-secondary);
  font-size: 16px;
  font-weight: 500;
  margin: 0;
}

.unified-dashboard {
  padding: 30px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
}

.unified-header {
  text-align: center;
  margin-bottom: 40px;
  color: white;
}

.unified-header h1 {
  font-size: 48px;
  font-weight: 700;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.unified-header p {
  font-size: 18px;
  opacity: 0.9;
}

/* Hero Stats Cards */
.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.hero-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border: 2px solid transparent;
}

.hero-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 40px rgba(0,0,0,0.3);
  border-color: #667eea;
}

.hero-card.web { border-left: 5px solid var(--color-primary); }
.hero-card.email { border-left: 5px solid var(--color-success); }
.hero-card.social { border-left: 5px solid var(--color-danger); }
.hero-card.ml { border-left: 5px solid var(--color-warning); }

.hero-card h3 {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: 15px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hero-value {
  font-size: 48px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 10px;
}

.hero-label {
  font-size: 16px;
  color: var(--color-text-tertiary);
}

.hero-trend {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 600;
}

.hero-trend.positive { color: var(--color-success); }
.hero-trend.negative { color: var(--color-danger); }

/* AI Insights */
.ai-insights {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  padding: 30px;
  margin-bottom: 40px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.ai-insights h2 {
  font-size: 24px;
  margin-bottom: 20px;
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.insights-carousel {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  padding: 10px 0;
}

.insight-card {
  min-width: 350px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 25px;
  border-radius: 12px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.insight-card h4 {
  margin-bottom: 10px;
  font-size: 18px;
}

.insight-card p {
  font-size: 14px;
  opacity: 0.95;
  line-height: 1.6;
}

.insight-confidence {
  margin-top: 15px;
  font-size: 12px;
  opacity: 0.8;
}

/* Attribution Chart */
.attribution-section {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  padding: 30px;
  margin-bottom: 40px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.attribution-section h2 {
  margin-bottom: 20px;
  color: var(--color-text-primary);
}

#attributionChart {
  min-height: 400px;
}

/* Live Activity Feed */
.activity-section {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  padding: 30px;
  margin-bottom: 40px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.activity-feed {
  max-height: 500px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  padding: 15px;
  border-bottom: 1px solid #ecf0f1;
  transition: background 0.2s ease;
}

.activity-item:hover {
  background: #f8f9fa;
}

.activity-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
}

.activity-icon.web { background: var(--color-primary); }
.activity-icon.email { background: var(--color-success); }
.activity-icon.social { background: var(--color-danger); }
.activity-icon.ml { background: var(--color-warning); }

.activity-content h4 {
  margin-bottom: 5px;
  color: var(--color-text-primary);
  font-size: 16px;
}

.activity-content p {
  color: var(--color-text-secondary);
  font-size: 14px;
  margin-bottom: 5px;
}

.activity-time {
  font-size: 12px;
  color: var(--color-text-tertiary);
}

/* Sentiment Analysis */
.sentiment-section {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  padding: 30px;
  margin-bottom: 40px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.sentiment-gauges {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.sentiment-gauge {
  text-align: center;
}

.gauge-circle {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  margin: 0 auto 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 700;
  color: white;
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.gauge-circle.positive { background: linear-gradient(135deg, var(--color-success), var(--color-success-dark)); }
.gauge-circle.neutral { background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark)); }
.gauge-circle.negative { background: linear-gradient(135deg, var(--color-danger), var(--color-danger-dark)); }

.gauge-label {
  font-size: 16px;
  color: var(--color-text-secondary);
  font-weight: 600;
}

/* Predictions Grid */
.predictions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.prediction-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  padding: 25px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.prediction-card h3 {
  margin-bottom: 15px;
  color: var(--color-text-primary);
}

.prediction-value {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 10px;
}

.prediction-value.high { color: var(--color-danger); }
.prediction-value.medium { color: var(--color-warning); }
.prediction-value.low { color: var(--color-success); }

.prediction-detail {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: 5px;
}

/* Anomaly Alerts */
.anomaly-section {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  padding: 30px;
  margin-bottom: 40px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.anomaly-alert {
  background: #fff3cd;
  border-left: 4px solid var(--color-warning);
  padding: 15px;
  margin-bottom: 15px;
  border-radius: 8px;
}

.anomaly-alert.critical {
  background: #f8d7da;
  border-left-color: var(--color-danger);
}

.anomaly-alert h4 {
  margin-bottom: 5px;
  color: var(--color-text-primary);
}

.anomaly-alert p {
  font-size: 14px;
  color: var(--color-text-secondary);
}

/* Responsive Design */
@media (max-width: 768px) {
  .unified-dashboard {
    padding: 15px;
  }

  .unified-header h1 {
    font-size: 32px;
  }

  .hero-stats {
    grid-template-columns: 1fr;
  }

  .insights-carousel {
    flex-direction: column;
  }

  .insight-card {
    min-width: 100%;
  }
}
