:root {
  --bg: #0b1220;
  --bg2: #0f1a2e;
  --card: rgba(255, 255, 255, 0.06);
  --card-brd: rgba(255, 255, 255, 0.12);
  --ink: #eaf1fb;
  --ink-soft: #a9b8cf;
  --teal: #34d3c2;
  --teal2: #21b6c9;
  --blue: #5aa9ff;
  --coral: #ff7a7a;
  --warn: #ffb020;
  --crit: #ff4d4f;
  --ok: #37d67a;
  --radius: 20px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(52, 211, 194, 0.16), transparent 60%),
    radial-gradient(1000px 700px at 110% 10%, rgba(90, 169, 255, 0.16), transparent 55%),
    linear-gradient(160deg, var(--bg), var(--bg2));
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.85fr);
  gap: 22px; max-width: 1460px; margin: 0 auto; padding: 22px; min-height: 100vh;
}
@media (max-width: 1040px) { .app { grid-template-columns: 1fr; } }

.stage { min-width: 0; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-size: 16px; }
.brand-sub { color: var(--ink-soft); font-size: 12.5px; }
.brand-dot { width: 34px; height: 34px; border-radius: 11px; background: linear-gradient(135deg, var(--teal), var(--blue)); box-shadow: 0 6px 20px rgba(52, 211, 194, 0.5); }

.status-chips { display: flex; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--card); border: 1px solid var(--card-brd); color: var(--ink-soft); }
.chip-led { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-soft); }
.chip.ok { color: #d6fff0; border-color: rgba(55, 214, 122, 0.5); }
.chip.ok .chip-led { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.chip.bad { color: #ffdede; border-color: rgba(255, 77, 79, 0.5); }
.chip.bad .chip-led { background: var(--crit); box-shadow: 0 0 10px var(--crit); }

/* Room / scene */
.room { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--card-brd); box-shadow: var(--shadow); aspect-ratio: 16 / 9; background: #060a12; }
/* Imagem-base unica: o "prato" fixo do quarto. Somente o filtro de cor muda
   por ambiente, mantendo a geometria pixel-identica. */
.room-base { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: filter 0.6s ease; }

/* Camada de ambiente (tint de cor por cima de tudo) */
.ambient-layer { position: absolute; inset: 0; z-index: 1; pointer-events: none; background: transparent; transition: background 0.6s ease; }
/* Brilhos localizados (ex.: foco de leitura / presenca noturna) */
.ambient-glow { position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0; transition: opacity 0.6s ease; }

/* Ambientes (tipos de iluminacao) — so mudam luz/cor, o quarto continua o mesmo */
.room.amb-conforto .room-base { filter: brightness(1.03) saturate(1.04); }
.room.amb-conforto .ambient-layer { background: rgba(255, 196, 130, 0.10); }

.room.amb-leitura .room-base { filter: brightness(0.72) saturate(1.12) sepia(0.20); }
.room.amb-leitura .ambient-layer { background: rgba(255, 138, 40, 0.24); }
.room.amb-leitura .ambient-glow { opacity: 1;
  background:
    radial-gradient(46% 52% at 50% 86%, rgba(255, 205, 135, 0.55), transparent 72%),
    radial-gradient(125% 105% at 50% 45%, transparent 52%, rgba(6, 4, 0, 0.55)); }

.room.amb-noturno .room-base { filter: brightness(0.36) saturate(0.72) contrast(1.02); }
.room.amb-noturno .ambient-layer { background: rgba(24, 46, 96, 0.42); }
.room.amb-noturno .ambient-glow { opacity: 1; background: radial-gradient(60% 22% at 50% 100%, rgba(90, 150, 255, 0.28), transparent 70%); }

.room.amb-clinico .room-base { filter: brightness(1.14) contrast(1.05) saturate(0.96); }
.room.amb-clinico .ambient-layer { background: rgba(206, 224, 255, 0.16); }

/* Persiana fechada: ripas horizontais cobrindo a janela (canto sup. esquerdo) */
.blinds { position: absolute; left: 0.6%; top: 1.4%; width: 14.6%; height: 62%; z-index: 1; opacity: 0; transition: opacity 0.5s ease; border-radius: 2px;
  background:
    linear-gradient(rgba(60, 60, 66, 0.55), rgba(40, 40, 46, 0.62)),
    repeating-linear-gradient(0deg, rgba(210, 210, 216, 0.92) 0 5px, rgba(120, 120, 128, 0.92) 5px 8px);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.4); }
.room.persiana-fechada .blinds { opacity: 1; }

/* TV acesa: overlay posicionado sobre a TV da cena (POV consistente) */
.tv-overlay { position: absolute; left: 56.2%; top: 22%; width: 21%; height: 20.8%; opacity: 0; transition: opacity 0.4s ease; z-index: 2; border-radius: 4px; }
.tv-overlay.on { opacity: 1; }
.tv-content {
  position: absolute; inset: 0; border-radius: 4px;
  background:
    linear-gradient(120deg, rgba(90,169,255,0.9), rgba(52,211,194,0.75) 55%, rgba(255,122,122,0.7)),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.06) 0 2px, transparent 2px 4px);
  box-shadow: inset 0 0 18px rgba(0,0,0,0.35);
  animation: tvflick 3.2s infinite alternate;
}
.tv-glow { position: absolute; inset: -18% -14%; border-radius: 10px; background: radial-gradient(closest-side, rgba(90,169,255,0.55), transparent 75%); filter: blur(8px); }
@keyframes tvflick { from { filter: brightness(0.92); } to { filter: brightness(1.08); } }

.emergency-overlay { position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0; transition: opacity 0.3s ease; box-shadow: inset 0 0 120px 10px rgba(255, 77, 79, 0.75); }
.emergency-overlay.on { opacity: 1; animation: emergpulse 1.1s infinite; }
@keyframes emergpulse { 0%,100% { box-shadow: inset 0 0 90px 6px rgba(255,77,79,0.45); } 50% { box-shadow: inset 0 0 150px 16px rgba(255,77,79,0.85); } }

.room-badges { position: absolute; top: 14px; left: 14px; display: flex; gap: 8px; flex-wrap: wrap; z-index: 3; }
.rbadge { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border-radius: 12px; background: rgba(10,16,28,0.6); backdrop-filter: blur(8px); border: 1px solid var(--card-brd); font-size: 12px; color: var(--ink-soft); }
.rbadge b { color: var(--ink); font-weight: 700; }
.rbadge.on { border-color: rgba(52,211,194,0.6); color: #d9fff7; }
.rbadge.on b { color: var(--teal); }
.rbadge.alarm { border-color: rgba(255,77,79,0.7); color: #ffdede; animation: emergpulse 1.1s infinite; }
.rbadge.alarm b { color: var(--crit); }

.vall { position: absolute; left: 18px; right: 18px; bottom: 18px; z-index: 3; display: flex; align-items: flex-end; gap: 14px; }
.vall-orb { position: relative; width: 74px; height: 74px; flex: 0 0 auto; }
.vall-orb img { width: 74px; height: 74px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.35); box-shadow: 0 10px 30px rgba(52,211,194,0.5); }
.ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(52,211,194,0.55); opacity: 0; }
.vall.speaking .ring { animation: ripple 1.8s ease-out infinite; }
.vall.speaking .ring.r2 { animation-delay: 0.6s; } .vall.speaking .ring.r3 { animation-delay: 1.2s; }
@keyframes ripple { 0% { transform: scale(1); opacity: 0.7; } 100% { transform: scale(1.9); opacity: 0; } }
.vall.listening .vall-orb img { border-color: var(--blue); box-shadow: 0 0 30px rgba(90,169,255,0.8); }
.vall-bubble { background: rgba(10,16,28,0.74); backdrop-filter: blur(10px); border: 1px solid var(--card-brd); border-radius: 16px; padding: 12px 15px; max-width: 660px; box-shadow: var(--shadow); }
.vall-name { font-weight: 700; font-size: 13px; margin-bottom: 3px; display: flex; align-items: center; gap: 8px; }
.vall-tag { font-size: 10.5px; font-weight: 600; color: var(--teal); background: rgba(52,211,194,0.15); padding: 2px 8px; border-radius: 999px; }
.vall-bubble p { margin: 0; font-size: 14.5px; line-height: 1.5; }

.talk { display: flex; gap: 12px; margin-top: 16px; }
.mic { display: inline-flex; align-items: center; gap: 10px; padding: 0 18px; height: 52px; border-radius: 14px; cursor: pointer; border: none; color: #04231f; font-weight: 700; font-size: 14px; background: linear-gradient(135deg, var(--teal), var(--teal2)); box-shadow: 0 10px 26px rgba(52,211,194,0.4); transition: transform 0.12s; }
.mic:hover { transform: translateY(-1px); }
.mic.rec { background: linear-gradient(135deg, var(--coral), var(--crit)); color: #fff; animation: micpulse 1.1s infinite; }
@keyframes micpulse { 0%,100% { box-shadow: 0 10px 26px rgba(255,77,79,0.4);} 50% { box-shadow: 0 10px 40px rgba(255,77,79,0.8);} }
.mic-ico { font-size: 18px; }
.say { flex: 1; display: flex; gap: 8px; }
.say input { flex: 1; height: 52px; border-radius: 14px; padding: 0 16px; background: var(--card); border: 1px solid var(--card-brd); color: var(--ink); font-size: 14px; }
.say input::placeholder { color: var(--ink-soft); }
.say input:focus { outline: none; border-color: var(--teal); }
.say button { height: 52px; padding: 0 18px; border-radius: 14px; cursor: pointer; background: var(--card); border: 1px solid var(--card-brd); color: var(--ink); font-weight: 600; }
.say button:hover { border-color: var(--teal); }

.quick { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.quick-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.quick-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--ink-soft); width: 78px; }
.q { padding: 9px 13px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 600; background: var(--card); border: 1px solid var(--card-brd); color: var(--ink); transition: 0.14s; }
.q:hover { border-color: var(--teal); transform: translateY(-1px); }
.q-warn { border-color: rgba(255,176,32,0.5); color: #ffe0a6; }
.q-crit { border-color: rgba(255,77,79,0.55); color: #ffcccc; }
.q-ghost { color: var(--ink-soft); }

/* Ops */
.ops { background: var(--card); border: 1px solid var(--card-brd); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.ops-title { margin: 0; font-size: 16px; }
.ops-sub { margin: 4px 0 14px; color: var(--ink-soft); font-size: 13px; }
.notifs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; min-height: 320px; }
.notif-empty { margin: auto; text-align: center; color: var(--ink-soft); font-size: 12.5px; }
.notif-empty span { font-size: 26px; display: block; margin-bottom: 8px; opacity: 0.7; }

.notif { border-radius: 14px; padding: 12px 13px; background: rgba(255,255,255,0.05); border: 1px solid var(--card-brd); animation: notifin 0.4s cubic-bezier(0.2,0.9,0.3,1.3); }
@keyframes notifin { from { opacity: 0; transform: translateY(-10px) scale(0.97); } to { opacity: 1; transform: none; } }
.notif-head { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--ink-soft); margin-bottom: 5px; }
.notif-app { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ink); }
.notif-badge { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; font-size: 12px; }
.notif-title { font-size: 13.5px; font-weight: 700; margin: 0 0 3px; }
.notif-body { font-size: 12.5px; color: #d7e2f2; margin: 0; line-height: 1.4; }
.notif-time { margin-left: auto; }
.notif.enfermagem { border-left: 3px solid var(--warn); } .notif.enfermagem .notif-badge { background: rgba(255,176,32,0.22); }
.notif.hotelaria { border-left: 3px solid var(--teal); } .notif.hotelaria .notif-badge { background: rgba(52,211,194,0.22); }
.notif.medico { border-left: 3px solid var(--crit); box-shadow: 0 0 0 1px rgba(255,77,79,0.25); } .notif.medico .notif-badge { background: rgba(255,77,79,0.25); } .notif.medico .notif-title { color: #ffd5d5; }

.ops-legend { display: flex; gap: 14px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--card-brd); font-size: 11.5px; color: var(--ink-soft); }
.ops-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.dot.medico { background: var(--crit); } .dot.enfermagem { background: var(--warn); } .dot.hotelaria { background: var(--teal); }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(30px); background: rgba(10,16,28,0.95); border: 1px solid var(--card-brd); color: var(--ink); padding: 11px 18px; border-radius: 12px; font-size: 13.5px; opacity: 0; pointer-events: none; transition: 0.28s; box-shadow: var(--shadow); z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { border-color: rgba(255,77,79,0.6); }
