/* ========================================
   KANSHI - Surveillance System UI
   Futuristic SaaS Design
   ======================================== */

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2035;
  --bg-card-hover: #1f2a45;
  --border: #2a3555;
  --border-glow: #3b82f6;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-light: #60a5fa;
  --accent-dark: #1d4ed8;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --gradient-1: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --gradient-2: linear-gradient(135deg, #0a0e17, #1a2035);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background Grid Pattern */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    linear-gradient(rgba(59, 130, 246, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59, 130, 246, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* ---- Header / Navbar ---- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.navbar-logo {
  width: 36px;
  height: 36px;
  background: var(--gradient-1);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.navbar-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.navbar-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 3px;
  text-transform: uppercase;
}

.navbar-status {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 20px;
  font-size: 12px;
  color: var(--success);
  font-weight: 500;
}

.status-badge.offline {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse-dot 2s ease-in-out infinite;
}

.status-badge.offline .status-dot {
  background: var(--danger);
  animation: none;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ---- Main Content ---- */
.main-content {
  padding-top: 64px;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ========================================
   CAMERA PAGE (Tablet)
   ======================================== */
.camera-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 64px);
  padding: 20px;
}

.camera-feed-wrapper {
  position: relative;
  width: 100%;
  max-width: 800px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-glow), var(--shadow-card);
  background: #000;
}

.camera-feed-wrapper video {
  width: 100%;
  display: block;
  min-height: 300px;
  object-fit: cover;
}

/* Camera Overlay HUD */
.camera-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.camera-overlay-top {
  display: flex;
  justify-content: space-between;
  padding: 16px;
}

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

.hud-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  color: #fff;
  letter-spacing: 0.5px;
}

.hud-badge.rec {
  color: var(--danger);
}

.hud-badge.rec::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse-dot 1s ease-in-out infinite;
}

/* Scan line effect */
.scanline {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.4), transparent);
  animation: scanline 4s linear infinite;
}

@keyframes scanline {
  0% { top: 0; }
  100% { top: 100%; }
}

/* Corner brackets */
.corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--accent);
  border-style: solid;
  border-width: 0;
  opacity: 0.6;
}
.corner.tl { top: 12px; left: 12px; border-top-width: 2px; border-left-width: 2px; }
.corner.tr { top: 12px; right: 12px; border-top-width: 2px; border-right-width: 2px; }
.corner.bl { bottom: 12px; left: 12px; border-bottom-width: 2px; border-left-width: 2px; }
.corner.br { bottom: 12px; right: 12px; border-bottom-width: 2px; border-right-width: 2px; }

/* Camera Controls */
.camera-controls {
  margin-top: 20px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.3px;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}

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

.btn-primary:hover {
  opacity: 0.9;
  box-shadow: 0 0 30px rgba(59, 130, 246, 0.3);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* Camera Info Card */
.camera-info {
  margin-top: 20px;
  width: 100%;
  max-width: 800px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.info-item {
  text-align: center;
}

.info-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.info-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ========================================
   VIEWER PAGE (PC)
   ======================================== */
.viewer-layout {
  display: flex;
  height: calc(100vh - 64px);
}

/* Sidebar */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.sidebar-count {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.camera-list {
  flex: 1;
  padding: 12px;
}

.camera-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 4px;
}

.camera-list-item:hover {
  background: var(--bg-card-hover);
}

.camera-list-item.active {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.camera-list-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.camera-list-info {
  flex: 1;
  min-width: 0;
}

.camera-list-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.camera-list-status {
  font-size: 11px;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 4px;
}

.camera-list-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

/* Viewer Main Area */
.viewer-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.5);
}

.viewer-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.viewer-toolbar-title {
  font-size: 16px;
  font-weight: 600;
}

.viewer-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.toolbar-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

.toolbar-btn.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* Video Grid */
.video-grid {
  flex: 1;
  display: grid;
  gap: 2px;
  padding: 2px;
  background: var(--bg-primary);
  overflow: auto;
}

.video-grid.grid-1 { grid-template-columns: 1fr; }
.video-grid.grid-2 { grid-template-columns: 1fr 1fr; }
.video-grid.grid-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }

.video-cell {
  position: relative;
  background: #0d1117;
  overflow: hidden;
  min-height: 200px;
}

.video-cell video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.video-cell-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 14px;
  background: linear-gradient(rgba(0,0,0,0.6), transparent);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}

.video-cell-label {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  gap: 6px;
}

.video-cell-label .live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse-dot 1s ease-in-out infinite;
}

.video-cell-time {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  font-family: 'Courier New', monospace;
}

/* Empty State */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 16px;
}

.empty-state-icon {
  font-size: 64px;
  opacity: 0.3;
}

.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state-desc {
  font-size: 14px;
  max-width: 400px;
  text-align: center;
  line-height: 1.6;
}

/* No camera placeholder inside video cell */
.no-signal {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 8px;
  font-size: 13px;
  min-height: 300px;
}

.no-signal-icon {
  font-size: 40px;
  opacity: 0.3;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .navbar-subtitle {
    display: none;
  }
  .video-grid.grid-4 {
    grid-template-columns: 1fr;
  }
}

/* ---- Animations ---- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.4s ease-out;
}

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