/* Visor 3D de la casa. Estilo nocturno del hub (docs/PLANO.md). Pensado para Echo Show (960×480 a
   1920×1080, táctil) y también para el celular y la compu. */
:root {
  --bg: #05070B; --text: #E8EEF7; --muted: #B4BDCC; --label: #8A96AB;
  --cyan: #5BE7FF; --amber: #FFC266; --green: #4DF0A8; --danger: #FF6B6B;
  --card: rgba(255,255,255,.03); --line: rgba(255,255,255,.08);
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
  font-family: "Space Grotesk", system-ui, -apple-system, sans-serif;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.label { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--label); }

.bar {
  position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) 22px 14px; pointer-events: none;
  background: linear-gradient(var(--bg) 30%, transparent);
}
.bar > * { pointer-events: auto; }
.bar .title { flex: 1; min-width: 0; }
.bar h1 { font-size: 26px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .stat { text-align: right; }
.bar .stat b { display: block; font-family: var(--mono); font-size: 20px; color: var(--amber); }
.back {
  width: 52px; height: 52px; border-radius: 50%; font-size: 34px; line-height: 1; padding-bottom: 4px;
  background: var(--card); border: 1px solid var(--line); color: var(--cyan);
}
.ghost { padding: 10px 16px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.ghost.danger { color: var(--danger); }
.btn { display: inline-block; padding: 10px 16px; border-radius: 14px; background: var(--cyan); color: #04161C; font-weight: 600; cursor: pointer; box-shadow: 0 0 18px rgba(91,231,255,.35); }

/* Etiquetas de las habitaciones sobre el 3D */
#labels { position: fixed; inset: 0; pointer-events: none; }
.tag {
  position: absolute; transform: translate(-50%, -50%); text-align: center; pointer-events: auto; cursor: pointer;
  padding: 6px 12px; border-radius: 12px; background: rgba(5,7,11,.55); border: 1px solid var(--line);
  transition: opacity .3s, border-color .3s; white-space: nowrap;
}
.tag b { display: block; font-size: 15px; font-weight: 600; }
.tag span { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; color: var(--muted); }
.tag.on { border-color: var(--glow, var(--amber)); box-shadow: 0 0 18px -4px var(--glow, var(--amber)); }
.tag.on span { color: var(--glow, var(--amber)); }
.tag.hide { opacity: 0; pointer-events: none; }

/* Panel de la habitación elegida */
.panel {
  position: fixed; right: 16px; top: 88px; bottom: 16px; width: min(400px, 40vw);
  padding: 18px; border-radius: 24px; background: rgba(10,13,19,.86); border: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  display: flex; flex-direction: column; gap: 14px; animation: slide .45s cubic-bezier(.2,.8,.2,1);
}
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.panel-head { display: flex; align-items: center; gap: 12px; }
.panel-head > div { flex: 1; min-width: 0; }
.panel h2 { font-size: 24px; font-weight: 600; margin-top: 2px; }
.all { padding: 12px 18px; border-radius: 16px; font-weight: 600; background: var(--cyan); color: #04161C; box-shadow: 0 0 18px rgba(91,231,255,.35); white-space: nowrap; }
.all.off { background: var(--card); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.lights { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.light {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px 12px;
  padding: 14px 16px; border-radius: 18px; background: var(--card); border: 1px solid var(--line);
  transition: border-color .24s, box-shadow .24s, background .24s;
}
.light.on { border-color: color-mix(in srgb, var(--glow) 65%, transparent); background: color-mix(in srgb, var(--glow) 13%, transparent); box-shadow: 0 0 28px -6px color-mix(in srgb, var(--glow) 38%, transparent); }
.light .n { font-weight: 600; font-size: 17px; }
.light .s { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; color: var(--muted); text-transform: uppercase; }
.light input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--glow, var(--cyan)); height: 28px; }
.light.offline { opacity: .5; }
.empty { color: var(--muted); padding: 10px 2px; }

/* Interruptor grande, cómodo para el dedo en el Echo Show */
.sw { width: 64px; height: 38px; border-radius: 19px; background: rgba(255,255,255,.12); position: relative; transition: background .2s; }
.sw::after { content: ""; position: absolute; top: 4px; left: 4px; width: 30px; height: 30px; border-radius: 50%; background: #fff; transition: transform .2s; }
.sw.on { background: var(--glow, var(--cyan)); }
.sw.on::after { transform: translateX(26px); }

/* Edición (sólo en casa, con la sesión del hub) */
.edit {
  position: fixed; left: 16px; right: 16px; bottom: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 20px; background: rgba(10,13,19,.9); border: 1px solid var(--line);
}
.edit-room { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.edit select { padding: 9px 10px; border-radius: 12px; background: #0D1118; border: 1px solid var(--line); }
.edit .hint { flex: 1; min-width: 200px; color: var(--muted); font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); padding: 10px 16px; border-radius: 14px; background: #10151E; border: 1px solid var(--line); }
.msg { position: fixed; inset: 0; display: grid; place-items: center; text-align: center; padding: 30px; color: var(--muted); }
.msg a { color: var(--cyan); }

/* Pantallas bajas (Echo Show 5: 960×480) y celulares en vertical */
@media (max-height: 520px) {
  .bar { padding-top: 10px; padding-bottom: 8px; }
  .bar h1 { font-size: 21px; }
  .panel { top: 70px; bottom: 10px; padding: 14px; }
  .light { padding: 10px 12px; }
}
@media (max-width: 640px) and (orientation: portrait) {
  .panel { left: 12px; right: 12px; width: auto; top: auto; max-height: 55vh; }
}
