.network-quality-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(30, 30, 30, 0.95), rgba(50, 50, 50, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(12px);
  z-index: 101;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.network-quality-toggle:hover {
  background: linear-gradient(135deg, rgba(40, 40, 40, 0.95), rgba(60, 60, 60, 0.95));
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.2);
}

.network-quality-toggle .material-icons {
  font-size: 22px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.network-quality {
  position: absolute;
  top: 80px;
  right: 20px;
  width: 480px;
  background: linear-gradient(135deg, rgba(20, 20, 20, 0.95), rgba(35, 35, 35, 0.95));
  border-radius: 16px;
  padding: 16px;
  font-size: 14px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  color: white;
  backdrop-filter: blur(16px);
  z-index: 100;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.quality-section {
  display: flex;
  justify-content: space-around;
  margin-bottom: 12px;
  padding: 12px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
}

.quality-section > div {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.quality-section > div:hover {
  background: rgba(255, 255, 255, 0.05);
}

.quality-section span {
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.quality-indicator {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  position: relative;
  transition: all 0.3s ease;
}

.quality-indicator::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  opacity: 0.3;
  animation: pulse 2s infinite;
}

.quality-good {
  background: linear-gradient(135deg, #4caf50, #66bb6a);
  box-shadow:
    0 0 12px rgba(76, 175, 80, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.quality-good::before {
  background: #4caf50;
}

.quality-fair {
  background: linear-gradient(135deg, #ffc107, #ffca28);
  box-shadow:
    0 0 12px rgba(255, 193, 7, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.quality-fair::before {
  background: #ffc107;
}

.quality-poor {
  background: linear-gradient(135deg, #f44336, #ef5350);
  box-shadow:
    0 0 12px rgba(244, 67, 54, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.quality-poor::before {
  background: #f44336;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 0.3;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.1;
  }
  100% {
    transform: scale(1);
    opacity: 0.3;
  }
}

.stats-section {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.video-stats,
.audio-stats,
.connection-stats {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  transition: all 0.3s ease;
  min-width: 0; /* Allow flex shrinking */
}

.video-stats:hover,
.audio-stats:hover,
.connection-stats:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.06));
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.video-stats h4,
.audio-stats h4,
.connection-stats h4 {
  margin: 0 0 8px 0;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
  padding-bottom: 6px;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-stats h4::after,
.audio-stats h4::after,
.connection-stats h4::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 30px;
  height: 2px;
  background: linear-gradient(90deg, #4caf50, #66bb6a);
  border-radius: 1px;
}

.video-stats > div,
.audio-stats > div,
.connection-stats > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 11px;
  border-radius: 6px;
  transition: all 0.2s ease;
  white-space: nowrap; /* Prevent text wrapping */
  overflow: hidden;
}

.video-stats > div span:last-child,
.audio-stats > div span:last-child,
.connection-stats > div span:last-child {
  text-align: right;
  flex-shrink: 0;
  margin-left: 6px;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-stats > div span:first-child,
.audio-stats > div span:first-child,
.connection-stats > div span:first-child {
  flex-shrink: 0;
  min-width: 0;
  white-space: nowrap;
}

.video-stats > div:hover,
.audio-stats > div:hover,
.connection-stats > div:hover {
  background: rgba(255, 255, 255, 0.05);
  padding-left: 8px;
  padding-right: 8px;
}

.score-value,
.rtt-value {
  font-weight: 700;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 6px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.score-value {
  color: #4caf50;
  background: rgba(76, 175, 80, 0.1);
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.rtt-value {
  color: #ffc107;
  background: rgba(255, 193, 7, 0.1);
  border: 1px solid rgba(255, 193, 7, 0.3);
}

.video-stats > div:not(:last-child),
.audio-stats > div:not(:last-child) {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Add hover effect for stats rows */
.video-stats > div:hover,
.audio-stats > div:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Add minimize/maximize functionality */
.network-quality.minimized {
  width: auto;
  cursor: pointer;
}

.network-quality.minimized .stats-section,
.network-quality.minimized .quality-section {
  display: none;
}

/* Responsive design */
@media (max-width: 1024px) {
  .network-quality {
    width: 420px;
  }
}

@media (max-width: 768px) {
  .network-quality {
    width: 350px;
    top: 10px;
    right: 10px;
  }

  .stats-section {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .quality-section {
    flex-direction: column;
    gap: 8px;
  }

  .quality-section > div {
    justify-content: space-between;
  }
}

@media (max-width: 480px) {
  .stats-section {
    grid-template-columns: 1fr;
  }

  .video-stats,
  .audio-stats,
  .connection-stats {
    padding: 8px;
  }
}

/* Add animation for opening/closing */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.network-quality {
  animation: slideIn 0.3s ease;
}

/* Add to existing CSS */
.latency-chart {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border-radius: 12px;
  padding: 12px;
  margin: 12px 0;
  width: 100%;
  height: 140px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  box-sizing: border-box;
  overflow: hidden;
}

.latency-chart canvas {
  width: 100% !important;
  height: 100% !important;
}

.network-quality {
  min-width: 300px;
  max-width: 600px;
}
