:root {
  --main-bg: #0f0f0f;
  --active-color: #006400;
  --button-bg: #222;
  --button-hover: #333;
  --inactive-color: #666;
  --offline-color: #500;
  --text-color: #fff;
  --padding: 16px;
  --max-player-width: 1440px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--main-bg);
  color: var(--text-color);
  font-family: system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-content {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.player-section {
  flex: 0 1 auto;
  padding: var(--padding);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  max-height: calc(100vh - 200px);
}

.button-section {
  flex-shrink: 0;
  padding: 0 var(--padding) var(--padding);
}

.container {
  max-width: var(--max-player-width);
  margin: 0 auto;
  width: 100%;
}

/* Main player area */
.theater-area {
  width: 100%;
  max-width: 100%;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  aspect-ratio: 16/9;
  max-height: calc(100vh - 220px);
  margin: 0 auto;
}

#player-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#video-player {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* Error overlay styles */
.error-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.error-content {
  text-align: center;
  padding: 30px;
  max-width: 400px;
}

.error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.error-message {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #ff6b6b;
}

.error-hint {
  font-size: 14px;
  color: #aaa;
  margin-bottom: 24px;
  line-height: 1.6;
}

.retry-button {
  background: var(--active-color);
  color: white;
  border: none;
  padding: 12px 32px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.retry-button:hover {
  background: #008000;
}

/* Camera selector bar */
.camera-selector-container {
  width: 100%;
  margin-bottom: 10px;
}

.camera-selector {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
}

/* Camera buttons */
.camera-button {
  height: 65px;
  background: var(--button-bg);
  border: 2px solid transparent;
  border-radius: 8px;
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 8px;
  text-align: center;
  user-select: none;
  position: relative;
}

.camera-button:not(.offline):hover {
  background: var(--button-hover);
  transform: translateY(-2px);
}

.camera-button.active {
  border-color: var(--active-color);
  background-color: rgba(0, 100, 0, 0.3);
}

/* Offline camera buttons - visible but dimmed */
.camera-button.offline {
  opacity: 0.6;
  cursor: pointer;
  border-color: var(--inactive-color);
  background-color: rgba(50, 50, 50, 0.3);
}

.camera-button.offline:hover {
  opacity: 0.8;
  background-color: rgba(70, 70, 70, 0.4);
}

.camera-button.offline .camera-name {
  color: #999;
}

.status-indicator {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #f00;
}

.status-indicator.live {
  background-color: #0f0;
  animation: pulse 2s infinite;
}

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

.camera-button .status-text {
  font-size: 11px;
  font-weight: normal;
  margin-top: 4px;
  opacity: 0.8;
}

.camera-button.offline .status-text {
  color: #888;
}

/* Status indicator */
.status-area {
  text-align: center;
  padding-bottom: 8px;
}

.status {
  padding: 4px 0;
  font-size: 13px;
  opacity: 0.8;
}

.last-check {
  font-size: 11px;
  opacity: 0.6;
}

/* Loading spinner for video */
.loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 50;
}

@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Responsive adjustments */
@media (max-width: 1200px) {
  .player-section {
    max-height: calc(100vh - 180px);
  }
  
  .theater-area {
    max-height: calc(100vh - 200px);
  }
}

@media (max-width: 1024px) {
  :root {
    --padding: 12px;
  }
  
  .player-section {
    max-height: calc(100vh - 170px);
  }
  
  .theater-area {
    max-height: calc(100vh - 190px);
  }
  
  .camera-button {
    height: 60px;
    font-size: 16px;
  }
}

@media (max-width: 768px) {
  :root {
    --padding: 10px;
  }
  
  .camera-selector {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  
  .player-section {
    max-height: calc(100vh - 280px);
  }
  
  .theater-area {
    max-height: calc(100vh - 300px);
  }
  
  .camera-button {
    height: 55px;
    font-size: 15px;
  }
  
  .error-content {
    padding: 20px;
  }
  
  .error-icon {
    font-size: 36px;
  }
  
  .error-message {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  :root {
    --padding: 8px;
  }
  
  .camera-selector {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  
  .player-section {
    max-height: calc(100vh - 520px);
  }
  
  .theater-area {
    max-height: calc(100vh - 540px);
  }
  
  .camera-button {
    height: 50px;
    font-size: 14px;
  }
  
  .status-indicator {
    width: 7px;
    height: 7px;
  }
  
  .camera-button .status-text {
    font-size: 10px;
  }
}

/* Additional constraint to prevent video zoom */
@media (min-width: 1441px) {
  .theater-area {
    max-width: var(--max-player-width);
    margin: 0 auto;
  }
}
