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

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-soft: rgba(99, 102, 241, 0.15);
  --bg-1: #0b0b14;
  --bg-2: #1a1a2e;
  --bg-3: #2d2b45;
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-strong: rgba(255, 255, 255, 0.14);
  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-faint: #71717a;
  --error: #ef4444;
  --success: #10b981;
  --line: #2a2a3a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background:
    radial-gradient(circle at 15% 20%, rgba(99, 102, 241, 0.18), transparent 50%),
    radial-gradient(circle at 85% 80%, rgba(139, 92, 246, 0.12), transparent 50%),
    linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 60%, var(--bg-3) 100%);
  background-size: 200% 200%;
  animation: bgAnimate 25s ease-in-out infinite;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  overflow: hidden;
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@keyframes bgAnimate {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* ==========================================================
   Login / Connect container
   ========================================================== */
#login-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  position: absolute;
  z-index: 10;
  padding: 1rem;
  gap: 1rem;
}

.login-box {
  background: var(--glass-bg);
  padding: 2.25rem 2rem;
  border-radius: 18px;
  width: 100%;
  max-width: 380px;
  box-shadow:
    0 20px 60px -10px rgba(0, 0, 0, 0.6),
    0 0 0 1px var(--glass-border) inset;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--glass-border);
  animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================
   Brand block
   ========================================================== */
.brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.brand-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 0.75rem;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #a78bfa);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.5px;
  color: #fff;
  box-shadow: 0 8px 24px -6px rgba(99, 102, 241, 0.55);
}

h2 {
  margin: 0 0 0.25rem;
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #fff 30%, #c4b5fd);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

/* ==========================================================
   Inputs (floating label)
   ========================================================== */
.input-group {
  position: relative;
  margin-bottom: 1.5rem;
}

.input-group input {
  width: 100%;
  padding: 0.75rem 0.5rem 0.5rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--line);
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.25s;
}

.input-group input:focus {
  border-bottom-color: var(--primary);
}

.input-group input:-webkit-autofill,
.input-group input:-webkit-autofill:hover,
.input-group input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text-main);
  -webkit-box-shadow: 0 0 0 100px transparent inset;
  transition: background-color 9999s ease-in-out 0s;
}

.input-group label {
  position: absolute;
  top: 0.75rem;
  left: 0.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  pointer-events: none;
  transition: 0.25s ease all;
}

.input-group input:focus ~ label,
.input-group input:not(:placeholder-shown) ~ label {
  top: -0.6rem;
  font-size: 0.72rem;
  color: var(--primary);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ==========================================================
   Buttons
   ========================================================== */
button[type="submit"] {
  width: 100%;
  padding: 0.85rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
  box-shadow: 0 8px 20px -8px rgba(99, 102, 241, 0.6);
  letter-spacing: 0.01em;
}

button[type="submit"]:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
  box-shadow: 0 12px 24px -8px rgba(99, 102, 241, 0.75);
}

button[type="submit"]:active {
  transform: translateY(0);
}

button:disabled {
  background: #2a2a3a;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  color: var(--text-faint);
  filter: none;
}

.ghost-btn {
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.7rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--glass-border-strong);
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.ghost-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  border-color: var(--glass-border-strong);
}

.footer-note {
  color: var(--text-faint);
  font-size: 0.75rem;
  margin: 0;
  text-align: center;
}

/* ==========================================================
   Remote view
   ========================================================== */
#remote-view {
  display: none;
  position: fixed;
  inset: 0;
  background: #000;
  overflow: hidden;
  cursor: default;
  outline: none;
}

#remote-view > div {
  width: 100%;
  height: 100%;
}

#remote-view canvas {
  display: block;
}

.no-cursor {
  cursor: none !important;
}

/* ==========================================================
   Floating toolbar
   ========================================================== */
#toolbar {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  padding: 6px 10px;
  background: rgba(11, 11, 20, 0.7);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--glass-border-strong);
  border-radius: 999px;
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.6);
  z-index: 10000;
  cursor: grab;
  user-select: none;
  align-items: center;
  gap: 6px;
  transition: opacity 0.3s, transform 0.1s cubic-bezier(0, 0, 0.2, 1);
}

#toolbar:active {
  cursor: grabbing;
}

#toolbar button {
  background: transparent;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  color: #e2e8f0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  transition: background 0.18s, color 0.18s;
}

#toolbar button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

#toolbar button.disconnect-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

/* ==========================================================
   Toasts
   ========================================================== */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: calc(100vw - 40px);
}

.toast {
  background: rgba(11, 11, 20, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-left: 4px solid var(--primary);
  padding: 0.85rem 1.25rem;
  border-radius: 8px;
  color: #fff;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid var(--glass-border);
}

.toast.error {
  border-left-color: var(--error);
}

.toast.success {
  border-left-color: var(--success);
}

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

.toast-closing {
  animation: slideOut 0.3s forwards;
}

@keyframes slideOut {
  to { transform: translateX(110%); opacity: 0; }
}

/* ==========================================================
   Mobile
   ========================================================== */
@media (max-width: 480px) {
  .login-box {
    padding: 1.75rem 1.5rem;
    border-radius: 14px;
  }

  h2 { font-size: 1.25rem; }

  #toolbar {
    top: 12px;
    padding: 4px 8px;
  }

  #toast-container {
    right: 12px;
    bottom: 12px;
    left: 12px;
  }

  .toast { min-width: 0; width: 100%; }
}
