/**
 * Camera UI Styling
 * Styles for WebRTC camera streaming interface with connection state indicators
 */

/* Camera Container */
.camera-container {
  position: relative;
  margin-bottom: 20px;
}

.camera-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding: 10px 0;
}

.camera-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

/* Connection Status Badges */
.connection-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
}

.connection-badge.disconnected {
  background-color: #6c757d;
  color: white;
}

.connection-badge.connecting {
  background-color: #ffc107;
  color: #000;
  animation: pulse 1.5s ease-in-out infinite;
}

.connection-badge.connected {
  background-color: #28a745;
  color: white;
}

.connection-badge.failed {
  background-color: #dc3545;
  color: white;
}

.connection-badge.retrying {
  background-color: #17a2b8;
  color: white;
  animation: pulse 2s ease-in-out infinite;
}

/* Pulse Animation */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* Reconnect Button */
.btn-reconnect {
  padding: 6px 16px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color 0.2s ease;
}

.btn-reconnect:hover {
  background-color: #0056b3;
}

.btn-reconnect:active {
  background-color: #004085;
}

.btn-reconnect:disabled {
  background-color: #6c757d;
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-reconnect.hidden {
  display: none;
}

/* Video Wrapper */
.video-wrapper {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

.video-wrapper video {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

/* Video Overlay */
.video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.video-overlay.visible {
  opacity: 1;
}

.video-overlay .message {
  margin-top: 16px;
  font-size: 1rem;
  text-align: center;
  max-width: 80%;
}

/* Spinner Animation */
.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Error Message */
.error-message {
  margin-top: 10px;
  padding: 12px;
  background-color: #f8d7da;
  border: 1px solid #f5c6cb;
  border-radius: 4px;
  color: #721c24;
  font-size: 0.875rem;
  display: none;
}

.error-message.visible {
  display: block;
}

.error-message strong {
  display: block;
  margin-bottom: 4px;
}

/* Retry Countdown */
.retry-countdown {
  font-size: 0.75rem;
  color: #17a2b8;
  margin-top: 4px;
  font-style: italic;
}

/* Camera Grid Layout */
.cameras-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 24px;
  margin-top: 20px;
}

@media (max-width: 768px) {
  .cameras-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .camera-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .connection-badge {
    align-self: flex-start;
  }

  .btn-reconnect {
    align-self: flex-start;
    margin-top: 8px;
  }
}

/* Stats Display (Optional) */
.connection-stats {
  margin-top: 8px;
  padding: 8px;
  background-color: #f8f9fa;
  border-radius: 4px;
  font-size: 0.75rem;
  color: #6c757d;
  font-family: monospace;
  display: none;
}

.connection-stats.visible {
  display: block;
}

.connection-stats .stat-line {
  margin: 2px 0;
}

/* Success Message */
.success-message {
  margin-top: 10px;
  padding: 12px;
  background-color: #d4edda;
  border: 1px solid #c3e6cb;
  border-radius: 4px;
  color: #155724;
  font-size: 0.875rem;
  display: none;
}

.success-message.visible {
  display: block;
}
