/* Modern Styling Design Tokens */
:root {
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Color Palette (HSL Tailored) */
  --bg-color: hsl(222, 47%, 6%);
  --text-primary: hsl(210, 40%, 98%);
  --text-secondary: hsl(215, 20%, 65%);
  --text-muted: hsl(215, 15%, 45%);
  
  --primary: hsl(186, 100%, 45%);       /* Cyber Cyan */
  --primary-hover: hsl(186, 100%, 55%);
  --primary-glow: hsla(186, 100%, 45%, 0.3);
  
  --accent: hsl(280, 100%, 60%);        /* Neon Violet */
  --accent-hover: hsl(280, 100%, 70%);
  
  --danger: hsl(350, 100%, 60%);        /* Crimson Alert */
  --danger-hover: hsl(350, 100%, 70%);
  
  --glass-bg: rgba(10, 18, 36, 0.65);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-shadow: rgba(0, 0, 0, 0.5);
  
  --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --transition-fast: all 0.15s ease-out;
}

/* Global Reset & Base Setup */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Background Ambient Orbs */
.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(140px);
  z-index: -1;
  pointer-events: none;
  opacity: 0.4;
}
.orb-1 {
  width: 45vw;
  height: 45vw;
  background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
  top: -10%;
  left: -10%;
  animation: floatOrb1 25s infinite alternate ease-in-out;
}
.orb-2 {
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  bottom: -15%;
  right: -10%;
  animation: floatOrb2 30s infinite alternate ease-in-out;
}
.orb-3 {
  width: 30vw;
  height: 30vw;
  background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
  top: 40%;
  left: 60%;
  opacity: 0.2;
}

@keyframes floatOrb1 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(5%, 8%) scale(1.1); }
}
@keyframes floatOrb2 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-6%, -10%) scale(1.05); }
}

/* App Container */
#app-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

/* Glassmorphism Card Style */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 20px 50px var(--glass-shadow);
  border-radius: 20px;
}

.glass-bar {
  background: rgba(10, 18, 36, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
}

/* 1. Connection Panel (Login Card) */
#connection-panel {
  width: 460px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  gap: 30px;
  animation: fadeInDown 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-30px); }
  to { opacity: 1; transform: translateY(0); }
}

.brand-header {
  text-align: center;
}

.brand-header .logo-icon {
  font-size: 3rem;
  margin-bottom: 10px;
  display: inline-block;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 10px var(--primary-glow));
}

.brand-header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-header h1 span {
  color: var(--primary);
  text-shadow: 0 0 15px var(--primary-glow);
}

.brand-header .subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 6px;
}

.panel-body {
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.card-section h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.card-section .section-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* Input Fields */
.input-container {
  position: relative;
  width: 100%;
  margin-bottom: 20px;
}

.input-container input {
  width: 100%;
  padding: 16px 20px;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-align: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: var(--text-primary);
  outline: none;
  font-family: var(--font-family);
  transition: var(--transition-smooth);
}

.input-container input::placeholder {
  letter-spacing: 2px;
  color: var(--text-muted);
  opacity: 0.7;
}

.input-container input:focus {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--primary);
  box-shadow: 0 0 15px var(--primary-glow);
}

/* Buttons */
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  width: 100%;
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: hsl(222, 47%, 6%);
  box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px hsla(186, 100%, 45%, 0.5);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary-sm {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-secondary-sm:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: white;
}

.btn-accent:hover {
  box-shadow: 0 4px 15px rgba(189, 0, 255, 0.4);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.9rem;
  width: auto;
  border-radius: 8px;
}

.divider {
  border: none;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}

/* Steps List Info */
.steps-list {
  padding-left: 20px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.steps-list li strong {
  color: var(--text-primary);
}

.code-badge {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  color: var(--primary);
  display: inline-block;
  margin-top: 4px;
}

/* Status Indicator Footer */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.status-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-indicator .dot.idle { background-color: var(--text-muted); }
.status-indicator .dot.connecting { background-color: var(--accent); animation: pulse 1s infinite alternate; }
.status-indicator .dot.online { background-color: var(--primary); box-shadow: 0 0 8px var(--primary); }
.status-indicator .dot.error { background-color: var(--danger); box-shadow: 0 0 8px var(--danger); }

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.3); opacity: 1; }
}

/* Helper / Util classes */
.hidden {
  display: none !important;
}


/* 2. Viewer Panel */
#viewer-panel {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 20;
  background-color: #000;
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Header Toolbar */
#viewer-header {
  height: 60px;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  z-index: 30;
  flex-shrink: 0;
}

.header-left, .header-center, .header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* Back button */
.btn-icon {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-fast);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.session-info {
  display: flex;
  flex-direction: column;
}

.session-info .peer-title {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.session-info .peer-id {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
}

/* Center HUD Controls */
.setting-group {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.setting-group input[type="range"] {
  width: 100px;
  accent-color: var(--primary);
  height: 4px;
  border-radius: 2px;
  cursor: pointer;
}

.setting-group select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 6px;
  outline: none;
  font-family: var(--font-family);
  font-size: 0.85rem;
}

.btn-secondary-sm {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-secondary-sm:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
}

/* Diagnostics */
.diagnostics-hud {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.3);
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.diagnostics-hud .separator {
  opacity: 0.3;
}

/* Viewport Canvas Area */
#viewport-container {
  flex-grow: 1;
  width: 100%;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #0b0c10;
  position: relative;
}

#viewport-helper-text {
  position: absolute;
  top: 15px;
  background: rgba(0, 0, 0, 0.7);
  padding: 6px 16px;
  border-radius: 30px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  pointer-events: none;
  animation: fadeOutHelper 6s forwards;
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

@keyframes fadeOutHelper {
  0% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

.canvas-wrapper {
  max-width: 100%;
  max-height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

#screen-canvas {
  box-shadow: 0 10px 40px rgba(0,0,0,0.8);
  max-width: 100%;
  max-height: calc(100vh - 60px);
  cursor: crosshair;
  background: #000;
  display: block;
  outline: none; /* remove focus border */
}


/* 3. File Explorer Panel Overlay */
#file-explorer {
  position: absolute;
  top: 70px;
  right: 20px;
  bottom: 20px;
  width: 480px;
  display: flex;
  flex-direction: column;
  z-index: 40;
  animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

@keyframes slideInRight {
  from { transform: translateX(110%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.explorer-header {
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--glass-border);
}

.explorer-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}

.explorer-body {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-height: 0; /* Important for inner scrolling */
}

.explorer-panel {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  padding: 15px;
  gap: 12px;
  min-height: 0;
}

.panel-header-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.path-nav {
  display: flex;
  gap: 6px;
  width: 100%;
}

.btn-icon-sm {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-primary);
  width: 34px;
  height: 34px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.btn-icon-sm:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.2);
}

.path-nav input {
  flex-grow: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 6px 12px;
  color: var(--text-primary);
  font-family: monospace;
  font-size: 0.8rem;
  outline: none;
}

/* Files Table */
.files-table-container {
  flex-grow: 1;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  overflow-y: auto;
  min-height: 150px;
}

.files-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.files-table th {
  padding: 10px 12px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  color: var(--text-secondary);
  font-weight: 500;
  position: sticky;
  top: 0;
  z-index: 5;
}

.files-table td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.files-table tbody tr {
  cursor: pointer;
  transition: var(--transition-fast);
}

.files-table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

.files-table td .item-icon {
  margin-right: 8px;
  font-size: 1rem;
}

.empty-message {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0 !important;
}

/* Actions in table */
.action-cell {
  display: flex;
  gap: 6px;
}

.btn-table-action {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-secondary);
  padding: 4px 8px;
  font-size: 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-table-action:hover {
  background: rgba(186, 100%, 45%, 0.1);
  color: var(--primary);
  border-color: var(--primary);
}

/* Upload zone */
.upload-drop-zone {
  border: 2px dashed rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 15px;
  text-align: center;
  background: rgba(255,255,255,0.01);
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.upload-drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(186, 100%, 45%, 0.05);
  box-shadow: inset 0 0 10px var(--primary-glow);
}

.upload-drop-zone .upload-icon {
  font-size: 1.5rem;
}

.upload-drop-zone p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Transfer Progress Bar */
.transfer-status {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.transfer-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-family: monospace;
}

.transfer-info #transfer-file-name {
  max-width: 80%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
}
