/* deskctl PWA — Mobile-first remote desktop client */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface2: #252540;
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --text: #e8e8f0;
  --text-muted: #9999aa;
  --danger: #e53935;
  --success: #43a047;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.screen { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; }
.screen.active { display: flex; }

/* Connection Screen */
#connect-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 100%);
}
.logo { text-align: center; margin-bottom: 32px; }
.logo h1 { font-size: 28px; font-weight: 700; margin-top: 12px; letter-spacing: -0.5px; }
.logo p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.connect-form { width: 100%; max-width: 360px; }
.input-group { margin-bottom: 16px; }
.input-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.input-group input, .input-group select {
  width: 100%; padding: 12px 16px;
  background: var(--surface2);
  border: 1px solid #333350;
  border-radius: 12px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.input-group input:focus, .input-group select:focus { border-color: var(--primary); }
.btn-primary, .btn-secondary {
  width: 100%; padding: 14px;
  border: none; border-radius: 12px;
  font-size: 16px; font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  margin-bottom: 8px;
}
.btn-primary:active, .btn-secondary:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--surface2); color: var(--text); }
#connection-status { margin-top: 16px; font-size: 13px; color: var(--text-muted); text-align: center; }

/* Remote Desktop Screen */
#remote-screen {
  flex-direction: column;
  background: #000;
}
.toolbar {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  padding-top: calc(8px + var(--safe-top));
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 100;
  gap: 8px;
}
.toolbar-spacer { flex: 1; }
.toolbar-btn {
  width: 40px; height: 40px;
  border: none; border-radius: 10px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.toolbar-btn:active { background: rgba(255,255,255,0.2); }
#connection-info { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--success); color: #fff; }
#device-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#remote-canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#remote-canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
#no-video {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.touch-overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  /* Touch events handled by JS */
}

.bottom-bar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  padding-bottom: calc(10px + var(--safe-bottom));
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  justify-content: center;
}
.bar-btn {
  padding: 10px 16px;
  border: none; border-radius: 8px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* Virtual Keyboard */
.virtual-kb {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #1c1c2e;
  padding: 8px 4px;
  padding-bottom: calc(8px + var(--safe-bottom));
  z-index: 200;
  border-top: 1px solid #333;
}
.virtual-kb.hidden { display: none; }
.kb-row { display: flex; gap: 4px; margin-bottom: 4px; justify-content: center; }
.kb-key {
  min-width: 28px; height: 40px;
  border: none; border-radius: 6px;
  background: #2a2a3e;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.kb-key:active { background: var(--primary); }
.kb-key.wide { min-width: 34px; }
.kb-key.shift { min-width: 42px; font-size: 11px; }
.kb-key.ctrl { min-width: 38px; font-size: 10px; }
.kb-key.space { flex: 1; max-width: 200px; }

/* Overlays */
.overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
  padding: 24px;
}
.overlay.hidden { display: none; }
.overlay-content {
  background: var(--surface);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 400px;
}
.overlay-content h3 { margin-bottom: 16px; font-size: 18px; }
.overlay-content textarea {
  width: 100%; height: 100px;
  background: var(--surface2);
  border: 1px solid #333;
  border-radius: 8px;
  color: var(--text);
  padding: 12px;
  font-size: 14px;
  resize: vertical;
  margin-bottom: 12px;
}
.overlay-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.quality-options { display: flex; gap: 8px; margin-bottom: 16px; }
.quality-btn {
  flex: 1; padding: 16px;
  border: 2px solid #333;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}
.quality-btn.active { border-color: var(--primary); background: rgba(26,115,232,0.15); }
.quality-btn small { font-size: 11px; color: var(--text-muted); }

/* Mobile tweaks */
@media (max-width: 480px) {
  .logo h1 { font-size: 24px; }
  .kb-key { min-width: 24px; height: 36px; font-size: 11px; }
}
