/* Enhanced WebSocket Client Styles */
* {
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 20px;
  background-color: #f5f5f5;
  color: #333;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  padding: 24px;
  overflow: hidden;
}

h1 {
  color: #333;
  text-align: center;
  margin-bottom: 32px;
  font-weight: 600;
}

.status-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 12px;
  margin-bottom: 24px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.status-connected {
  background: #4CAF50;
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}

.status-connecting {
  background: #FFC107;
  animation: pulse 1.5s infinite;
}

.status-disconnected {
  background: #F44336;
}

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

.health-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: bold;
}

.health-excellent {
  background: #d4edda;
  color: #155724;
}

.health-good {
  background: #d1ecf1;
  color: #0c5460;
}

.health-warning {
  background: #fff3cd;
  color: #856404;
}

.health-poor {
  background: #f8d7da;
  color: #721c24;
}

.tabs {
  display: flex;
  border-bottom: 2px solid #e9ecef;
  margin-bottom: 24px;
  overflow-x: auto;
  background: white;
  border-radius: 8px 8px 0 0;
}

.tab {
  padding: 16px 24px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.3s ease;
  font-weight: 500;
  color: #666;
}

.tab:hover {
  background: #f8f9fa;
  color: #333;
}

.tab.active {
  border-bottom-color: #1976d2;
  color: #1976d2;
  font-weight: 600;
  background: #f8f9fa;
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-content.active {
  display: block;
}

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

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
  padding: 24px;
  background: #f8f9fa;
  border-radius: 8px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-group label {
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.input-group input,
.input-group select,
.input-group textarea {
  padding: 12px 16px;
  border: 2px solid #e9ecef;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.3s ease;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
  outline: none;
  border-color: #1976d2;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.checkbox-group input[type="checkbox"] {
  margin: 0;
  width: 18px;
  height: 18px;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-primary {
  background: #1976d2;
  color: white;
}

.btn-primary:hover {
  background: #1565c0;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.3);
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background: #5a6268;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.btn-warning {
  background: #FFC107;
  color: #212529;
}

.btn-warning:hover {
  background: #e0a800;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 193, 7, 0.3);
}

.btn-info {
  background: #17a2b8;
  color: white;
}

.btn-info:hover {
  background: #138496;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(23, 162, 184, 0.3);
}

.btn-danger {
  background: #dc3545;
  color: white;
}

.btn-danger:hover {
  background: #c82333;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

.btn-success {
  background: #28a745;
  color: white;
}

.btn-success:hover {
  background: #218838;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.messages-container {
  height: 500px;
  overflow-y: auto;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  padding: 20px;
  background: #fafafa;
  font-family: "SF Mono", "Monaco", "Inconsolata", "Roboto Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
}

.messages-container::-webkit-scrollbar {
  width: 8px;
}

.messages-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

.message {
  margin-bottom: 16px;
  padding: 16px;
  border-radius: 8px;
  border-left: 4px solid #1976d2;
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  animation: slideIn 0.3s ease;
}

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

.message.error {
  border-left-color: #dc3545;
  background: #fff5f5;
}

.message.warning {
  border-left-color: #FFC107;
  background: #fffbf0;
}

.message.info {
  border-left-color: #17a2b8;
  background: #f0f9ff;
}

.message.success {
  border-left-color: #28a745;
  background: #f0fff4;
}

.message-time {
  font-size: 11px;
  color: #666;
  margin-bottom: 8px;
  font-weight: 500;
}

.message-type {
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin: 24px 0;
}

.stat-card {
  background: white;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  text-align: center;
  border: 1px solid #e9ecef;
}

.stat-number {
  font-size: 2.5em;
  font-weight: 700;
  color: #1976d2;
  margin-bottom: 8px;
}

.stat-label {
  color: #666;
  font-size: 14px;
  font-weight: 500;
}

.online-users {
  max-height: 400px;
  overflow-y: auto;
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  border: 1px solid #e9ecef;
}

.online-users::-webkit-scrollbar {
  width: 6px;
}

.online-users::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.online-users::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  margin: 8px 0;
  background: white;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  border: 1px solid #e9ecef;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-id {
  font-weight: 600;
  color: #333;
}

.user-details {
  font-size: 12px;
  color: #666;
}

.loading-indicator {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #1976d2;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 8px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.message-limit-warning {
  background: #fff3cd;
  border: 1px solid #ffeaa7;
  padding: 16px;
  margin: 16px 0;
  border-radius: 6px;
  font-size: 14px;
  color: #856404;
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-controls {
  background: #fff3cd;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 24px;
  border: 1px solid #ffeaa7;
}

.admin-warning {
  color: #856404;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

pre {
  background: #f8f9fa;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
  border: 1px solid #e9ecef;
  margin: 8px 0;
}

code {
  background: #f8f9fa;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: "SF Mono", "Monaco", "Inconsolata", "Roboto Mono", monospace;
  font-size: 13px;
}

.message pre {
  white-space: pre-wrap;
  word-break: break-word;
}

.message code {
  display: block;
  margin: 8px 0;
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    margin: 10px;
    padding: 16px;
    border-radius: 8px;
  }

  .controls {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .status-bar {
    grid-template-columns: 1fr;
    padding: 16px;
  }

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

  .tabs {
    flex-wrap: wrap;
  }

  .tab {
    padding: 12px 16px;
    font-size: 14px;
  }

  .messages-container {
    height: 300px;
    font-size: 12px;
  }

  .message {
    padding: 12px;
    font-size: 13px;
  }

  .btn {
    padding: 10px 16px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 12px;
  }

  .controls {
    padding: 12px;
  }

  .status-bar {
    padding: 12px;
  }

  .messages-container {
    height: 250px;
    padding: 12px;
  }

  .tab {
    padding: 8px 12px;
    font-size: 12px;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  body {
    background-color: #121212;
    color: #e0e0e0;
  }

  .container {
    background: #1e1e1e;
    border: 1px solid #333;
  }

  .controls {
    background: #2a2a2a;
    border: 1px solid #404040;
  }

  .message {
    background: #2a2a2a;
    border: 1px solid #404040;
  }

  .stat-card {
    background: #2a2a2a;
    border: 1px solid #404040;
  }

  .online-users {
    background: #2a2a2a;
    border: 1px solid #404040;
  }

  .user-item {
    background: #333;
    border: 1px solid #404040;
  }

  .messages-container {
    background: #1a1a1a;
    border-color: #404040;
  }

  pre {
    background: #2a2a2a;
    border-color: #404040;
  }

  code {
    background: #333;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for keyboard navigation */
.btn:focus,
.tab:focus,
.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
  outline: 2px solid #1976d2;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .btn {
    border: 2px solid currentColor;
  }

  .message {
    border: 2px solid currentColor;
  }

  .stat-card {
    border: 2px solid currentColor;
  }
}
