:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(31, 41, 55, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(59, 130, 246, 0.4);
  
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Outfit', sans-serif;
  --font-mono: 'Space Grotesk', monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --shadow-glow: 0 0 25px rgba(59, 130, 246, 0.15);
  --glass-backdrop: blur(12px);
}

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

body {
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.12) 0px, transparent 50%);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: var(--glass-backdrop);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent-rose), var(--accent-purple));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: #fff;
  box-shadow: 0 0 20px rgba(244, 63, 94, 0.3);
}

.logo-text h2 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.35rem;
  line-height: 1.1;
}

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

.logo-text .subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.nav-metrics {
  display: flex;
  gap: 1rem;
}

.metric-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  padding: 8px 16px;
  border-radius: 30px;
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

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

.dot.total {
  background: var(--accent-blue);
}

.nav-actions {
  display: flex;
  gap: 12px;
}

/* Layout */
.app-container {
  display: grid;
  grid-template-columns: 320px 1fr;
  flex: 1;
  min-height: calc(100vh - 75px);
}

/* Sidebar */
.sidebar {
  background: rgba(17, 24, 39, 0.5);
  border-right: 1px solid var(--border-color);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.sidebar-section h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-list li {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s ease;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.filter-list li:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.filter-list li.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.2), transparent);
  border-left: 3px solid var(--accent-blue);
  color: var(--text-main);
  font-weight: 600;
}

.badge {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
}

.badge-success {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
}

.badge-muted {
  background: rgba(156, 163, 175, 0.2);
  color: var(--text-muted);
}

.search-box {
  display: flex;
  gap: 6px;
}

.search-box input {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.85rem;
}

.search-box button {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.api-snippet-box {
  background: rgba(0, 0, 0, 0.3);
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
}

.api-snippet-box label {
  display: block;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.code-copy-row {
  display: flex;
  gap: 6px;
}

.code-copy-row input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

/* Main Content */
.main-content {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.search-field {
  flex: 1;
  max-width: 500px;
  position: relative;
}

.search-field i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-field input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 12px 14px 12px 42px;
  border-radius: 30px;
  color: var(--text-main);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.search-field input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.tool-tags {
  display: flex;
  gap: 8px;
}

.tag {
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
}

.tag-onenet { color: var(--accent-cyan); border-color: rgba(6, 182, 212, 0.3); }
.tag-anydesk { color: #f43f5e; border-color: rgba(244, 63, 94, 0.3); }

.grid-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.grid-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.live-indicator {
  font-size: 0.8rem;
  color: var(--accent-emerald);
  display: flex;
  align-items: center;
  gap: 6px;
}

.pulse {
  width: 8px;
  height: 8px;
  background: var(--accent-emerald);
  border-radius: 50%;
  animation: pulse-anim 1.5s infinite;
}

@keyframes pulse-anim {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Device Cards Grid */
.devices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.5rem;
}

.device-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-backdrop);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: all 0.3s ease;
  position: relative;
}

.device-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.device-info h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.device-info .hostname {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-cyan);
}

.status-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

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

.status-badge.offline {
  background: rgba(107, 114, 128, 0.15);
  color: var(--text-muted);
  border: 1px solid rgba(107, 114, 128, 0.3);
}

.ip-row {
  display: flex;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.ip-box {
  display: flex;
  flex-direction: column;
}

.ip-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
}

.ip-val {
  font-family: var(--font-mono);
  color: var(--text-main);
  font-weight: 600;
}

.remote-apps-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.app-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.app-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
}

.app-id-code {
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--accent-amber);
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: #fff;
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent-rose), var(--accent-purple));
  color: #fff;
  box-shadow: 0 0 15px rgba(244, 63, 94, 0.3);
}

.btn-danger {
  background: var(--accent-rose);
  color: #fff;
}

.btn-glass {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

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

/* Logs Section */
.logs-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.logs-container {
  height: 180px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-entry {
  display: flex;
  gap: 12px;
  color: var(--text-muted);
}

.log-entry.info .log-level { color: var(--accent-blue); }
.log-entry.warning .log-level { color: var(--accent-amber); }
.log-entry.error .log-level { color: var(--accent-rose); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-content {
  width: 100%;
  max-width: 480px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.form-group input {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.9rem;
}

/* FULLSCREEN REMOTE DESKTOP VIEWER WORKSPACE */
.remote-viewer-overlay {
  position: fixed;
  inset: 0;
  background: #020617;
  z-index: 9999;
  display: flex;
  flex-direction: column;
}

.viewer-toolbar {
  height: 50px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
}

.viewer-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
}

.id-badge {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--accent-cyan);
}

.fps-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.viewer-controls {
  display: flex;
  gap: 8px;
}

.canvas-viewport {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  position: relative;
  overflow: hidden;
}

#remote-screen-canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: crosshair;
}

.viewer-loader {
  position: absolute;
  inset: 0;
  background: rgba(11, 15, 25, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s infinite linear;
  margin-bottom: 1rem;
}

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

.hidden {
  display: none !important;
}

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10000;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--accent-blue);
  color: var(--text-main);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}
