@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #0b0f19;
  --bg-secondary: rgba(15, 23, 42, 0.7);
  --bg-tertiary: rgba(30, 41, 59, 0.8);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-glow: rgba(59, 130, 246, 0.5);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: rgba(255, 255, 255, 0.1);
  --radius: 16px;
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --glass-blur: blur(12px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.15), transparent 25%),
    radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.15), transparent 25%);
  color: var(--text-primary);
  overflow: hidden;
}

#app { width: 100%; height: 100%; }

.screen {
  width: 100%;
  height: 100%;
  display: none;
  opacity: 0;
  transition: opacity 0.4s ease-in-out;
}
.screen.active { 
  display: flex;
  flex-direction: column;
  opacity: 1;
}

.glass {
  background: var(--bg-secondary);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* Login Screen */
#login-screen {
  align-items: center;
  justify-content: center;
}

.login-container {
  width: 100%;
  max-width: 440px;
  padding: 3rem;
  border-radius: var(--radius);
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUp {
  0% { transform: translateY(40px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.logo {
  text-align: center;
  margin-bottom: 2.5rem;
}

.logo svg {
  filter: drop-shadow(0 0 12px var(--accent-glow));
  animation: float 6s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.logo h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 1rem;
  background: linear-gradient(to right, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Tabs */
.login-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 2rem;
  border-bottom: 2px solid rgba(255, 255, 255, 0.05);
}

.tab-btn {
  flex: 1;
  padding: 0.875rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: all 0.3s;
  position: relative;
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent); }

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.tab-content { display: none; animation: fadeIn 0.4s ease; }
.tab-content.active { display: block; }

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

/* Forms */
.form-group { margin-bottom: 1.5rem; }

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.form-group input {
  width: 100%;
  padding: 0.875rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: 'Outfit', sans-serif;
  transition: all 0.3s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* Buttons */
.btn {
  width: 100%;
  padding: 0.875rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  font-family: 'Outfit', sans-serif;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #2563eb);
  color: white;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.6);
  transform: translateY(-2px);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #dc2626);
  color: white;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}
.btn-danger:hover {
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.6);
}

.error-msg {
  color: #fca5a5;
  font-size: 0.9rem;
  margin-top: 1rem;
  text-align: center;
  min-height: 1.25rem;
}

.info-text {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

/* Results */
.result-box {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.result-box.hidden { display: none; }

.result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.result-item .label { color: var(--text-secondary); font-size: 0.9rem; }

.result-item .value {
  flex: 1;
  font-family: 'Monaco', 'Consolas', monospace;
  font-size: 1.1rem;
  color: var(--text-primary);
  background: rgba(255,255,255,0.05);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.btn-copy {
  padding: 0.4rem 0.75rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-copy:hover { background: rgba(255,255,255,0.2); }

.hint {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.75rem;
  text-align: center;
}

.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 1.5rem 0;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.qr-container img {
  width: 180px;
  height: 180px;
  border-radius: 8px;
}

.qr-container.hidden, .url-item.hidden { display: none; }

.admin-bar {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-admin {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s;
}

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

/* Desktop Screen */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 50;
}

.topbar-left, .topbar-center, .topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
  transition: all 0.3s;
}

.status-indicator.connected { 
  background: var(--success); 
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}
.status-indicator.connecting { 
  background: var(--warning); 
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
  animation: pulse 1.5s infinite; 
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

.session-id {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.session-id span {
  color: var(--text-primary);
  font-family: monospace;
  font-weight: 600;
  letter-spacing: 0.05em;
}

#connection-quality {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

#latency-display {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.toolbar-btn.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.toolbar-btn.btn-danger { color: #fca5a5; }
.toolbar-btn.btn-danger:hover { background: var(--danger); color: white; }

.main-area {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

#screen-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  position: relative;
}

#remote-screen {
  max-width: 100%;
  max-height: 100%;
  cursor: crosshair;
  transition: opacity 0.3s;
}

#loading-overlay, #reconnect-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  z-index: 10;
}

#loading-overlay.hidden, #reconnect-overlay.hidden { display: none; }

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1.5rem;
}

#loading-overlay p, #reconnect-overlay p {
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Side Panels */
.side-panel {
  width: 400px;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -10px 0 30px rgba(0,0,0,0.5);
  z-index: 40;
}

.side-panel.hidden { transform: translateX(100%); position: absolute; right: 0; top: 0; bottom: 0; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.panel-header h3 { font-size: 1.1rem; font-weight: 600; }

.btn-close-panel {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-close-panel:hover { background: rgba(255,255,255,0.2); color: white; }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

/* Files Panel */
.drop-zone {
  border: 2px dashed rgba(255,255,255,0.2);
  border-radius: 12px;
  padding: 2.5rem;
  text-align: center;
  color: var(--text-secondary);
  transition: all 0.3s;
  background: rgba(0,0,0,0.2);
  margin-bottom: 1.5rem;
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.1);
  color: var(--text-primary);
}

.drop-zone p { margin-top: 1rem; font-size: 0.95rem; }

.drop-zone button {
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
  text-decoration: none;
}
.drop-zone button:hover { text-decoration: underline; }

.file-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.file-item:hover { border-color: rgba(255,255,255,0.1); background: rgba(255,255,255,0.08); }

/* Terminal Panel */
.shell-selector { display: flex; gap: 0.5rem; }

.shell-btn {
  padding: 0.4rem 0.75rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.shell-btn.active {
  background: var(--accent);
  color: white;
}

#terminal-output {
  flex: 1;
  overflow-y: auto;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #a7f3d0;
  padding: 1rem;
  background: rgba(0,0,0,0.4);
  border-radius: 8px;
  margin-bottom: 1rem;
  min-height: 300px;
}

.terminal-input-line {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(0,0,0,0.4);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
}

.terminal-input-line:focus-within { border-color: var(--accent); }

#terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  color: white;
  font-family: 'Consolas', monospace;
  font-size: 0.9rem;
  outline: none;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal:not(.hidden) {
  opacity: 1;
  pointer-events: auto;
}

.modal.hidden { display: flex; } /* override to allow transition */

.modal-content {
  width: 90%;
  max-width: 440px;
  background: rgba(30, 41, 59, 0.9);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal:not(.hidden) .modal-content { transform: scale(1); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.modal-body { padding: 1.5rem; }

.setting-item { margin-bottom: 1.5rem; }
.setting-item label { font-size: 0.95rem; margin-bottom: 0.75rem; color: var(--text-secondary); display: flex; align-items: center; gap: 0.5rem; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.4); }

@media (max-width: 768px) {
  .side-panel { width: 100%; position: absolute; right: 0; top: 0; bottom: 0; z-index: 20; }
  .login-container { margin: 1rem; padding: 1.5rem; }
  .topbar-center { display: none; }
}
