/* ═══════════════════════════════════════════════════
   Browser Terminal — Styles
   Dark theme with glassmorphism, matching Browser-RDP aesthetic
   ═══════════════════════════════════════════════════ */

/* ── Reset & Base ───────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #111119;
  --bg-card: rgb(20, 20, 32, 0.85);
  --bg-glass: rgb(18, 18, 28, 0.75);
  --bg-input: rgb(30, 30, 48, 0.9);
  --bg-hover: rgb(99, 102, 241, 0.1);
  --text-primary: #e4e4ef;
  --text-secondary: #8b8ba0;
  --text-muted: #5a5a72;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-dim: rgb(99, 102, 241, 0.15);
  --accent-glow: rgb(99, 102, 241, 0.25);
  --danger: #ef4444;
  --danger-hover: #f87171;
  --success: #22c55e;
  --warning: #f59e0b;
  --border: rgb(255, 255, 255, 0.06);
  --border-accent: rgb(99, 102, 241, 0.3);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --font: 'Inter', -apple-system, blinkmacsystemfont, 'Segoe UI', sans-serif;
  --font-mono: 'Menlo', 'Monaco', 'Courier New', monospace;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow: 0 8px 32px rgb(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgb(0, 0, 0, 0.6);
}

html,
body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

/* ── Custom Scrollbar ───────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ── Login Card ────────────────────────────────── */
#login-view.active {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px);
  padding: 2rem;
  background: radial-gradient(ellipse at top, var(--accent-dim) 0%, transparent 50%), var(--bg-primary);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3rem;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow:
    0 4px 24px rgb(0, 0, 0, 0.4),
    0 0 40px var(--accent-dim);
  backdrop-filter: blur(20px);
}

.login-logo {
  margin-bottom: 0.5rem;
}

.login-logo svg {
  width: 48px;
  height: 48px;
  color: var(--accent);
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.login-logo img {
  width: 120px;
  height: 120px;
  filter: drop-shadow(0 0 16px var(--accent-glow));
}

.login-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

.login-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.google-button,
.microsoft-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.875rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: var(--font);
  color: #3c4043;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.google-button:hover,
.microsoft-button:hover {
  background: #f8f9fa;
  border-color: #c0c4c9;
  box-shadow: 0 1px 3px rgb(0, 0, 0, 0.1);
}

.google-icon,
.microsoft-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ── App Launcher — Tile Grid ────────────── */
#launcher-view.active {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 3rem;
  min-height: calc(100vh - 52px);
  background: radial-gradient(ellipse at top, var(--accent-dim) 0%, transparent 50%), var(--bg-primary);
  overflow-y: auto;
}

.app-launcher {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 1150px;
  padding: 0 2rem 3rem;
}

.app-launcher-logo {
  margin-bottom: -0.5rem;
  opacity: 0;
  animation: launcherFadeIn 0.4s ease forwards;
}

.app-launcher-logo img {
  width: 72px;
  height: 72px;
  filter: drop-shadow(0 0 16px var(--accent-glow));
}

.app-launcher-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  opacity: 0;
  animation: launcherFadeIn 0.4s ease forwards;
}

.app-launcher-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 2.5rem;
  opacity: 0;
  animation: launcherFadeIn 0.4s 0.1s ease forwards;
}

.app-launcher-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, 140px);
  gap: 1.25rem;
  justify-content: center;
  width: 100%;
}

.app-launcher-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  width: 140px;
  height: 140px;
  background: rgb(20, 20, 32, 0.8);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  transform: scale(0.9) translateY(10px);
  animation: launcherTileIn 0.3s ease forwards;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0;
  font-family: var(--font);
  color: var(--text-primary);
}

.app-launcher-tile:hover {
  transform: scale(1.05);
  border-color: var(--border-accent);
  box-shadow:
    0 0 30px var(--accent-dim),
    0 8px 24px rgb(0, 0, 0, 0.3);
  background: rgb(20, 20, 32, 0.95);
}

.app-launcher-tile:active {
  transform: scale(0.97);
  transition-duration: 0.1s;
}

.app-launcher-icon {
  width: 48px;
  height: 48px;
  color: var(--accent);
  flex-shrink: 0;
}

.app-launcher-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.app-launcher-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

@keyframes launcherFadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes launcherTileIn {
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ── Header ─────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 52px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  position: relative;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-icon {
  width: 32px;
  height: 32px;
  color: var(--accent);
}

header h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.header-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border-accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.header-btn svg {
  width: 16px;
  height: 16px;
}

.header-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  border-color: var(--border-accent);
}

.header-btn-danger {
  color: var(--danger);
  border-color: rgb(239, 68, 68, 0.3);
}

.header-btn-danger:hover {
  color: var(--danger);
  border-color: rgb(239, 68, 68, 0.3);
  background: rgb(239, 68, 68, 0.08);
}

/* ── Main Content ───────────────────────────────── */
main {
  height: calc(100vh - 52px);
  position: relative;
}

.view {
  display: none;
  width: 100%;
  height: 100%;
}

.view.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Connect Card ───────────────────────────────── */
.connect-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.card-header svg {
  width: 28px;
  height: 28px;
  color: var(--accent);
  flex-shrink: 0;
}

.card-header h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 28px;
  line-height: 1.5;
}

.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.flex-grow {
  flex: 1;
}

.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group select,
.form-group input {
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  outline: none;
  transition: all var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b8ba0' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.form-group select:focus,
.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group select:disabled,
.form-group input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-error {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--danger);
  background: rgb(239, 68, 68, 0.08);
  border: 1px solid rgb(239, 68, 68, 0.2);
  border-radius: var(--radius-xs);
  margin-bottom: 16px;
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 8px;
}

.btn-primary svg {
  width: 18px;
  height: 18px;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* ── Session View ───────────────────────────────── */
#session-view.active {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
}

#terminal-viewport {
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  overflow: hidden;
  padding: 4px;
}

/* xterm.js overrides */
#terminal-viewport .xterm {
  height: 100%;
}

#terminal-viewport .xterm-screen {
  height: 100% !important;
}

/* ── Toast Notifications ────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--text-primary);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: toastIn 0.3s ease-out;
}

.toast.success {
  border-color: rgb(34, 197, 94, 0.3);
}

.toast.error {
  border-color: rgb(239, 68, 68, 0.3);
}

.toast.warning {
  border-color: rgb(245, 158, 11, 0.4);
  background: rgb(245, 158, 11, 0.15);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Spinner ────────────────────────────────────── */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Connecting overlay ─────────────────────────── */
.connecting-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--bg-primary);
  z-index: 50;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ── Connection Failed Overlay ─────────────────── */
.connection-failed {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, var(--accent-dim) 0%, transparent 60%), var(--bg-primary);
  z-index: 11;
  text-align: center;
  padding: 40px;
  animation: cf-fade-in 0.4s ease;
}

@keyframes cf-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.connection-failed.hidden {
  display: none;
}

.cf-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3rem;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow:
    0 4px 24px rgb(0, 0, 0, 0.4),
    0 0 40px var(--accent-dim);
  backdrop-filter: blur(20px);
}

.cf-icon {
  width: 72px;
  height: 72px;
  margin-bottom: 12px;
  animation: cf-pulse 2.5s ease-in-out infinite;
}

@keyframes cf-pulse {
  0%,
  100% {
    opacity: 0.7;
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

.cf-title {
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.cf-subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 16px;
  max-width: 280px;
}

.cf-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 32px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 20px rgb(99, 102, 241, 0.35);
}

.cf-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgb(99, 102, 241, 0.45);
}

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

.cf-btn svg {
  flex-shrink: 0;
}

.cf-btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  margin-top: 8px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s ease;
}

.cf-btn-outline:hover {
  background: var(--bg-hover);
  border-color: var(--border-accent);
  color: var(--text-primary);
}

/* ── Fullscreen Mode ────────────────────────────── */
header {
  transition:
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.fullscreen-mode #app-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

body.fullscreen-mode main {
  height: 100vh;
}

body.fullscreen-mode #app-header.header-peek {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
  z-index: 150;
}

.fullscreen-reveal-tab {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 5px;
  background: rgb(99, 102, 241, 0.5);
  border-radius: 0 0 6px 6px;
  cursor: pointer;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.3s ease,
    height 0.2s ease,
    background 0.2s ease;
}

body.fullscreen-mode .fullscreen-reveal-tab {
  opacity: 1;
  pointer-events: auto;
}

.fullscreen-reveal-tab:hover {
  height: 8px;
  background: rgb(99, 102, 241, 0.8);
}

/* ── Header Icon (img support) ──────────────────── */
.header-icon {
  object-fit: contain;
  border-radius: 4px;
}
