* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0a0a0a;
  color: #ddd;
  font-family: system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

:root {
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 52px;
}

.side-menu {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: #111;
  border-right: 1px solid #333;
  padding: 14px 12px 20px;
  z-index: 200;
  overflow-y: auto;
  transition: width 0.22s ease, padding 0.22s ease;
}

.side-menu.collapsed {
  width: var(--sidebar-collapsed-width);
  padding-left: 6px;
  padding-right: 6px;
  overflow-x: hidden;
}

.sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.menu-banner {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-bottom: 10px;
}

.menu-banner img {
  width: 100%;
  max-width: 220px;
  height: auto;
  object-fit: contain;
  display: block;
  filter: brightness(1.02) contrast(1.04);
}

.sidebar-toggle {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #1a1a1a;
  color: #ddd;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.15s ease;
}

.sidebar-toggle:hover {
  background: #242424;
  border-color: #444;
}

.sidebar-toggle:active {
  transform: scale(0.96);
}

.menu-title {
  padding: 0 12px 12px;
  font-size: 0.92rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.menu-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #222;
}

.mode-toggle {
  display: flex;
  background: #1a1a1a;
  border-radius: 6px;
  padding: 4px;
  margin: 12px 8px;
  gap: 4px;
}

.mode-btn {
  flex: 1;
  padding: 10px 4px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  min-height: 52px;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.mode-btn:hover {
  background: #242424;
  border-color: #2f2f2f;
}

.mode-btn.active {
  background: #333;
  border-color: #4ade80;
  box-shadow:
    0 0 8px rgba(74, 222, 128, 0.45),
    0 0 16px rgba(74, 222, 128, 0.25);
}

.mode-btn.disabled {
  opacity: 0.45;
}

.mode-btn img {
  width: 80%;
  height: 80%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  display: block;
  filter: brightness(0.9) contrast(1.05);
  transition: filter 0.2s, transform 0.15s;
}

.mode-btn:hover img {
  filter: brightness(1.1);
  transform: scale(1.05);
}

.mode-btn.active img {
  filter: brightness(1.2) drop-shadow(0 0 6px rgba(74, 222, 128, 0.7));
}

.camera-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  margin: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.2s ease, filter 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.camera-toggle:hover {
  background: #1a1a1a;
}

.camera-toggle.active {
  background: #222;
  border-left: 3px solid #4ade80;
}

.camera-toggle.offline {
  opacity: 0.5;
  filter: grayscale(0.9);
}

.camera-toggle.offline.active {
  border-left-color: #6b7280;
}

.toggle-switch {
  width: 42px;
  height: 22px;
  background: #333;
  border-radius: 9999px;
  position: relative;
  flex: 0 0 auto;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #ddd;
  border-radius: 50%;
  transition: transform 0.2s;
}

.camera-toggle.active .toggle-switch {
  background: #4ade80;
}

.camera-toggle.active .toggle-switch::after {
  transform: translateX(20px);
}

.camera-toggle.offline .toggle-switch {
  background: #444;
}

.camera-toggle.offline .toggle-switch::after {
  background: #a3a3a3;
}

.status-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 8px 8px;
}

.status-card {
  background: #181818;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 10px 12px;
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.status-card.offline {
  opacity: 0.7;
  filter: grayscale(0.65);
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.status-name {
  font-size: 0.92rem;
  color: #ddd;
}

.status-detail {
  font-size: 0.78rem;
  color: #9ca3af;
  line-height: 1.35;
  min-height: 1em;
  word-break: break-word;
}

.status-chip {
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: rgba(75, 85, 99, 0.92);
  white-space: nowrap;
}

.status-live { background: rgba(22, 101, 52, 0.9); }
.status-near { background: rgba(161, 98, 7, 0.92); }
.status-delayed { background: rgba(153, 27, 27, 0.92); }
.status-error { background: rgba(75, 85, 99, 0.92); }

.main-content {
  margin-left: var(--sidebar-width);
  height: 100vh;
  padding: 12px;
  position: relative;
  transition: margin-left 0.22s ease;
}

.main-content.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed-width);
}

.grid {
  display: grid;
  gap: 12px;
  height: 100%;
}

.grid-1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.grid-2 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
.grid-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }

.pip-container {
  position: relative;
  height: 100%;
}

.main-video {
  width: 100%;
  height: 100%;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}

.pip-section {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  z-index: 100;
  max-width: calc(100% - 40px);
}

.pip-grid {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pip {
  background: #111;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.85);
  border: 2px solid #555;
  position: relative;
}

.global-scale-handle {
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: nwse-resize;
  z-index: 200;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
  margin-bottom: 8px;
  user-select: none;
}

.camera {
  background: #111;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.offline-placeholder {
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  filter: grayscale(0.7);
}

.pip.camera {
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.pip.camera:hover {
  transform: translateY(-2px);
  border-color: #888;
}

.label {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.95rem;
  z-index: 10;
}

video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.controls {
  padding: 8px 12px;
  background: #1a1a1a;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

button {
  background: #333;
  color: #ddd;
  border: none;
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
}

button:hover {
  background: #555;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.side-menu.collapsed .menu-banner,
.side-menu.collapsed .menu-title,
.side-menu.collapsed .menu-section,
.side-menu.collapsed #menu-items {
  display: none;
}

.side-menu.collapsed .sidebar-header {
  justify-content: center;
  margin-bottom: 0;
}

.side-menu.collapsed .sidebar-toggle {
  width: 40px;
  height: 40px;
}
