/* WebRTC Status Dashboard - Integrated with Material Design Theme */

/* Container placement */
.webrtc-status-anchor {
  margin-top: 24px;
}

.webrtc-status-container {
  font-family: "Roboto", -apple-system, BlinkMacSystemFont, sans-serif;
  background: rgba(33, 33, 33, 0.95);
  border-radius: 12px;
  overflow: hidden;
  color: #ffffff;
  font-size: 14px;
  line-height: 1.4;
  margin: 16px 0;
}

.webrtc-status-toggle-mount {
  margin: 16px 0;
}

.webrtc-status-toggle-mount .webrtc-status-toggle {
  margin-bottom: 0;
}

/* Toggle checkbox styling to match existing theme */
.webrtc-status-toggle {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: all 0.3s ease;
}

.webrtc-status-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
}

.webrtc-status-toggle input[type="checkbox"] {
  margin-right: 12px;
  width: 18px;
  height: 18px;
  accent-color: #1976d2;
}

.webrtc-status-toggle label {
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  flex: 1;
}

/* Status dashboard panel */
.webrtc-status-panel {
  background: linear-gradient(135deg, rgba(33, 33, 33, 0.95) 0%, rgba(66, 66, 66, 0.95) 100%);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 16px;
  margin-top: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  display: none; /* Hidden by default */
  animation: slideDown 0.3s ease-out;
}

.webrtc-status-panel.visible {
  display: block;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Status section header */
.status-section-header {
  color: #e0e0e0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Status items within the panel */
.status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: all 0.2s ease;
}

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

.status-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Status labels and icons */
.status-label {
  display: flex;
  align-items: center;
  color: #e0e0e0;
  font-size: 13px;
  font-weight: 500;
}

.status-icon {
  width: 18px;
  height: 18px;
  margin-right: 10px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
  transition: all 0.3s ease;
}

/* Simple, user-friendly status indicators */
.status-indicator {
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 12px;
  text-transform: capitalize;
  letter-spacing: 0.3px;
  min-width: 70px;
  justify-content: center;
}

/* Connection status colors - simple and clear */
.status-connected {
  background: linear-gradient(45deg, #4caf50, #66bb6a);
  color: white;
}

.status-connecting {
  background: linear-gradient(45deg, #ff9800, #ffb74d);
  color: white;
  animation: gentle-pulse 2s infinite;
}

.status-disconnected {
  background: linear-gradient(45deg, #757575, #9e9e9e);
  color: white;
}

.status-error {
  background: linear-gradient(45deg, #f44336, #ef5350);
  color: white;
  animation: gentle-blink 1.5s infinite;
}

/* Media track indicators */
.media-tracks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.track-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.35px;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
  color: #e0e0e0;
  transition: all 0.25s ease;
}

.track-text {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.track-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}

.track-live {
  border-color: rgba(76, 175, 80, 0.6);
  background: rgba(76, 175, 80, 0.16);
  color: #c8e6c9;
}

.track-live .track-dot {
  background: #4caf50;
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
  animation: live-pulse 2.2s infinite;
}

.track-ready {
  border-color: rgba(255, 193, 7, 0.7);
  background: rgba(255, 193, 7, 0.14);
  color: #ffe082;
}

.track-ready .track-dot {
  background: #ffc107;
  box-shadow: 0 0 7px rgba(255, 193, 7, 0.6);
  animation: gentle-pulse 2.8s infinite;
}

.track-muted {
  border-color: rgba(244, 67, 54, 0.7);
  background: rgba(244, 67, 54, 0.18);
  color: #ffcdd2;
}

.track-muted .track-dot {
  background: #f44336;
  box-shadow: 0 0 8px rgba(244, 67, 54, 0.6);
  animation: gentle-blink 1.8s infinite;
}

.track-idle {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: #f5f5f5;
}

.track-idle .track-dot {
  background: #ffffff;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.35);
  opacity: 0.85;
}

.status-item-media {
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
}

.status-item-media .status-label {
  align-items: flex-start;
  width: 100%;
}

.status-item-media .media-tracks {
  margin-top: 0;
}

/* Live indicator */
.live-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-dot {
  width: 8px;
  height: 8px;
  background: #f44336;
  border-radius: 50%;
  animation: live-pulse 2s infinite;
}

.live-text {
  font-size: 12px;
  font-weight: 600;
  color: #f44336;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.offline-text {
  font-size: 12px;
  font-weight: 600;
  color: #757575;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Statistics section */
.status-stats {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

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

.stat-item {
  text-align: center;
  padding: 10px 8px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: #4fc3f7;
  display: block;
  line-height: 1.2;
}

.stat-label {
  font-size: 10px;
  color: #bdbdbd;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* Quality indicator */
.connection-quality {
  display: flex;
  align-items: center;
  gap: 2px;
}

.quality-bar {
  width: 3px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 1px;
  transition: all 0.3s ease;
}

.quality-bar:nth-child(1) {
  height: 6px;
}
.quality-bar:nth-child(2) {
  height: 9px;
}
.quality-bar:nth-child(3) {
  height: 12px;
}
.quality-bar:nth-child(4) {
  height: 15px;
}

.quality-excellent .quality-bar {
  background: #4caf50;
}
.quality-good .quality-bar:nth-child(-n + 3) {
  background: #8bc34a;
}
.quality-fair .quality-bar:nth-child(-n + 2) {
  background: #ffeb3b;
}
.quality-poor .quality-bar:nth-child(1) {
  background: #f44336;
}

/* Gentle animations for better UX */
@keyframes gentle-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.02);
  }
}

@keyframes gentle-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

@keyframes live-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.3);
  }
}

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

/* Responsive adjustments */
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
  }

  .stat-item {
    padding: 8px 6px;
  }

  .stat-value {
    font-size: 14px;
  }

  .stat-label {
    font-size: 9px;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .webrtc-status-panel {
    border: 2px solid #ffffff;
  }

  .status-item {
    border: 1px solid rgba(255, 255, 255, 0.3);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .webrtc-status-panel,
  .status-item,
  .status-indicator,
  .quality-bar {
    transition: none;
  }

  .status-connecting,
  .status-error,
  .live-dot {
    animation: none;
  }
}

/* Focus states for accessibility */
.webrtc-status-toggle:focus-within {
  outline: 2px solid #4fc3f7;
  outline-offset: 2px;
}

.webrtc-status-toggle input[type="checkbox"]:focus {
  outline: none;
}

/* User-friendly labels */
.simple-status-text {
  font-size: 13px;
  color: #e0e0e0;
  font-weight: 500;
}

.status-description {
  font-size: 11px;
  color: #bdbdbd;
  margin-top: 2px;
  font-style: italic;
}

/* Additional CSS rules moved from JavaScript */
.webrtc-status-panel.show {
  display: block;
}

.status-section-collapsible {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.3s ease;
}

.status-section-collapsible:hover {
  color: #ffffff;
}

.status-section-icon {
  font-size: 10px;
  transition: transform 0.3s ease;
  display: inline-block;
}

.status-section-icon.collapsed {
  transform: rotate(-90deg);
}

.status-section-content {
  max-height: 1000px;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  opacity: 1;
}

.status-section-content.collapsed {
  max-height: 0;
  opacity: 0;
}

/* Enhanced: STUN/TURN status styles */
.status-direct {
  background: rgba(33, 150, 243, 0.2);
  color: #2196f3;
  border: 1px solid rgba(33, 150, 243, 0.3);
}

.status-stun {
  background: rgba(156, 39, 176, 0.2);
  color: #9c27b0;
  border: 1px solid rgba(156, 39, 176, 0.3);
}

.status-turn {
  background: rgba(255, 87, 34, 0.2);
  color: #ff5722;
  border: 1px solid rgba(255, 87, 34, 0.3);
}

.status-unknown {
  background: rgba(158, 158, 158, 0.2);
  color: #9e9e9e;
  border: 1px solid rgba(158, 158, 158, 0.3);
}

.track-inactive {
  background: rgba(158, 158, 158, 0.2);
  color: #9e9e9e;
  border: 1px solid rgba(158, 158, 158, 0.3);
}

.track-active {
  background: rgba(76, 175, 80, 0.2);
  color: #4caf50;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.track-issue {
  background: rgba(255, 193, 7, 0.2);
  color: #ffc107;
  border: 1px solid rgba(255, 193, 7, 0.3);
}

.webrtc-status-fallback {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
