:root {
  --bg-primary: #0b0f19;
  --bg-card: rgba(18, 26, 43, 0.75);
  --bg-card-hover: rgba(28, 39, 65, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(0, 242, 254, 0.3);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-cyan: #00f2fe;
  --accent-blue: #4facfe;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

.mono {
  font-family: var(--font-mono);
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ========================================= */
/* Top Navigation Bar */
/* ========================================= */
.top-nav {
  height: 64px;
  background: rgba(11, 15, 25, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
}

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

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0b0f19;
  font-size: 1.25rem;
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.4);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.accent-text {
  color: var(--accent-cyan);
}

.brand-subtitle {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 1.5px;
}

.device-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.device-selector-wrapper label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.styled-select {
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
  padding: 4px 8px;
}

.styled-select option {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.icon-btn:hover {
  color: var(--accent-cyan);
  transform: rotate(90deg);
}

.nav-status {
  display: flex;
  align-items: center;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-amber);
  box-shadow: 0 0 8px var(--accent-amber);
  animation: pulse 2s infinite;
}

.pulse-dot.online {
  background-color: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* ========================================= */
/* Main Workspace Layout */
/* ========================================= */
.main-content {
  display: flex;
  flex: 1;
  height: calc(100vh - 64px);
  position: relative;
}

/* Left Sidebar */
.control-sidebar {
  width: 380px;
  height: 100%;
  background: rgba(11, 15, 25, 0.9);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border-color);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  z-index: 500;
}

.control-sidebar::-webkit-scrollbar {
  width: 4px;
}
.control-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* Glass Card */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 14px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-header h3 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.status-badge.online {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.status-badge.offline {
  background: rgba(239, 68, 68, 0.2);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.live-pill {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--accent-cyan);
  background: rgba(0, 242, 254, 0.1);
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid rgba(0, 242, 254, 0.3);
  display: flex;
  align-items: center;
  gap: 4px;
}
.live-pill i {
  font-size: 0.45rem;
  animation: pulse 1.5s infinite;
}

/* Device Meta Grid */
.device-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.meta-item {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.02);
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.meta-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.meta-val {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.battery-val {
  color: var(--accent-green);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Telemetry Grid */
.telemetry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.telemetry-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 8px 10px;
  border-radius: 8px;
}

.t-label {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
}

.t-val {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-cyan);
}

/* Command Buttons */
.command-buttons-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cmd-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
  position: relative;
  overflow: hidden;
}

.cmd-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.cmd-btn:active {
  transform: translateY(0);
}

.cmd-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.cmd-text {
  display: flex;
  flex-direction: column;
}

.cmd-title {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.cmd-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Button Variants */
.btn-danger .cmd-icon {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}
.btn-danger:hover {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}

.btn-warning .cmd-icon {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
}
.btn-warning:hover {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.08);
}

.btn-primary .cmd-icon {
  background: rgba(79, 172, 254, 0.15);
  color: var(--accent-blue);
}
.btn-primary:hover {
  border-color: rgba(79, 172, 254, 0.4);
  background: rgba(79, 172, 254, 0.08);
}

.btn-toggle .cmd-icon {
  background: rgba(0, 242, 254, 0.15);
  color: var(--accent-cyan);
}
.btn-toggle:hover {
  border-color: rgba(0, 242, 254, 0.4);
}
.btn-toggle.active {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--accent-red);
}
.btn-toggle.active .cmd-icon {
  background: var(--accent-red);
  color: white;
}
.btn-toggle.active .cmd-title {
  color: var(--accent-red);
}

/* Photos Stream */
.photos-stream {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  min-height: 80px;
}
.photos-stream::-webkit-scrollbar {
  height: 4px;
}
.photos-stream::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.photo-thumb {
  width: 70px;
  height: 70px;
  border-radius: 8px;
  object-fit: cover;
  cursor: pointer;
  border: 1px solid var(--border-color);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.photo-thumb:hover {
  transform: scale(1.05);
  border-color: var(--accent-cyan);
}

.mini-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}
.mini-btn:hover {
  color: var(--accent-cyan);
}

.empty-state {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  width: 100%;
  padding: 16px 0;
}

/* ========================================= */
/* Map Display Area */
/* ========================================= */
.map-wrapper {
  flex: 1;
  height: 100%;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
  background: #111827;
}

.dark-tiles {
  filter: brightness(0.6) invert(1) contrast(3) hue-rotate(200deg) saturate(0.3) brightness(0.7);
}

.map-floating-overlay {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.map-fab-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transition: all 0.2s;
}

.map-fab-btn:hover {
  background: var(--accent-cyan);
  color: #0b0f19;
  transform: scale(1.08);
}

.map-fab-btn.active {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.floating-hud {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  padding: 8px 18px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  pointer-events: none;
}
.floating-hud span {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ========================================= */
/* Custom Leaflet Map Styling */
/* ========================================= */
.custom-device-marker {
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.marker-container {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-core {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00f2fe, #4facfe);
  border: 2px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0b0f19;
  font-size: 0.9rem;
  box-shadow: 0 0 16px rgba(0, 242, 254, 0.9);
  z-index: 10;
}

.marker-pulse-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 242, 254, 0.4);
  border: 1.5px solid #00f2fe;
  animation: radar-expand 2s infinite cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 1;
}

@keyframes radar-expand {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.modal-overlay.hidden {
  display: none;
}

.modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.modal-content img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 10px;
}

.modal-close-btn {
  position: absolute;
  top: 10px;
  right: 14px;
  background: transparent;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
}

.modal-meta {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
