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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #0f0f1a;
  color: #eee;
  min-height: 100vh;
}

.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 240px;
  background: #16213e;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #1e3a5f;
}

.logo {
  padding: 20px;
  border-bottom: 1px solid #1e3a5f;
}

.logo h1 {
  font-size: 20px;
  font-weight: 600;
  color: #3b82f6;
}

.nav-menu {
  list-style: none;
  padding: 10px 0;
  flex: 1;
}

.nav-item {
  padding: 12px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #888;
  transition: all 0.2s;
}

.nav-item:hover {
  background: rgba(59, 130, 246, 0.1);
  color: #eee;
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
  border-right: 3px solid #3b82f6;
}

.nav-item .icon {
  font-size: 18px;
}

.nav-footer {
  padding: 15px 20px;
  border-top: 1px solid #1e3a5f;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #888;
}

.connection-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
}

.connection-status.disconnected .dot {
  background: #f87171;
}

/* Main Content */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

.view.active {
  display: flex;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background: #1a1a2e;
  border-bottom: 1px solid #333;
}

.view-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.header-actions select,
.header-actions input {
  padding: 8px 12px;
  border: 1px solid #333;
  border-radius: 4px;
  background: #16213e;
  color: #eee;
  font-size: 14px;
}

/* Camera Grid */
.camera-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 15px;
  padding: 20px;
  overflow-y: auto;
}

.camera-feed {
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.camera-feed video {
  width: 100%;
  display: block;
}

.camera-feed .camera-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.camera-feed .camera-name {
  font-size: 14px;
  font-weight: 600;
}

.camera-feed .camera-status {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  background: rgba(74, 222, 128, 0.2);
  color: #4ade80;
}

.camera-feed .camera-status.offline {
  background: rgba(248, 113, 113, 0.2);
  color: #f87171;
}

.camera-feed .camera-status.motion {
  background: rgba(248, 113, 113, 0.4);
  color: #fff;
  animation: pulse 1s infinite;
}

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

.camera-feed.offline {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 225px;
  color: #666;
}

/* Playback */
.playback-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow: hidden;
}

.video-player {
  flex: 1;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-player video {
  max-width: 100%;
  max-height: 100%;
}

.timeline-container {
  margin-top: 20px;
}

.timeline {
  height: 60px;
  background: #16213e;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.timeline-segment {
  position: absolute;
  top: 10px;
  bottom: 10px;
  background: #3b82f6;
  border-radius: 2px;
  cursor: pointer;
  opacity: 0.7;
}

.timeline-segment:hover {
  opacity: 1;
}

.timeline-segment.motion {
  background: #ef4444;
}

.timeline-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-top: 10px;
}

#timeline-date {
  font-size: 14px;
  color: #888;
}

/* Clips Grid */
.clips-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 15px;
  padding: 20px;
  overflow-y: auto;
}

.clip-card {
  background: #16213e;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s;
}

.clip-card:hover {
  transform: translateY(-2px);
}

.clip-card .clip-thumbnail {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
}

.clip-card .clip-info {
  padding: 12px;
}

.clip-card .clip-time {
  font-size: 14px;
  font-weight: 500;
}

.clip-card .clip-meta {
  font-size: 12px;
  color: #888;
  margin-top: 5px;
  display: flex;
  justify-content: space-between;
}

.clip-card .clip-flagged {
  color: #fbbf24;
}

/* Cameras List */
.cameras-list {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.camera-card {
  background: #16213e;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.camera-card .camera-info h3 {
  font-size: 16px;
  margin-bottom: 5px;
}

.camera-card .camera-info p {
  font-size: 12px;
  color: #888;
}

.camera-card .camera-actions {
  display: flex;
  gap: 10px;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  background: #333;
  color: #eee;
  transition: background 0.2s;
}

.btn:hover {
  background: #444;
}

.btn-primary {
  background: #3b82f6;
  color: white;
}

.btn-primary:hover {
  background: #2563eb;
}

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

.btn-danger:hover {
  background: #dc2626;
}

.btn-icon {
  background: none;
  border: 1px solid #333;
  color: #888;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
}

.btn-icon:hover {
  background: #333;
  color: #eee;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #16213e;
  border-radius: 12px;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #333;
}

.modal-header h3 {
  font-size: 18px;
}

.modal-close {
  background: none;
  border: none;
  color: #888;
  font-size: 24px;
  cursor: pointer;
}

.modal-close:hover {
  color: #eee;
}

.modal-body {
  flex: 1;
  overflow: auto;
  background: #000;
}

.modal-body video {
  width: 100%;
  display: block;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 15px 20px;
  border-top: 1px solid #333;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #666;
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 15px;
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 10px;
  color: #888;
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #666;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #333;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
  }

  .logo h1,
  .nav-item span:not(.icon),
  .connection-status span:not(.dot) {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: 15px;
  }

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