/* ============================================
   PERFORMANCE HEATMAP STYLES
   ============================================ */

.heatmap-container {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.05), rgba(0, 208, 132, 0.05));
  border: 1px solid rgba(102, 126, 234, 0.2);
  border-radius: var(--radius-lg, 16px);
  padding: var(--space-2xl, 3rem);
  max-width: 1400px;
  margin: 0 auto;
  overflow: hidden;
}

/* ============================================
   STATUS BANNER (Large Visual Indicator)
   ============================================ */

.heatmap-status-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3xl, 4rem);
  margin-bottom: var(--space-3xl, 4rem);
  padding: var(--space-2xl, 3rem);
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.5), rgba(20, 20, 20, 0.5));
  border-radius: var(--radius-lg, 16px);
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.status-badge {
  display: flex;
  align-items: center;
  gap: var(--space-lg, 1.5rem);
  padding: var(--space-xl, 2rem) var(--space-2xl, 3rem);
  border-radius: var(--radius-md, 10px);
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(20, 20, 20, 0.5);
  transition: all 0.5s ease;
  opacity: 0.5;
  transform: scale(0.95);
}

.status-badge.active {
  opacity: 1;
  transform: scale(1.05);
  border-color: var(--accent, #00D084);
  background: linear-gradient(135deg, rgba(0, 208, 132, 0.1), rgba(102, 126, 234, 0.1));
  box-shadow: 0 8px 32px rgba(0, 208, 132, 0.3);
}

.badge-icon {
  font-size: 3rem;
  line-height: 1;
}

.badge-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs, 0.25rem);
}

.badge-title {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: var(--text-primary, #fff);
  font-family: 'SF Mono', 'Monaco', monospace;
}

.status-badge.active .badge-title {
  color: var(--accent, #00D084);
}

.badge-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary, #A1A1AA);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.status-arrow {
  font-size: 2.5rem;
  color: var(--text-tertiary, #71717A);
  animation: arrowPulse 2s ease-in-out infinite;
}

@keyframes arrowPulse {
  0%, 100% {
    opacity: 0.5;
    transform: translateX(0);
  }
  50% {
    opacity: 1;
    transform: translateX(10px);
  }
}

@keyframes badgePulse {
  0%, 100% {
    transform: scale(1.05);
  }
  50% {
    transform: scale(1.15);
  }
}

/* ============================================
   HEADER SECTION
   ============================================ */

.heatmap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2xl, 3rem);
  gap: var(--space-xl, 2rem);
}

.heatmap-title-section {
  flex: 1;
}

.heatmap-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: var(--space-sm, 0.5rem);
  background: linear-gradient(135deg, #667eea 0%, #00D084 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.heatmap-subtitle {
  font-size: 1rem;
  color: var(--text-secondary, #A1A1AA);
}

/* View Toggle */
.heatmap-toggle {
  display: flex;
  gap: var(--space-sm, 0.5rem);
  background: var(--bg-secondary, #141414);
  padding: var(--space-xs, 0.25rem);
  border-radius: var(--radius-md, 10px);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
}

.toggle-btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm, 0.5rem);
  padding: var(--space-md, 1rem) var(--space-lg, 1.5rem);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm, 6px);
  color: var(--text-secondary, #A1A1AA);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.toggle-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary, #fff);
}

.toggle-btn.active {
  background: linear-gradient(135deg, #667eea, #00D084);
  color: var(--text-primary, #fff);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.toggle-icon {
  font-size: 1.25rem;
}

/* ============================================
   STATS BAR
   ============================================ */

.heatmap-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg, 1.5rem);
  margin-bottom: var(--space-2xl, 3rem);
}

.stat-card {
  background: var(--bg-card, #1a1a1a);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius-md, 10px);
  padding: var(--space-lg, 1.5rem);
  text-align: center;
  transition: all 0.3s ease;
}

.stat-card:hover {
  border-color: var(--primary, #667eea);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(102, 126, 234, 0.2);
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary, #71717A);
  margin-bottom: var(--space-sm, 0.5rem);
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary, #fff);
  margin-bottom: var(--space-xs, 0.25rem);
  font-family: 'SF Mono', 'Monaco', monospace;
}

.stat-update {
  animation: statPulse 0.5s ease;
}

@keyframes statPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
    color: var(--accent, #00D084);
  }
}

.stat-change {
  font-size: 0.875rem;
  font-weight: 600;
  margin-top: var(--space-xs, 0.25rem);
}

.stat-change.positive {
  color: var(--success, #00D084);
}

.stat-change.negative {
  color: var(--text-tertiary, #71717A);
}

/* ============================================
   WORLD MAP
   ============================================ */

.heatmap-map-container {
  position: relative;
  background: var(--bg-card, #1a1a1a);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius-lg, 16px);
  padding: var(--space-xl, 2rem);
  margin-bottom: var(--space-2xl, 3rem);
  overflow: hidden;
}

.map-wrapper {
  position: relative;
  width: 100%;
  min-height: 400px;
}

/* Map State Indicator Overlay */
.map-state-indicator {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  z-index: 100;
  animation: slideInLeft 0.5s ease-out;
}

.state-indicator-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 2rem;
  border-radius: 12px;
  backdrop-filter: blur(10px);
  border: 2px solid;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  transition: all 0.5s ease;
}

.state-indicator-content.before-state {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.95), rgba(217, 119, 6, 0.95));
  border-color: rgba(251, 191, 36, 0.8);
}

.state-indicator-content.after-state {
  background: linear-gradient(135deg, rgba(0, 208, 132, 0.95), rgba(16, 185, 129, 0.95));
  border-color: rgba(0, 208, 132, 0.8);
}

.state-indicator-icon {
  font-size: 2.5rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.state-indicator-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.state-indicator-label {
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: white;
  text-transform: uppercase;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  font-family: 'SF Mono', 'Monaco', monospace;
}

.state-indicator-description {
  font-size: 0.875rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

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

.world-map {
  width: 100%;
  height: auto;
  display: block;
}

.map-region {
  cursor: pointer;
  transition: all 0.5s ease;
}

.map-region:hover {
  opacity: 1 !important;
  stroke: rgba(255, 255, 255, 0.8);
  stroke-width: 2;
  filter: brightness(1.2);
}

/* Origin Marker */
.origin-marker {
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

/* Edge Markers */
.edge-dot {
  animation: edgePulse 2s ease-in-out infinite;
}

@keyframes edgePulse {
  0%, 100% {
    opacity: 0.8;
    r: 4;
  }
  50% {
    opacity: 1;
    r: 5;
  }
}

/* Legend */
.heatmap-legend {
  position: absolute;
  bottom: var(--space-xl, 2rem);
  right: var(--space-xl, 2rem);
  background: rgba(10, 10, 10, 0.95);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius-md, 10px);
  padding: var(--space-lg, 1.5rem);
  backdrop-filter: blur(10px);
}

.legend-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary, #A1A1AA);
  margin-bottom: var(--space-md, 1rem);
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm, 0.5rem);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm, 0.5rem);
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-sm, 6px);
  flex-shrink: 0;
}

.legend-text {
  font-size: 0.875rem;
  color: var(--text-secondary, #A1A1AA);
  white-space: nowrap;
}

/* ============================================
   REGION DETAILS
   ============================================ */

.region-details {
  margin-bottom: var(--space-2xl, 3rem);
}

.region-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-lg, 1.5rem);
}

.region-card {
  background: var(--bg-card, #1a1a1a);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius-md, 10px);
  padding: var(--space-lg, 1.5rem);
  transition: all 0.3s ease;
  cursor: default;
}

.region-card:hover {
  border-color: var(--primary, #667eea);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(102, 126, 234, 0.2);
}

.region-card.highlighted {
  border-color: var(--accent, #00D084);
  box-shadow: 0 8px 20px rgba(0, 208, 132, 0.3);
  transform: translateY(-4px);
}

.region-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary, #A1A1AA);
  margin-bottom: var(--space-sm, 0.5rem);
}

.region-latency {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: var(--space-xs, 0.25rem);
  font-family: 'SF Mono', 'Monaco', monospace;
  transition: color 0.5s ease;
}

.region-cities {
  font-size: 0.75rem;
  color: var(--text-tertiary, #71717A);
  line-height: 1.4;
}

/* ============================================
   IMPROVEMENT SUMMARY
   ============================================ */

.improvement-summary {
  display: flex;
  align-items: start;
  gap: var(--space-lg, 1.5rem);
  padding: var(--space-xl, 2rem);
  background: linear-gradient(135deg, rgba(0, 208, 132, 0.1), rgba(102, 126, 234, 0.1));
  border: 2px solid var(--accent, #00D084);
  border-radius: var(--radius-lg, 16px);
}

.summary-icon {
  font-size: 3rem;
  flex-shrink: 0;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.summary-content {
  flex: 1;
}

.summary-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary, #fff);
  margin-bottom: var(--space-sm, 0.5rem);
}

.summary-text {
  font-size: 1rem;
  color: var(--text-secondary, #A1A1AA);
  line-height: 1.6;
}

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

@media (max-width: 968px) {
  .heatmap-container {
    padding: var(--space-xl, 2rem);
  }

  .heatmap-status-banner {
    gap: var(--space-xl, 2rem);
    padding: var(--space-lg, 1.5rem);
  }

  .status-badge {
    padding: var(--space-lg, 1.5rem);
    gap: var(--space-md, 1rem);
  }

  .badge-icon {
    font-size: 2rem;
  }

  .badge-title {
    font-size: 1.5rem;
  }

  .status-arrow {
    font-size: 2rem;
  }

  .heatmap-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .heatmap-toggle {
    width: 100%;
  }

  .toggle-btn {
    flex: 1;
    justify-content: center;
    padding: var(--space-md, 1rem);
  }

  .heatmap-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .region-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .heatmap-legend {
    position: static;
    margin-top: var(--space-xl, 2rem);
  }
}

@media (max-width: 640px) {
  .heatmap-container {
    padding: var(--space-lg, 1.5rem);
  }

  .heatmap-status-banner {
    flex-direction: column;
    gap: var(--space-md, 1rem);
    padding: var(--space-md, 1rem);
  }

  .status-badge {
    width: 100%;
    padding: var(--space-md, 1rem) var(--space-lg, 1.5rem);
  }

  .badge-icon {
    font-size: 1.5rem;
  }

  .badge-title {
    font-size: 1.25rem;
  }

  .badge-subtitle {
    font-size: 0.75rem;
  }

  .status-arrow {
    transform: rotate(90deg);
    font-size: 1.5rem;
  }

  .map-state-indicator {
    top: 0.75rem;
    left: 0.75rem;
  }

  .state-indicator-content {
    padding: 0.75rem 1.25rem;
    gap: 0.75rem;
  }

  .state-indicator-icon {
    font-size: 1.75rem;
  }

  .state-indicator-label {
    font-size: 1.125rem;
  }

  .state-indicator-description {
    font-size: 0.75rem;
  }

  .heatmap-title {
    font-size: 1.5rem;
  }

  .heatmap-subtitle {
    font-size: 0.875rem;
  }

  .heatmap-stats {
    grid-template-columns: 1fr;
    gap: var(--space-md, 1rem);
  }

  .stat-card {
    padding: var(--space-md, 1rem);
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .region-grid {
    grid-template-columns: 1fr;
  }

  .improvement-summary {
    flex-direction: column;
    padding: var(--space-lg, 1.5rem);
  }

  .summary-icon {
    font-size: 2rem;
  }

  .summary-title {
    font-size: 1.25rem;
  }

  .summary-text {
    font-size: 0.875rem;
  }

  .toggle-btn {
    font-size: 0.75rem;
    padding: var(--space-sm, 0.5rem) var(--space-md, 1rem);
  }

  .toggle-icon {
    font-size: 1rem;
  }

  .map-wrapper {
    min-height: 300px;
  }
}

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

@media (prefers-color-scheme: dark) {
  .stat-card {
    background: rgba(255, 255, 255, 0.03);
  }

  .stat-card:hover {
    background: rgba(255, 255, 255, 0.05);
  }

  .region-card {
    background: rgba(255, 255, 255, 0.03);
  }

  .region-card:hover {
    background: rgba(255, 255, 255, 0.05);
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .origin-marker,
  .edge-dot,
  .summary-icon,
  .stat-update {
    animation: none;
  }

  .map-region,
  .stat-card,
  .region-card,
  .toggle-btn {
    transition: none;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .heatmap-container,
  .stat-card,
  .region-card,
  .heatmap-legend {
    border-width: 2px;
  }

  .map-region {
    stroke-width: 2;
  }
}

/* Focus styles for accessibility */
.toggle-btn:focus-visible {
  outline: 2px solid var(--accent, #00D084);
  outline-offset: 2px;
}

.region-card:focus-within,
.stat-card:focus-within {
  outline: 2px solid var(--accent, #00D084);
  outline-offset: 2px;
}

/* ============================================
   LOADING STATE
   ============================================ */

.heatmap-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: var(--text-secondary, #A1A1AA);
  font-size: 1rem;
}

.heatmap-loading::after {
  content: '...';
  animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {
  0%, 20% {
    content: '.';
  }
  40% {
    content: '..';
  }
  60%, 100% {
    content: '...';
  }
}
