/* Debug Stats Panel Styling */
.debug-panel {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 320px;
  max-height: 80vh;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid #444;
  border-radius: 8px;
  color: #fff;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  z-index: 1000;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: all 0.3s ease;
}

.debug-panel.hidden {
  display: none;
}

.debug-panel.minimized {
  height: 40px;
  overflow: hidden;
}

/* Header */
.debug-header {
  background: rgba(255, 255, 255, 0.1);
  padding: 8px 12px;
  border-bottom: 1px solid #555;
  display: flex;
  justify-content: between;
  align-items: center;
  cursor: pointer;
}

.debug-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: bold;
  flex-grow: 1;
}

.debug-toggle {
  background: none;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  transition: background-color 0.2s;
}

.debug-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Content Area */
.debug-content {
  max-height: calc(80vh - 60px);
  overflow-y: auto;
  padding: 8px 0;
}

/* Scrollbar Styling */
.debug-content::-webkit-scrollbar {
  width: 6px;
}

.debug-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
}

.debug-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

/* Sections */
.debug-section {
  border-bottom: 1px solid #333;
  padding: 8px 12px;
}

.debug-section:last-child {
  border-bottom: none;
}

.debug-section-title {
  font-weight: bold;
  color: #4CAF50;
  margin-bottom: 6px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.debug-section-title:hover {
  color: #66BB6A;
}

.debug-section-title::before {
  content: '▼';
  font-size: 10px;
  margin-right: 6px;
  transition: transform 0.2s;
}

.debug-section.collapsed .debug-section-title::before {
  transform: rotate(-90deg);
}

.debug-section.collapsed .debug-section-content {
  display: none;
}

/* Metrics */
.debug-metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  line-height: 1.3;
}

.debug-metric:last-child {
  margin-bottom: 0;
}

.debug-metric-label {
  color: #ccc;
  flex-grow: 1;
}

.debug-metric-value {
  color: #fff;
  font-weight: bold;
  text-align: right;
  min-width: 80px;
}

/* Status Colors */
.status-good {
  color: #4CAF50 !important;
}

.status-warning {
  color: #FF9800 !important;
}

.status-error {
  color: #f44336 !important;
}

.status-critical {
  color: #f44336 !important;
  animation: flash 1s infinite;
}

@keyframes flash {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0.5; }
}

/* Progress Bars */
.debug-progress {
  width: 60px;
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
  margin-left: 8px;
}

.debug-progress-bar {
  height: 100%;
  background: #4CAF50;
  transition: width 0.2s, background-color 0.2s;
}

.debug-progress-bar.warning {
  background: #FF9800;
}

.debug-progress-bar.error {
  background: #f44336;
}

/* Mini Charts */
.debug-chart {
  width: 100px;
  height: 20px;
  margin-left: 8px;
  position: relative;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.debug-chart-line {
  position: absolute;
  bottom: 0;
  width: 2px;
  background: #4CAF50;
  transition: height 0.2s;
}

/* Tooltips */
.debug-tooltip {
  position: relative;
  cursor: help;
}

.debug-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 1001;
}

.debug-tooltip:hover::after {
  opacity: 1;
}

/* Network Status Indicators */
.connection-status {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.connection-status.connected {
  background: #4CAF50;
  box-shadow: 0 0 4px #4CAF50;
}

.connection-status.disconnected {
  background: #f44336;
  box-shadow: 0 0 4px #f44336;
}

.connection-status.connecting {
  background: #FF9800;
  box-shadow: 0 0 4px #FF9800;
  animation: pulse 1s infinite;
}

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

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .debug-panel {
    width: calc(100vw - 40px);
    max-width: 300px;
    top: 10px;
    right: 10px;
    font-size: 11px;
  }
  
  .debug-metric-value {
    min-width: 70px;
  }
  
  .debug-progress {
    width: 50px;
  }
  
  .debug-chart {
    width: 80px;
    height: 16px;
  }
}

/* Compact Mode */
.debug-panel.compact .debug-section {
  padding: 4px 8px;
}

.debug-panel.compact .debug-metric {
  margin-bottom: 2px;
}

.debug-panel.compact .debug-section-title {
  font-size: 12px;
  margin-bottom: 4px;
}

/* Toggle Hint */
.debug-hint {
  position: fixed;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  opacity: 0.7;
  pointer-events: none;
  z-index: 999;
}

.debug-hint.hidden {
  display: none;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .debug-panel {
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid #fff;
  }
  
  .debug-section {
    border-bottom: 1px solid #666;
  }
  
  .debug-metric-label {
    color: #fff;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .debug-panel,
  .debug-toggle,
  .debug-progress-bar,
  .debug-chart-line,
  .debug-tooltip::after {
    transition: none;
  }
  
  .status-critical {
    animation: none;
  }
  
  .connection-status.connecting {
    animation: none;
  }
}