:root {
  --bg-dark: #12141a;
  --bg-card: #1a1d26;
  --bg-sidebar: #161820;
  --bg-input: #232733;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --accent: #38bdf8;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #2e3446;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body.dark-theme {
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background-color: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
}

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

.brand-icon {
  font-size: 1.5rem;
  color: var(--accent);
}

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

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

.badge-free {
  font-size: 0.75rem;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

/* App Container */
.app-container {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

.view-section {
  width: 100%;
  height: 100%;
  display: flex;
}

/* Auth View */
#authView {
  justify-content: center;
  align-items: center;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 420px;
  padding: 32px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab-btn.active {
  color: var(--text-main);
  border-bottom-color: var(--primary);
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.auth-form h2 {
  font-size: 1.5rem;
  margin-bottom: 6px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 16px;
}

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

input, select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-main);
  outline: none;
  font-size: 0.95rem;
}

input:focus, select:focus {
  border-color: var(--accent);
}

/* Buttons */
.btn {
  padding: 10px 16px;
  border-radius: 6px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--border-color); color: var(--text-main); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-dark { background: #0f172a; color: white; border: 1px solid var(--border-color); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-lg { padding: 14px 24px; font-size: 1.1rem; }

/* Dashboard */
.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  padding: 20px 0;
}

.nav-menu {
  display: flex;
  flex-direction: column;
}

.nav-item {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 14px 24px;
  text-align: left;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-item.active, .nav-item:hover {
  background: rgba(37, 99, 235, 0.1);
  color: var(--accent);
  border-left: 3px solid var(--accent);
}

.dashboard-content {
  flex: 1;
  padding: 28px;
  overflow-y: auto;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

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

/* Devices Grid */
.devices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.device-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

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

.device-icon {
  font-size: 1.8rem;
  color: var(--accent);
}

.status-badge {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: bold;
}

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

.status-badge.offline {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-muted);
}

.host-id-display {
  font-family: monospace;
  font-size: 1.1rem;
  background: var(--bg-input);
  padding: 6px 10px;
  border-radius: 4px;
  text-align: center;
  margin: 12px 0;
  letter-spacing: 1px;
}

.device-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

/* Remote Session View */
#remoteSessionView {
  flex-direction: column;
  background: #000;
}

.session-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: rgba(26, 29, 38, 0.9);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
}

.session-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.status-indicator.online { background: var(--success); }

.fps-indicator {
  font-size: 0.8rem;
  color: var(--accent);
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

.stream-container {
  flex: 1;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.approval-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(18, 20, 26, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 200;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.active { display: flex; }

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  width: 440px;
  padding: 24px;
}

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

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

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

.toast {
  padding: 12px 18px;
  border-radius: 6px;
  color: white;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  font-size: 0.9rem;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }
