/* ==========================================================================
   Escritorio Remoto - Sistema de diseño
   Tema oscuro premium, glassmorphism y micro-animaciones
   ========================================================================== */
:root {
  --bg-0: hsl(228 30% 6%);
  --bg-1: hsl(228 26% 9%);
  --bg-2: hsl(228 22% 13%);
  --glass: hsla(228 30% 16% / .55);
  --glass-strong: hsla(228 30% 12% / .85);
  --border: hsla(220 40% 80% / .09);
  --border-strong: hsla(220 40% 80% / .18);
  --text: hsl(220 30% 96%);
  --text-2: hsl(222 16% 70%);
  --text-3: hsl(224 12% 50%);
  --accent: hsl(168 84% 52%);
  --accent-2: hsl(258 90% 68%);
  --accent-grad: linear-gradient(135deg, hsl(168 84% 52%) 0%, hsl(200 90% 58%) 50%, hsl(258 90% 68%) 100%);
  --danger: hsl(352 86% 62%);
  --warn: hsl(38 96% 60%);
  --ok: hsl(150 70% 50%);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 20px 60px -20px hsla(230 60% 2% / .8), 0 0 0 1px var(--border);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg-0);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
}
button, input, select { font: inherit; color: inherit; }
::selection { background: hsla(168 84% 52% / .3); }

/* Fondo animado */
.bg-orbs { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.bg-orbs span {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: .35;
  animation: float 22s var(--ease) infinite alternate;
}
.bg-orbs span:nth-child(1) { width: 520px; height: 520px; background: hsl(168 84% 40%); top: -160px; left: -120px; }
.bg-orbs span:nth-child(2) { width: 460px; height: 460px; background: hsl(258 80% 50%); bottom: -180px; right: -100px; animation-delay: -8s; }
.bg-orbs span:nth-child(3) { width: 300px; height: 300px; background: hsl(205 90% 45%); top: 40%; left: 45%; opacity: .18; animation-delay: -14s; }
@keyframes float { to { transform: translate(60px, 40px) scale(1.12); } }
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
  opacity: .5;
}

/* Layout */
.app { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: hsla(228 30% 6% / .4); backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; letter-spacing: -.02em; font-size: 17px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 10px; background: var(--accent-grad);
  display: grid; place-items: center; box-shadow: 0 6px 24px -6px hsla(168 84% 52% / .6);
}
.brand-logo svg { width: 19px; height: 19px; color: hsl(228 30% 8%); }
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--text-3); letter-spacing: .02em; }
.spacer { flex: 1; }

.status-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); position: relative; }
.dot.ok { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.dot.ok::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--ok); animation: ping 2s infinite; opacity: 0; }
.dot.warn { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.dot.err { background: var(--danger); box-shadow: 0 0 10px var(--danger); }
@keyframes ping { 0% { transform: scale(.6); opacity: .8; } 100% { transform: scale(1.8); opacity: 0; } }

.main {
  flex: 1; overflow: auto; padding: 32px 28px 40px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 24px;
  align-content: start; max-width: 1180px; width: 100%; margin: 0 auto;
}

/* Tarjetas */
.card {
  position: relative; background: var(--glass); backdrop-filter: blur(22px) saturate(140%);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px;
  animation: rise .6s var(--ease) both;
}
.card:nth-child(2) { animation-delay: .08s; }
.card:nth-child(3) { animation-delay: .16s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.card::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(160deg, hsla(168 84% 60% / .35), transparent 40%, transparent 60%, hsla(258 90% 70% / .3));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.card-icon {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: hsla(168 84% 52% / .12); color: var(--accent); border: 1px solid hsla(168 84% 52% / .25);
}
.card-icon.violet { background: hsla(258 90% 68% / .12); color: var(--accent-2); border-color: hsla(258 90% 68% / .25); }
.card-icon svg { width: 20px; height: 20px; }
.card h2 { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.card-head p { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.card.wide { grid-column: 1 / -1; }

.label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); margin-bottom: 8px; display: block; }

/* ID grande */
.id-box {
  display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-radius: var(--radius-sm);
  background: hsla(228 30% 6% / .55); border: 1px solid var(--border); margin-bottom: 16px;
}
.id-value {
  flex: 1; font-family: var(--mono); font-size: 32px; font-weight: 700; letter-spacing: .06em;
  background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  user-select: text;
}
.id-value.loading { color: var(--text-3); background: none; -webkit-text-fill-color: var(--text-3); font-size: 20px; }
.pw-value { flex: 1; font-family: var(--mono); font-size: 19px; font-weight: 600; letter-spacing: .12em; user-select: text; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: hsla(228 30% 20% / .6); cursor: pointer; font-weight: 600; font-size: 14px;
  transition: transform .15s var(--ease), background .2s, border-color .2s, box-shadow .2s;
  white-space: nowrap;
}
.btn:hover { background: hsla(228 30% 26% / .8); border-color: hsla(220 40% 80% / .28); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn svg { width: 17px; height: 17px; }
.btn-primary {
  background: var(--accent-grad); border: none; color: hsl(228 40% 8%);
  box-shadow: 0 10px 30px -10px hsla(168 84% 52% / .7);
}
.btn-primary:hover { background: var(--accent-grad); box-shadow: 0 14px 36px -10px hsla(200 90% 58% / .8); filter: brightness(1.08); }
.btn-danger { background: hsla(352 86% 62% / .15); border-color: hsla(352 86% 62% / .4); color: hsl(352 90% 75%); }
.btn-danger:hover { background: hsla(352 86% 62% / .28); border-color: hsla(352 86% 62% / .6); }
.btn-block { width: 100%; padding: 15px; font-size: 15px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: transparent; border: 1px solid transparent; color: var(--text-2); cursor: pointer;
  transition: background .2s, color .2s, transform .15s;
}
.icon-btn:hover { background: hsla(220 40% 80% / .08); color: var(--text); border-color: var(--border); }
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.active { color: var(--accent); background: hsla(168 84% 52% / .12); }

/* Inputs */
.field { margin-bottom: 16px; }
.input {
  width: 100%; padding: 14px 16px; border-radius: 12px; background: hsla(228 30% 6% / .6);
  border: 1px solid var(--border-strong); outline: none; font-size: 15px; transition: border-color .2s, box-shadow .2s;
  user-select: text;
}
.input:focus { border-color: hsla(168 84% 52% / .6); box-shadow: 0 0 0 4px hsla(168 84% 52% / .12); }
.input.id-input { font-family: var(--mono); font-size: 24px; font-weight: 600; letter-spacing: .08em; text-align: center; padding: 16px; }
.input::placeholder { color: var(--text-3); letter-spacing: normal; }
select.input { appearance: none; cursor: pointer; }

.row { display: flex; gap: 10px; align-items: center; }
.hint { font-size: 12.5px; color: var(--text-3); line-height: 1.55; }
.hint b { color: var(--text-2); font-weight: 600; }

/* Toggle */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); font-size: 13.5px; color: var(--text-2); }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: hsla(220 20% 40% / .5); cursor: pointer; transition: background .25s; }
.switch span::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform .25s var(--ease); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(18px); }

/* Listas */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px;
  background: hsla(228 30% 6% / .4); border: 1px solid var(--border); cursor: pointer;
  transition: background .2s, border-color .2s, transform .15s;
}
.list-item:hover { background: hsla(228 30% 14% / .7); border-color: var(--border-strong); transform: translateX(2px); }
.list-item .avatar {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: linear-gradient(135deg, hsla(200 90% 58% / .25), hsla(258 90% 68% / .25)); color: var(--text);
}
.list-item .meta { flex: 1; min-width: 0; }
.list-item .meta b { display: block; font-family: var(--mono); font-size: 14px; letter-spacing: .04em; }
.list-item .meta small { color: var(--text-3); font-size: 12px; }
.empty { padding: 18px; text-align: center; color: var(--text-3); font-size: 13px; border: 1px dashed var(--border-strong); border-radius: 12px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: hsla(168 84% 52% / .12); color: var(--accent); border: 1px solid hsla(168 84% 52% / .25); }
.badge.violet { background: hsla(258 90% 68% / .12); color: hsl(258 90% 78%); border-color: hsla(258 90% 68% / .3); }
.badge.warn { background: hsla(38 96% 60% / .12); color: var(--warn); border-color: hsla(38 96% 60% / .3); }

/* Feature chips */
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.feature { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 12px; background: hsla(228 30% 6% / .35); border: 1px solid var(--border); }
.feature svg { width: 20px; height: 20px; color: var(--accent); flex: none; margin-top: 1px; }
.feature b { display: block; font-size: 13.5px; margin-bottom: 3px; }
.feature span { font-size: 12.5px; color: var(--text-3); line-height: 1.45; }

/* Modales */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px;
  background: hsla(228 40% 3% / .65); backdrop-filter: blur(8px);
  animation: fade .2s var(--ease);
}
.modal-backdrop[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(440px, 100%); background: var(--glass-strong); backdrop-filter: blur(24px);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; animation: pop .3s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(10px); } }
.modal h3 { font-size: 18px; margin-bottom: 6px; }
.modal .sub { color: var(--text-2); font-size: 13.5px; margin-bottom: 20px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.modal-actions .btn { flex: 1; }
.incoming-ring {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 16px; display: grid; place-items: center;
  background: var(--accent-grad); color: hsl(228 40% 8%); position: relative;
}
.incoming-ring::before, .incoming-ring::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); animation: ring 1.8s infinite; }
.incoming-ring::after { animation-delay: .9s; }
.incoming-ring svg { width: 28px; height: 28px; }
@keyframes ring { from { transform: scale(1); opacity: .7; } to { transform: scale(1.8); opacity: 0; } }
.countdown { height: 3px; border-radius: 3px; background: var(--border); overflow: hidden; margin-top: 18px; }
.countdown i { display: block; height: 100%; background: var(--accent-grad); transform-origin: left; }

/* Toasts */
.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 80; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 380px; padding: 13px 16px; border-radius: 12px;
  background: var(--glass-strong); backdrop-filter: blur(20px); box-shadow: var(--shadow); font-size: 13.5px;
  animation: slidein .35s var(--ease);
}
.toast.out { animation: slideout .3s var(--ease) forwards; }
.toast .dot { flex: none; }
@keyframes slidein { from { opacity: 0; transform: translateX(30px); } }
@keyframes slideout { to { opacity: 0; transform: translateX(30px); } }

/* Spinner */
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid hsla(228 40% 8% / .3); border-top-color: currentColor; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Sesión remota (visor)
   ========================================================================== */
.stage {
  position: fixed; inset: 0; z-index: 40; background: #000; display: none;
  align-items: center; justify-content: center; overflow: hidden;
}
.stage.active { display: flex; }
.stage video {
  width: 100%; height: 100%; object-fit: contain; outline: none; background: #000;
  cursor: default; touch-action: none;
}
.stage.scale-native video { width: auto; height: auto; max-width: none; max-height: none; object-fit: none; }
.stage.scale-native { overflow: auto; align-items: flex-start; justify-content: flex-start; }
.stage.scale-stretch video { object-fit: fill; }

.stage-overlay {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 2;
  background: radial-gradient(ellipse at center, hsla(228 30% 10% / .9), hsla(228 30% 4% / .97));
  transition: opacity .3s;
}
.stage-overlay[hidden] { display: none; }
.stage-overlay .box { text-align: center; max-width: 380px; padding: 20px; }
.stage-overlay .big-spin { width: 54px; height: 54px; margin: 0 auto 20px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.stage-overlay h3 { font-size: 18px; margin-bottom: 8px; }
.stage-overlay p { color: var(--text-2); font-size: 14px; line-height: 1.5; margin-bottom: 20px; }

.toolbar-wrap { position: absolute; top: 0; left: 50%; transform: translateX(-50%); z-index: 5; padding-top: 10px; }
.toolbar-wrap .handle {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 140px; height: 10px;
}
.toolbar {
  display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 14px;
  background: hsla(228 30% 8% / .82); backdrop-filter: blur(20px); box-shadow: var(--shadow);
  transition: transform .35s var(--ease), opacity .35s;
}
.toolbar-wrap.hidden .toolbar { transform: translateY(calc(-100% - 14px)); opacity: 0; }
.toolbar-wrap.hidden .handle { height: 18px; }
.toolbar .sep { width: 1px; height: 22px; background: var(--border-strong); margin: 0 4px; }
.toolbar .tb-id { font-family: var(--mono); font-size: 13px; font-weight: 600; padding: 0 10px 0 6px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.toolbar select.input { width: auto; padding: 7px 28px 7px 10px; font-size: 12.5px; border-radius: 9px; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 13px) 50%, calc(100% - 9px) 50%; background-size: 4px 4px; background-repeat: no-repeat; }
.toolbar .icon-btn { width: 34px; height: 34px; }
.latency { font-family: var(--mono); font-size: 12px; padding: 4px 8px; border-radius: 7px; background: hsla(150 70% 50% / .14); color: var(--ok); min-width: 54px; text-align: center; }
.latency.mid { background: hsla(38 96% 60% / .14); color: var(--warn); }
.latency.bad { background: hsla(352 86% 62% / .14); color: var(--danger); }

.dropdown { position: relative; }
.menu {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 210px; padding: 6px; border-radius: 12px;
  background: hsla(228 30% 9% / .96); backdrop-filter: blur(20px); box-shadow: var(--shadow); display: none;
}
.menu.open { display: block; animation: pop .18s var(--ease); }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; border: none; background: none; cursor: pointer; font-size: 13px; text-align: left; color: var(--text-2); }
.menu button:hover { background: hsla(220 40% 80% / .08); color: var(--text); }
.menu kbd { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--text-3); }

.stats {
  position: absolute; left: 14px; bottom: 14px; z-index: 5; padding: 12px 14px; border-radius: 12px;
  background: hsla(228 30% 6% / .78); backdrop-filter: blur(14px); font-family: var(--mono); font-size: 11.5px;
  color: var(--text-2); line-height: 1.7; box-shadow: var(--shadow); pointer-events: none; min-width: 200px;
}
.stats[hidden] { display: none; }
.stats b { color: var(--text); font-weight: 600; }

/* Banner de host controlado */
.host-banner {
  display: none; align-items: center; gap: 12px; padding: 10px 28px; font-size: 13px;
  background: linear-gradient(90deg, hsla(168 84% 52% / .18), hsla(258 90% 68% / .18)); border-bottom: 1px solid var(--border);
}
.host-banner.active { display: flex; }

/* Utilidades */
[hidden] { display: none !important; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; }
.grow { flex: 1; }
.muted { color: var(--text-3); }
.center { text-align: center; }

@media (max-width: 720px) {
  .main { padding: 20px 14px; grid-template-columns: 1fr; }
  .topbar { padding: 12px 14px; }
  .id-value { font-size: 26px; }
  .toolbar .hide-sm { display: none; }
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: hsla(220 20% 50% / .25); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
