/* ==========================================================================
   新北市交通局 CCTV 即時監控戰情室 (NTPC Traffic CCTV Operations Center)
   Design System & Modern Dark SOC Theme
   ========================================================================== */

:root {
  /* Color Palette - Cyber Operations Center */
  --bg-primary: #0a0d14;
  --bg-secondary: #111622;
  --bg-tertiary: #182030;
  --bg-card: rgba(20, 27, 41, 0.75);
  --bg-card-hover: rgba(28, 38, 58, 0.85);
  --bg-glass: rgba(15, 23, 42, 0.65);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-active: #06b6d4;
  --border-active-glow: rgba(6, 182, 212, 0.35);

  --accent-cyan: #06b6d4;
  --accent-cyan-light: #38bdf8;
  --accent-cyan-glow: rgba(6, 182, 212, 0.2);
  --accent-green: #10b981;
  --accent-green-glow: rgba(16, 185, 129, 0.2);
  --accent-red: #ef4444;
  --accent-amber: #f59e0b;
  --accent-blue: #3b82f6;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-dark: #0f172a;

  /* Sizing & Layout */
  --header-height: 60px;
  --sidebar-width: 360px;
  --sidebar-collapsed-width: 0px;
  --bottombar-height: 32px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 15px rgba(6, 182, 212, 0.3);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Background ambient grid pattern */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* App Container */
#app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  z-index: 1;
}

/* ==========================================================================
   Header Bar
   ========================================================================== */
.header-bar {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 20;
  user-select: none;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-toggle-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.sidebar-toggle-btn:hover {
  background: var(--accent-cyan-glow);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0284c7, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.4);
}

.brand-icon svg {
  width: 18px;
  height: 18px;
  color: #fff;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
  letter-spacing: 0.5px;
}

/* Center Layout Modes */
.layout-switcher {
  display: flex;
  align-items: center;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.layout-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.layout-btn svg {
  width: 15px;
  height: 15px;
}

.layout-btn:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.layout-btn.active {
  background: var(--accent-cyan);
  color: var(--text-dark);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.4);
}

/* Header Tools & Clock */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.system-clock {
  font-family: 'JetBrains Mono', monospace, Consolas;
  font-size: 0.85rem;
  color: var(--accent-cyan-light);
  background: rgba(6, 182, 212, 0.08);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(6, 182, 212, 0.2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--accent-green);
  animation: pulse-glow 2s infinite ease-in-out;
}

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

.btn-icon-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-icon-label svg {
  width: 15px;
  height: 15px;
}

.btn-icon-label:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

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

/* ==========================================================================
   Main Workspace Layout
   ========================================================================== */
.main-workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ==========================================================================
   Sidebar (Device Explorer)
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100%;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-normal);
  position: relative;
  z-index: 10;
}

.sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-width));
}

/* Sidebar Search & Filter Section */
.sidebar-header {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(17, 22, 34, 0.95);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 11px;
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.85rem;
  padding: 8px 32px 8px 34px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: var(--transition-fast);
}

.search-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.2);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-clear-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: none;
  padding: 2px;
}

.search-clear-btn:hover {
  color: var(--text-primary);
}

/* Filter Chips */
.district-filter-container {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 84px;
  overflow-y: auto;
  padding-right: 2px;
}

.district-chip {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.district-chip:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.district-chip.active {
  background: var(--accent-cyan-glow);
  color: var(--accent-cyan-light);
  border-color: var(--accent-cyan);
  font-weight: 600;
}

.district-chip.star-chip.active {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: #f59e0b;
}

/* Sidebar List Stats & Actions */
.sidebar-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-subtle);
}

.quick-fill-btn {
  background: none;
  border: none;
  color: var(--accent-cyan);
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.quick-fill-btn:hover {
  text-decoration: underline;
}

/* Camera Device List */
.camera-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.camera-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: var(--transition-fast);
  user-select: none;
  position: relative;
}

.camera-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.camera-card.in-use {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.08);
}

.camera-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-district {
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-cyan-light);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.2);
}

.badge-id {
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace, Consolas;
  color: var(--text-muted);
}

.badge-in-use {
  font-size: 0.65rem;
  color: var(--accent-green);
  background: rgba(16, 185, 129, 0.15);
  padding: 1px 5px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.card-star-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.card-star-btn:hover, .card-star-btn.starred {
  color: #fbbf24;
}

.camera-card-name {
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.35;
}

.camera-card-loc {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Dragging preview styling */
.camera-card[draggable="true"] {
  cursor: grab;
}
.camera-card.dragging {
  opacity: 0.4;
  border: 1px dashed var(--accent-cyan);
}

/* ==========================================================================
   Video Wall Grid Stage
   ========================================================================== */
.stage-container {
  flex: 1;
  height: 100%;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  padding: 12px;
}

.grid-wrapper {
  flex: 1;
  width: 100%;
  height: 100%;
  display: grid;
  gap: 10px;
  overflow: hidden;
  transition: all var(--transition-normal);
}

/* Grid Layout Modes */
.grid-wrapper.layout-1x1 {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.grid-wrapper.layout-2x2 {
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
}

.grid-wrapper.layout-3x3 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

/* Individual CCTV Slot */
.cctv-slot {
  background: #0d121c;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow-card);
}

.cctv-slot:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

/* Active Selected Slot */
.cctv-slot.active-slot {
  border-color: var(--border-active);
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.3), 0 0 16px rgba(6, 182, 212, 0.2);
}

/* Drag Over Highlight */
.cctv-slot.drag-over {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.08);
}

/* Slot Header */
.slot-header {
  height: 32px;
  background: rgba(17, 24, 39, 0.95);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  font-size: 0.78rem;
  z-index: 5;
  user-select: none;
}

.slot-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.slot-ch-badge {
  font-family: 'JetBrains Mono', monospace, Consolas;
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.12);
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.slot-cam-name {
  color: var(--text-primary);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.slot-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.slot-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.slot-action-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

.slot-action-btn.btn-remove:hover {
  color: #f87171;
  background: rgba(239, 68, 68, 0.15);
}

/* Slot Video Body */
.slot-body {
  flex: 1;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Video Player */
.slot-video {
  width: 100%;
  height: 100%;
  object-fit: fill;
  background: #000;
  display: block;
}

/* Slot Empty State */
.slot-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 20px;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.slot-empty-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: var(--transition-fast);
}

.slot-empty-state:hover .slot-empty-icon {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.08);
  transform: scale(1.08);
}

.slot-empty-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.slot-empty-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Slot Loading State */
.slot-loading-state {
  position: absolute;
  inset: 0;
  background: rgba(10, 13, 20, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 8;
  backdrop-filter: blur(4px);
}

.slot-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(6, 182, 212, 0.15);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: cctv-spin 0.8s linear infinite;
}

.slot-loading-text {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* Slot Error / Offline State */
.slot-error-state {
  position: absolute;
  inset: 0;
  background: rgba(17, 22, 34, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  text-align: center;
  z-index: 9;
}

.slot-error-icon {
  width: 40px;
  height: 40px;
  color: #f87171;
}

.slot-error-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #f87171;
}

.slot-error-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  max-width: 240px;
}

.slot-retry-btn {
  font-size: 0.75rem;
  padding: 4px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.slot-retry-btn:hover {
  background: var(--accent-cyan);
  color: var(--text-dark);
  border-color: var(--accent-cyan);
}

/* Stream Status Overlays */
.stream-live-pill {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  z-index: 6;
  border: 1px solid rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

.stream-live-dot {
  width: 6px;
  height: 6px;
  background: #ef4444;
  border-radius: 50%;
  animation: pulse-glow 1.5s infinite ease-in-out;
}

/* Watermark Overlay */
.stream-watermark {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.65);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.65rem;
  font-family: 'JetBrains Mono', monospace, Consolas;
  color: rgba(255, 255, 255, 0.7);
  pointer-events: none;
  z-index: 6;
}

/* Maximize Overlay View (Single Cell Maximize) */
.cctv-slot.maximized {
  position: fixed !important;
  inset: 12px !important;
  z-index: 100 !important;
  width: auto !important;
  height: auto !important;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.9);
}

/* ==========================================================================
   Bottom Status & Shortcut Bar
   ========================================================================== */
.bottom-bar {
  height: var(--bottombar-height);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 0.74rem;
  color: var(--text-muted);
  user-select: none;
  z-index: 20;
}

.bottom-left, .bottom-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.shortcut-hint {
  display: flex;
  align-items: center;
  gap: 5px;
}

.kbd-badge {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.68rem;
  font-family: monospace;
  color: var(--text-secondary);
}

/* ==========================================================================
   Modal Dialogs (Presets, Help, Settings)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 90%;
  max-width: 540px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform var(--transition-fast);
}

.modal-overlay.open .modal-card {
  transform: scale(1);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: 65vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-primary);
}

/* Preset Item */
.preset-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preset-item {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition-fast);
}

.preset-item:hover {
  border-color: var(--accent-cyan);
}

.preset-info h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.preset-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.preset-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--accent-cyan);
  color: var(--text-dark);
  font-weight: 600;
  border: none;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  transition: var(--transition-fast);
}

.btn-primary:hover {
  background: var(--accent-cyan-light);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.4);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82rem;
  transition: var(--transition-fast);
}

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

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 45px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-cyan);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.25s ease forwards;
  pointer-events: auto;
}

.toast.toast-success {
  border-left-color: var(--accent-green);
}

.toast.toast-error {
  border-left-color: var(--accent-red);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

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

/* Responsive adjustments */
@media (max-width: 900px) {
  .sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.7);
  }
}

/* ==========================================================================
   Light Theme (淺色風格系統)
   ========================================================================== */
body.theme-light {
  --bg-primary: #f0f4f8;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e2e8f0;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-glass: rgba(255, 255, 255, 0.9);
  
  --border-color: rgba(0, 0, 0, 0.08);
  --border-subtle: rgba(0, 0, 0, 0.04);
  --border-active: #0284c7;
  --border-active-glow: rgba(2, 132, 199, 0.25);

  --accent-cyan: #0284c7;
  --accent-cyan-light: #0369a1;
  --accent-cyan-glow: rgba(2, 132, 199, 0.12);
  --accent-green: #059669;
  --accent-green-glow: rgba(5, 150, 105, 0.15);
  --accent-red: #dc2626;
  --accent-amber: #d97706;
  --accent-blue: #2563eb;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-dark: #ffffff;

  --shadow-card: 0 2px 10px rgba(0, 0, 0, 0.06);
  --shadow-glow: 0 0 15px rgba(2, 132, 199, 0.2);
}

body.theme-light::before {
  background-image: 
    linear-gradient(to right, rgba(0, 0, 0, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.03) 1px, transparent 1px);
}

body.theme-light .header-bar {
  background: #ffffff;
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

body.theme-light .sidebar {
  background: #ffffff;
  border-right-color: rgba(0, 0, 0, 0.08);
}

body.theme-light .sidebar-header {
  background: #ffffff;
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

body.theme-light .sidebar-stats {
  background: #f8fafc;
  border-bottom-color: rgba(0, 0, 0, 0.05);
}

body.theme-light .search-input {
  background: #f1f5f9;
  border-color: rgba(0, 0, 0, 0.1);
  color: #0f172a;
}

body.theme-light .search-input:focus {
  background: #ffffff;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

body.theme-light .district-chip {
  background: #f1f5f9;
  border-color: rgba(0, 0, 0, 0.06);
  color: #475569;
}

body.theme-light .district-chip:hover {
  background: #e2e8f0;
  color: #0f172a;
}

body.theme-light .district-chip.active {
  background: rgba(2, 132, 199, 0.12);
  color: #0284c7;
  border-color: #0284c7;
}

body.theme-light .camera-card {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

body.theme-light .camera-card:hover {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.2);
}

body.theme-light .camera-card.in-use {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.4);
}

body.theme-light .badge-district {
  background: rgba(2, 132, 199, 0.1);
  color: #0284c7;
  border-color: rgba(2, 132, 199, 0.2);
}

body.theme-light .cctv-slot {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

body.theme-light .cctv-slot:hover {
  border-color: rgba(0, 0, 0, 0.25);
}

body.theme-light .cctv-slot.active-slot {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.25), 0 0 14px rgba(2, 132, 199, 0.15);
}

body.theme-light .slot-header {
  background: #f8fafc;
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

body.theme-light .slot-cam-name {
  color: #1e293b;
}

body.theme-light .slot-ch-badge {
  background: rgba(2, 132, 199, 0.1);
  color: #0284c7;
}

body.theme-light .slot-action-btn {
  color: #64748b;
}

body.theme-light .slot-action-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #0f172a;
}

body.theme-light .slot-empty-state {
  background: #f8fafc;
  color: #64748b;
}

body.theme-light .slot-empty-icon {
  background: #e2e8f0;
  border-color: #cbd5e1;
  color: #64748b;
}

body.theme-light .slot-empty-title {
  color: #334155;
}

body.theme-light .system-clock {
  background: rgba(2, 132, 199, 0.08);
  color: #0284c7;
  border-color: rgba(2, 132, 199, 0.2);
}

body.theme-light .btn-icon-label {
  background: #f1f5f9;
  border-color: rgba(0, 0, 0, 0.08);
  color: #475569;
}

body.theme-light .btn-icon-label:hover {
  background: #e2e8f0;
  color: #0f172a;
}

body.theme-light .layout-switcher {
  background: #f1f5f9;
  border-color: rgba(0, 0, 0, 0.08);
}

body.theme-light .layout-btn {
  color: #64748b;
}

body.theme-light .layout-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

body.theme-light .layout-btn.active {
  background: var(--accent-cyan);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(2, 132, 199, 0.3);
}

body.theme-light .bottom-bar {
  background: #ffffff;
  border-top-color: rgba(0, 0, 0, 0.08);
}

body.theme-light .kbd-badge {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #475569;
}

body.theme-light .modal-card {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

body.theme-light .modal-header {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

body.theme-light .modal-footer {
  background: #f8fafc;
  border-top-color: rgba(0, 0, 0, 0.08);
}

body.theme-light .preset-item {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.08);
}

body.theme-light .preset-item:hover {
  border-color: var(--accent-cyan);
  background: #ffffff;
}

body.theme-light .toast {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.1);
  color: #0f172a;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}

body.theme-light ::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
}

body.theme-light ::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   Cloud Sync UI Elements
   ========================================================================== */
.sync-section-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
}

.sync-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sync-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
}

.sync-status-dot.synced {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.sync-status-dot.syncing {
  background: #38bdf8;
  animation: pulse-glow 1s infinite;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}

#cloud-sync-btn.has-sync {
  color: var(--accent-cyan);
  border-color: rgba(6, 182, 212, 0.3);
}

