:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #243044;
  --border: #2d3a4f;
  --text: #e8edf4;
  --text-muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --live: #22c55e;
  --offline: #ef4444;
  --waiting: #f59e0b;
  --loading: #60a5fa;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.site-header {
  background: linear-gradient(135deg, #1e3a5f 0%, #0f1419 100%);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 1rem;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
}

.site-header h1 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 700;
}

.site-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.back-link:hover {
  color: var(--text);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.toolbar input,
.toolbar select {
  flex: 1 1 200px;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
}

.toolbar input:focus,
.toolbar select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.result-count {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.camera-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.camera-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow);
}

.camera-card:hover,
.camera-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--accent);
  outline: none;
}

.camera-video-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
}

.camera-video,
.detail-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}

.camera-status,
.detail-status {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.camera-status[data-state='live'],
.detail-status[data-state='live'] {
  color: var(--live);
}

.camera-status[data-state='offline'],
.detail-status[data-state='offline'] {
  color: var(--offline);
}

.camera-status[data-state='waiting'],
.detail-status[data-state='waiting'] {
  color: var(--waiting);
}

.camera-status[data-state='loading'],
.detail-status[data-state='loading'] {
  color: var(--loading);
}

.camera-status[data-state='idle'] {
  color: var(--text-muted);
}

.camera-info {
  padding: 0.85rem 1rem 1rem;
}

.camera-name {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 600;
}

.camera-location {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.camera-category {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--surface-hover);
  color: var(--text-muted);
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
}

.page-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

.page-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-info {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.site-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

/* Halaman detail */
.detail-header {
  margin-bottom: 1.25rem;
}

.detail-header h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.detail-player-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: 70vh;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.detail-actions {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

.btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.webrtc-panel {
  margin-top: 1rem;
}

.webrtc-panel iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #000;
}

@media (max-width: 600px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .result-count {
    text-align: center;
  }
}
