:root {
  --bg-base:    #0a0d14;
  --bg-card:    #111827;
  --bg-card2:   #1a2235;
  --bg-sidebar: #0d1117;
  --accent:     #00e5ff;
  --accent2:    #7c3aed;
  --success:    #10b981;
  --warning:    #f59e0b;
  --danger:     #ef4444;
  --text:       #e2e8f0;
  --text-muted: #64748b;
  --border:     rgba(255,255,255,0.07);
  --glow:       0 0 20px rgba(0,229,255,0.15);
  --radius:     12px;
  --sidebar-w:  220px;
}

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

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  overflow: hidden;
}

/* ========== SIDEBAR ========== */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  padding: 0 0 1rem 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.logo-icon { font-size: 1.75rem; }
.logo-title { display: block; font-size: 1.1rem; font-weight: 700; color: var(--accent); line-height: 1; }
.logo-sub   { display: block; font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  position: relative;
  text-align: left;
}

.nav-item:hover { background: var(--bg-card2); color: var(--text); }
.nav-item.active { background: rgba(0,229,255,0.1); color: var(--accent); }
.nav-item.active .nav-icon { filter: drop-shadow(0 0 4px var(--accent)); }

.nav-icon { font-size: 1.1rem; width: 1.5rem; text-align: center; }
.nav-badge {
  position: absolute;
  right: 0.75rem;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.system-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}
.status-dot.online  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--danger); }

.clock {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 500;
}

/* ========== MAIN ========== */
.main {
  margin-left: var(--sidebar-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ========== TOPBAR ========== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-base);
  flex-shrink: 0;
}

.page-title { font-size: 1.1rem; font-weight: 600; }
.breadcrumb { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--danger);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
}

.pulse {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(1.3); }
}

.btn-icon {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: var(--bg-card); border-color: var(--accent); color: var(--accent); }

/* ========== SECTIONS ========== */
.section { display: none; flex: 1; overflow-y: auto; padding: 1.25rem; }
.section.active { display: flex; flex-direction: column; }

/* ========== CAMERA GRID ========== */
.cameras-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  flex: 1;
}

.camera-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: border-color 0.3s;
}
.camera-card:hover { border-color: rgba(0,229,255,0.3); }

.camera-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: rgba(0,0,0,0.4);
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
}

.camera-name {
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.cam-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cam-badge.live    { background: rgba(239,68,68,0.3); color: var(--danger); border: 1px solid var(--danger); }
.cam-badge.offline { background: rgba(100,116,139,0.3); color: var(--text-muted); border: 1px solid var(--text-muted); }

.camera-video-wrap {
  flex: 1;
  background: #000;
  min-height: 220px;
  position: relative;
}

video.camera-stream {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 0.5rem 0.75rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 5;
}

.cam-timestamp {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.8);
}

.cam-fps {
  font-size: 0.65rem;
  color: var(--success);
  font-weight: 600;
}

.offline-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  background: #000;
}
.offline-placeholder span { font-size: 2.5rem; }

/* ========== GRAVAÇÕES ========== */
.recordings-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1rem;
  flex: 1;
  height: 100%;
}

.recordings-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.section-heading {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.camera-tabs { display: flex; flex-direction: column; gap: 0.4rem; }

.cam-tab {
  padding: 0.6rem 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  display: flex; align-items: center; gap: 0.5rem;
}
.cam-tab:hover, .cam-tab.active {
  background: rgba(0,229,255,0.1);
  border-color: var(--accent);
  color: var(--accent);
}

.date-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.8rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
}
.date-input:focus { outline: none; border-color: var(--accent); }

.recordings-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.recordings-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rec-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.rec-item:hover { border-color: var(--accent); transform: translateX(3px); }
.rec-item-icon { font-size: 1.5rem; }
.rec-item-info { flex: 1; }
.rec-item-name { font-size: 0.8rem; font-weight: 600; font-family: 'JetBrains Mono', monospace; }
.rec-item-meta { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }
.rec-item-size { font-size: 0.75rem; color: var(--text-muted); }

.video-player-wrap {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--glow);
}

.video-player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: rgba(0,229,255,0.05);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem;
  transition: color 0.2s;
}
.btn-close:hover { color: var(--danger); }

.recording-video {
  width: 100%;
  max-height: 300px;
  background: #000;
  display: block;
}

/* ========== ALERTAS ========== */
.alerts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.btn-danger-sm {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--danger);
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.2s;
}
.btn-danger-sm:hover { background: rgba(239,68,68,0.25); }

.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  overflow-y: auto;
}

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.9rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  animation: slideIn 0.3s ease;
  border-left: 3px solid var(--text-muted);
}
.alert-item.motion { border-left-color: var(--danger); }
.alert-item.info   { border-left-color: var(--accent); }
.alert-item.warn   { border-left-color: var(--warning); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.alert-icon  { font-size: 1.3rem; flex-shrink: 0; margin-top: 2px; }
.alert-body  { flex: 1; }
.alert-title { font-size: 0.85rem; font-weight: 600; }
.alert-meta  { font-size: 0.72rem; color: var(--text-muted); margin-top: 3px; }

/* ========== SISTEMA ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.stat-card:hover { border-color: var(--accent); box-shadow: var(--glow); }
.stat-icon  { font-size: 1.75rem; margin-bottom: 0.5rem; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--accent); font-family: 'JetBrains Mono', monospace; }
.stat-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }

.camera-info-list { display: flex; flex-direction: column; gap: 0.75rem; }
.camera-info-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.cam-info-icon { font-size: 1.5rem; }
.cam-info-name { font-weight: 600; }
.cam-info-status { font-size: 0.75rem; color: var(--text-muted); }

/* ========== EMPTY STATE ========== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  flex: 1;
}
.empty-state span { font-size: 2.5rem; }

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  :root { --sidebar-w: 64px; }
  .nav-label, .logo-text, .sidebar-footer .system-status span { display: none; }
  .logo-icon { font-size: 1.5rem; }
  .sidebar-logo { justify-content: center; padding: 1rem; }
  .nav-item { justify-content: center; padding: 0.75rem; }
  .cameras-grid { grid-template-columns: 1fr; }
  .recordings-layout { grid-template-columns: 1fr; }
}
