/* ==========================================================================
   Design System: Tactical Gaming Pro (Zero-Slop UI)
   ========================================================================== */

:root {
  --bg-app: #07080c;
  --bg-surface: #0d1016;
  --bg-element: #131722;
  --bg-hover: #1b212f;
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.16);
  --border-strong: rgba(255, 255, 255, 0.28);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  
  --accent-red: #e11d48;
  --accent-red-glow: rgba(225, 29, 72, 0.35);
  --accent-core: #2563eb;
  
  --status-live: #10b981;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.3;
}

.app-container {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: var(--bg-app);
}

/* ==========================================================================
   ZONE 1: Slim Bezel OLED Monitor Viewport
   ========================================================================== */

.screen-viewport {
  width: 100%;
  background-color: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  padding: 1px 2px 0 2px;
}

.monitor-outer-frame {
  width: 100%;
  position: relative;
  border-radius: 5px 5px 3px 3px;
  background: linear-gradient(180deg, #222834 0%, #0f121a 100%);
  padding: 1.5px 1.5px 2px 1.5px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.7);
}

.stream-container {
  width: 100%;
  aspect-ratio: 16 / 9;
  background-color: #000000;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
}

#screenCanvas {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.monitor-glare-reflection {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 30%, transparent 45%);
  pointer-events: none;
}

.monitor-led {
  position: absolute;
  bottom: 1px;
  right: 6px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background-color: var(--status-live);
  box-shadow: 0 0 4px var(--status-live);
}

.loader-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(7, 8, 12, 0.92);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 20;
  transition: opacity 0.2s ease;
}

.loader-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.pulse-indicator {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(225, 29, 72, 0.2);
  border-top-color: var(--accent-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loader-text {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-secondary);
}

.zoom-indicator-pill {
  position: absolute;
  top: 8px;
  right: 10px;
  background: rgba(13, 16, 22, 0.92);
  border: 1px solid var(--border-medium);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 700;
  color: #38bdf8;
  z-index: 30;
  backdrop-filter: blur(4px);
}

.zoom-indicator-pill.hidden {
  display: none;
}

/* ==========================================================================
   Stream Toolbar & Network Selector
   ========================================================================== */

.stream-toolbar {
  height: 27px;
  min-height: 27px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
  gap: 4px;
  flex-shrink: 0;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-element);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 1px 5px;
  max-width: 120px;
}

.status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: #ef4444;
  flex-shrink: 0;
}

.status-dot.connected {
  background-color: var(--status-live);
  box-shadow: 0 0 4px var(--status-live);
}

.client-picker {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  width: 100%;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.metrics-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
}

.mono-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  color: var(--text-secondary);
  background-color: var(--bg-element);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 1px 4px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.mono-badge.quality-btn {
  background-color: #162030;
  border-color: rgba(56, 189, 248, 0.35);
  color: #38bdf8;
  cursor: pointer;
  transition: transform 0.08s, background-color 0.1s;
}

.mono-badge.quality-btn:active {
  background-color: #1e2c44;
  transform: scale(0.95);
}

.toolbar-tools {
  display: flex;
  align-items: center;
  gap: 3px;
}

.tool-btn {
  height: 21px;
  background-color: var(--bg-element);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  cursor: pointer;
  transition: transform 0.08s, background-color 0.1s;
}

.tool-btn.zoom-btn {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  color: #38bdf8;
  padding: 0 4px;
}

.tool-btn.action-menu-btn {
  color: #fda4af;
  border-color: rgba(225, 29, 72, 0.3);
  background-color: rgba(225, 29, 72, 0.12);
}

.tool-btn:active {
  background-color: var(--border-medium);
  color: var(--text-primary);
  transform: scale(0.94);
}

/* ==========================================================================
   ZONE 2: Maximized Red-Stitched Gaming Deskmat + 3D Rolling Scroll Wheel
   ========================================================================== */

.touchpad-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-app);
  padding: 3px 4px;
  gap: 3px;
  position: relative;
}

.touchpad-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  gap: 4px;
  position: relative;
}

/* Red-Stitched Gaming Deskmat (Full-Height Maximize) */
.touchpad-surface.gaming-deskmat {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  position: relative;
  background-color: #0b0c10;
  background-image: url('deskmat_red.webp?v=20260902_50');
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 10px;
  box-shadow: 
    inset 0 0 10px rgba(0, 0, 0, 0.8),
    0 3px 10px rgba(0, 0, 0, 0.5);
  touch-action: none;
  overflow: hidden;
  transition: box-shadow 0.15s ease-out;
}

.touchpad-surface.gaming-deskmat.dragging {
  box-shadow: 
    inset 0 0 16px rgba(225, 29, 72, 0.25),
    0 0 10px rgba(225, 29, 72, 0.35);
}

/* Dedicated 3D Rolling Scroll Wheel Strip */
.scroll-wheel-strip {
  width: 42px;
  min-width: 42px;
  background: linear-gradient(180deg, #141720 0%, #0a0c12 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 2px;
  touch-action: none;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.08), 0 2px 6px rgba(0,0,0,0.5);
}

.scroll-btn {
  width: 36px;
  height: 22px;
  background-color: var(--bg-element);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.08s, background-color 0.1s;
}

.scroll-btn:active {
  background-color: var(--accent-red);
  color: #ffffff;
  border-color: var(--accent-red);
  transform: scale(0.92);
}

.wheel-chassis {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  touch-action: none;
  overflow: hidden;
  padding: 4px 0;
}

/* Continuously Rolling 3D Textured Cylinder */
#wheelCanvas {
  width: 32px;
  height: 100%;
  max-height: 110px;
  border-radius: 5px;
  display: block;
  touch-action: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.75);
}

/* Tactile Gaming Mouse Buttons */
.mouse-actions {
  height: 32px;
  min-height: 32px;
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

.mouse-key {
  flex: 1;
  height: 100%;
  background: linear-gradient(180deg, #161a24 0%, #0d1016 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5), inset 0 1px 1px rgba(255, 255, 255, 0.1);
  transition: transform 0.06s, background-color 0.1s;
}

.mouse-key .btn-stitch {
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 1px;
  background-color: rgba(225, 29, 72, 0.5);
  border-radius: 1px;
}

.mouse-key.middle-key {
  flex: 0.72;
  color: var(--text-secondary);
  font-size: 8px;
}

.mouse-key:active {
  background: var(--accent-red);
  color: #ffffff;
  border-color: var(--accent-red);
  transform: scale(0.97);
  box-shadow: 0 0 8px var(--accent-red-glow);
}

/* ==========================================================================
   ZONE 3: Virtual Keyboard & Controls
   ========================================================================== */

.keyboard-panel {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 3px 5px 12px 5px;
  gap: 3px;
}

.input-row {
  display: flex;
  gap: 3px;
  height: 25px;
  min-height: 25px;
}

.input-row input {
  flex: 1;
  background-color: var(--bg-element);
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  color: var(--text-primary);
  padding: 0 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.input-row input:focus {
  border-color: var(--accent-red);
}

.submit-btn {
  width: 28px;
  background: var(--accent-red);
  border: none;
  border-radius: 4px;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.08s, background-color 0.1s;
}

.submit-btn:active {
  background-color: #be123c;
  transform: scale(0.94);
}

.control-keys-row {
  display: flex;
  gap: 2px;
  height: 24px;
  min-height: 24px;
}

.ctrl-key {
  flex: 1;
  background: var(--bg-element);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: transform 0.08s, background-color 0.1s;
}

.ctrl-key .led {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background-color: var(--text-tertiary);
}

.ctrl-key.mod-key.active {
  background-color: var(--bg-hover);
  border-color: var(--accent-red);
  color: #fda4af;
}

.ctrl-key.mod-key.active .led {
  background-color: var(--accent-red);
  box-shadow: 0 0 4px var(--accent-red);
}

.ctrl-key.primary-key {
  background: linear-gradient(180deg, #e11d48 0%, #be123c 100%);
  color: #ffffff;
  border-color: var(--accent-red);
}

.ctrl-key:active {
  transform: scale(0.95);
}

/* ==========================================================================
   Slide-Up Actions Drawer (Bottom Sheet)
   ========================================================================== */

.actions-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(4, 5, 8, 0.75);
  backdrop-filter: blur(6px);
  z-index: 90;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transition: opacity 0.2s ease;
}

.actions-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.actions-drawer {
  width: 100%;
  max-height: 80vh;
  background: #0f131a;
  border-top: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.85);
  padding: 8px 12px 24px 12px;
  transform: translateY(0);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.actions-backdrop.hidden .actions-drawer {
  transform: translateY(100%);
}

.drawer-handle-bar {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 4px 0 8px 0;
}

.drawer-pill {
  width: 36px;
  height: 4px;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 10px 4px;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-title {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-primary);
}

.drawer-close-btn {
  background: var(--bg-element);
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
}

.actions-grid-scroll {
  overflow-y: auto;
  max-height: calc(80vh - 70px);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.actions-group-title {
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
  padding-left: 2px;
}

.actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.action-card {
  background: var(--bg-element);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.1s, transform 0.08s, border-color 0.1s;
}

.action-card:active {
  background-color: var(--bg-hover);
  border-color: rgba(225, 29, 72, 0.4);
  transform: scale(0.97);
}

/* Direct Login Modal */
.auth-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(4, 5, 8, 0.92);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.auth-backdrop.hidden {
  display: none;
}

.auth-dialog {
  width: 100%;
  max-width: 300px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-title {
  font-size: 14px;
  font-weight: 700;
}

.auth-desc {
  font-size: 10.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.auth-dialog input {
  width: 100%;
  height: 32px;
  background-color: var(--bg-element);
  border: 1px solid var(--border-medium);
  border-radius: 5px;
  color: var(--text-primary);
  padding: 0 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  outline: none;
}

.auth-btn {
  height: 32px;
  background: var(--accent-red);
  border: none;
  border-radius: 5px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s;
}

.auth-btn:active {
  transform: scale(0.96);
}
