/* ─────────────────────────────────────────────────────────────────────────
   Remote Desktop — style.css
   Dark, premium glassmorphism UI
   ───────────────────────────────────────────────────────────────────────── */

/* ── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  --bg-base:        #0a0c10;
  --bg-surface:     #12151c;
  --bg-elevated:    #1a1f2b;
  --bg-glass:       rgba(26, 31, 43, 0.7);

  --accent:         #6c63ff;
  --accent-light:   #9b94ff;
  --accent-glow:    rgba(108, 99, 255, 0.35);

  --green:          #22c55e;
  --green-glow:     rgba(34, 197, 94, 0.3);
  --yellow:         #f59e0b;
  --red:            #ef4444;

  --text-primary:   #e8eaf0;
  --text-secondary: #8b92a8;
  --text-muted:     #4b5268;

  --border:         rgba(255,255,255,0.07);
  --border-accent:  rgba(108,99,255,0.4);

  --radius-sm:      6px;
  --radius-md:      12px;
  --radius-lg:      18px;

  --font-ui:        'Inter', system-ui, sans-serif;
  --font-mono:      'JetBrains Mono', monospace;

  --header-h:       52px;
  --anim-fast:      150ms;
  --anim-med:       280ms;
  
  /* Will be updated by JS to match visible area above keyboard */
  --vv-height: 100dvh; 
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%;
  height: var(--vv-height);
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  touch-action: none;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
#app-header {
  position: fixed;
  inset-block-start: 0; inset-inline: 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}
.header-right { justify-content: flex-end; }

/* ── Mobile header overrides ─────────────────────────────────────────────── */
@media (max-width: 600px) {
  #app-header {
    padding: 0 10px;
    height: 44px;
  }

  /* Kill fixed min-width so items don't overflow */
  .header-left, .header-right {
    min-width: 0;
    gap: 6px;
  }

  /* Hide logo text, keep only the icon */
  .logo span { display: none; }

  /* Hide FPS/frame counters — too noisy on small screens */
  .stats { display: none; }

  /* Shrink status pill text */
  .status-pill {
    padding: 4px 10px;
    font-size: 11px;
  }

  /* Smaller icon button */
  .icon-btn {
    width: 30px;
    height: 30px;
  }

  /* Update CSS variable so viewer area starts at the right place */
  :root { --header-h: 44px; }
}


/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.2px;
  color: var(--text-primary);
}
.logo svg {
  width: 22px; height: 22px;
  color: var(--accent-light);
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

/* Status pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 14px;
  border-radius: 100px;
  font-size: 12.5px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all var(--anim-med) ease;
}
.status-pill.connecting {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--yellow);
}
.status-pill.live {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.3);
  color: var(--green);
}
.status-pill.disconnected {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--red);
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.status-pill.live .status-dot {
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.75); }
}

/* Stats */
.stats {
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}
.stat-item svg {
  width: 13px; height: 13px;
  opacity: 0.7;
}

/* Icon button */
.icon-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--anim-fast) ease;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover {
  background: var(--bg-glass);
  border-color: var(--border-accent);
  color: var(--accent-light);
  box-shadow: 0 0 12px var(--accent-glow);
}
.icon-btn.active {
  background: rgba(108, 99, 255, 0.15);
  border-color: var(--border-accent);
  color: var(--accent-light);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* ── Viewer ──────────────────────────────────────────────────────────────── */
#viewer-wrap {
  position: fixed;
  inset: var(--header-h) 0 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 60%, #0d1120 0%, var(--bg-base) 100%);
  overflow: hidden;
  touch-action: none;
}

#main-canvas {
  max-width: 100vw;
  max-height: calc(100vh - var(--header-h));       /* fallback */
  max-height: calc(100dvh - var(--header-h));      /* dynamic: adjusts on rotation & browser chrome */
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  cursor: default;
  outline: none;
  border-radius: 4px;
  transform-origin: center center;
  will-change: transform;
  touch-action: none;
  box-shadow:
    0 0 0 1px var(--border),
    0 8px 60px rgba(0,0,0,0.7);
  transition: box-shadow var(--anim-med) ease;
}
#main-canvas:focus {
  box-shadow:
    0 0 0 1px var(--border),
    0 8px 60px rgba(0,0,0,0.7);
}

/* ── Overlay ─────────────────────────────────────────────────────────────── */
#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  z-index: 50;
  transition: opacity var(--anim-med) ease;
}
#overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  padding: 48px 56px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 80px rgba(0,0,0,0.5);
  max-width: 400px;
}
.overlay-card h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}
.overlay-card p {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Spinner */
.spinner {
  width: 44px; height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Floating Toolbar ────────────────────────────────────────────────────── */
#toolbar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 100px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  transition: opacity var(--anim-med) ease, transform var(--anim-med) ease;
}
#toolbar.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(12px);
  pointer-events: none;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 100px;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-family: var(--font-ui);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--anim-fast) ease;
  white-space: nowrap;
}
.tool-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.tool-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-primary);
}
.tool-btn.active {
  background: rgba(108,99,255,0.15);
  border-color: var(--border-accent);
  color: var(--accent-light);
}

.tool-divider {
  width: 1px; height: 22px;
  background: var(--border);
  margin: 0 4px;
}

/* ── Lock Banner ─────────────────────────────────────────────────────────── */
#lock-banner {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 22px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-accent);
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-light);
  white-space: nowrap;
  pointer-events: none;
  z-index: 60;
  opacity: 0;
  transition: opacity var(--anim-med) ease;
  box-shadow: 0 4px 24px rgba(108,99,255,0.25);
}
#lock-banner.visible {
  opacity: 1;
}

/* ── Fullscreen & Landscape ──────────────────────────────────────────────── */
:fullscreen #app-header { display: none; }
:fullscreen #mobile-bar { display: flex; } /* keep floating btn visible */
:fullscreen #viewer-wrap { inset: 0 !important; }
:fullscreen #main-canvas {
  border-radius: 0 !important;
  box-shadow: none !important;
  max-height: 100dvh;
}

/* ── Landscape on touch devices — use full height ───────────────────────── */
@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
  #viewer-wrap { bottom: 0; }
  #main-canvas {
    max-height: calc(100vh - var(--header-h));
    max-height: calc(100dvh - var(--header-h));
  }
}

/* ── Mobile floating input button ────────────────────────────────────────── */
#mobile-bar {
  display: none;              /* shown by JS if touch device */
  position: fixed;
  inset-block-end: 0;
  inset-inline: 0;
  pointer-events: none;       /* let touches pass through */
  justify-content: flex-end;
  align-items: flex-end;
  padding: 0 16px 16px 0;
  z-index: 100;
}

/* Hide the floating button while the input panel is actively open */
body.input-active #mobile-bar {
  display: none !important;
}

#mobile-bar #kbd-btn {
  display: flex;
  pointer-events: auto;       /* make button clickable */
  background: var(--bg-glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 50%;
  width: 56px;
  height: 56px;
  padding: 0;
  justify-content: center;
  align-items: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  color: var(--text-base);
  transition: background var(--anim-fast) ease, transform var(--anim-fast) ease;
}

#mobile-bar #kbd-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.1);
}

#mobile-bar #kbd-btn svg {
  width: 24px;
  height: 24px;
}

/* ── Visible Text Input Panel ────────────────────────────────────────────── */
#text-input-panel {
  display: none;
  position: fixed;
  bottom: 24px;       /* Back to bottom */
  left: 24px;
  right: 24px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  gap: 6px;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  flex-direction: row;
  align-items: center;
  box-sizing: border-box;
}

#text-input-panel.active {
  display: flex;
}

#visible-input {
  flex: 1;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  color: var(--text-base);
  border-radius: 4px;
  padding: 8px 10px;
  font-family: var(--font-ui);
  font-size: 16px; /* 16px prevents iOS from zooming in */
  outline: none;
  min-width: 0;
  box-sizing: border-box;
}

#text-input-panel button {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--text-base);
  border-radius: 4px;
  padding: 8px 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  box-sizing: border-box;
}

#text-input-panel button:active {
  background: rgba(255,255,255,0.15);
}

#send-btn {
  color: var(--accent-light) !important;
  border-color: var(--border-accent) !important;
  background: rgba(108, 99, 255, 0.1) !important;
}

@media (max-width: 400px) {
  #text-input-panel {
    bottom: 12px; left: 12px; right: 12px;
  }
}

/* On touch devices (portrait), shrink viewer area for mobile bar */
@media (hover: none) and (pointer: coarse) and (orientation: portrait) {
  #viewer-wrap {
    bottom: 68px;
  }
  #main-canvas {
    max-height: calc(100vh - var(--header-h) - 68px);
    max-height: calc(100dvh - var(--header-h) - 68px);
  }
  /* Slightly smaller header on phones */
  @media (max-width: 480px) {
    #app-header {
      padding: 0 12px;
    }
    .logo span { display: none; }
    .stats { gap: 8px; }
  }
}



