/* VsysIO Web — visual replicado do app FMX (azul #008DEF, tabs inferiores, listas) */
:root {
  --blue: #008DEF;
  --crimson: #DC143C;
  --bg: #FFFFFF;
  --bg2: #F5F6F8;
  --text: #2B2B2B;
  --text2: #778899;       /* lightslategray, como no app */
  --text3: #9AA4AE;
  --line: #D3D3D3;        /* lightgray */
  --card: #FFFFFF;
  --header-bg: #EFF1F4;
  --toast: #CD5C5C;       /* indianred */
}
body.dark {
  --bg: #1F2226;
  --bg2: #16181B;
  --text: #E8E8E8;
  --text2: #9FB0C0;
  --text3: #7C868F;
  --line: #3A3F45;
  --card: #26292E;
  --header-bg: #2C3036;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #3a3f44;
  color: var(--text);
}

/* moldura tipo celular no desktop */
#app {
  position: relative;
  max-width: 420px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 24px rgba(0,0,0,.45);
}

/* ===== Toolbar ===== */
.toolbar {
  position: relative;
  flex: 0 0 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  z-index: 5;
}
.tb-logo { height: 34px; }
.tb-icon {
  position: absolute; left: 8px; top: 8px;
  width: 32px; height: 32px; cursor: pointer;
}
.tb-title { font-size: 17px; color: var(--text2); }
.backbtn {
  position: absolute; left: 4px; top: 0;
  width: 44px; height: 47px;
  border: 0; background: none;
  font-size: 34px; line-height: 40px;
  color: var(--blue);
  cursor: pointer;
}
.spinner {
  position: absolute; right: 12px; top: 14px;
  width: 20px; height: 20px;
  border: 3px solid rgba(0,141,239,.25);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Abas / conteúdo ===== */
#tabs { flex: 1; overflow: hidden; position: relative; }
.tab { position: absolute; inset: 0; overflow-y: auto; background: var(--bg); display: flex; flex-direction: column; }
.tab[hidden] { display: none; }

.subbar {
  flex: 0 0 48px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--text2);
  border-bottom: 1px solid var(--line);
  position: relative;
}
.msg-bar .msg-actions { position: absolute; right: 8px; display: flex; align-items: center; gap: 8px; }

#localmode-banner img { width: 100%; display: block; }

/* ===== Listas ===== */
.list { flex: 1 1 auto; overflow-y: auto; }
.list-header {
  padding: 6px 12px 4px;
  font-size: 12px; font-weight: 600;
  color: var(--text2);
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
}
.list-footer {
  padding: 8px 12px 4px;
  font-size: 12px; font-weight: 600;
  color: var(--text3);
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
}
.item {
  display: flex; align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  min-height: 58px;
  gap: 8px;
  background: var(--card);
}
.item:active { background: var(--bg2); }

/* item de dispositivo (aba início) */
.dev-texts { flex: 1; min-width: 0; }
.dev-name { font-size: 14px; font-weight: 600; }
.dev-extra { font-size: 12px; color: var(--text2); margin-top: 1px; }
.dev-id { font-size: 11px; color: var(--text3); margin-top: 1px; }
.dev-dot { width: 14px; height: 14px; border-radius: 50%; flex: 0 0 14px; }
.dev-dot.on { background: #34C759; }
.dev-dot.off { background: #B8BEC4; }
.dev-opts { width: 26px; height: 26px; flex: 0 0 26px; padding: 4px; }

/* linhas da tela do dispositivo */
.drow { min-height: 26px; cursor: default; padding: 4px 12px; }
.drow-2col { display: flex; }
.drow-2col span { flex: 1; font-size: 13px; color: var(--text); }
.drow-2col span:last-child { color: var(--text2); }
.drow-2col.offline span { color: #E53935 !important; }
.drow-sensor { display: flex; align-items: center; }
.drow-sensor .sname { flex: 1; text-align: right; font-size: 13px; padding-right: 10px; }
.drow-sensor .sval { flex: 0 0 95px; font-size: 14px; font-weight: 600; color: var(--blue); }
.drow-io { display: flex; align-items: center; justify-content: flex-end; min-height: 52px; gap: 10px; }
.drow-io .ioname { flex: 1; text-align: right; font-size: 13px; }
.iobtn { width: 44px; height: 44px; cursor: pointer; transition: transform .08s; }
.iobtn:active { transform: scale(.9); }
body.big .iobtn { width: 64px; height: 64px; }
body.big .drow-io { min-height: 76px; }

/* mensagens */
.msg-item { display: block; min-height: 0; }
.msg-line1 { display: flex; align-items: baseline; }
.msg-title { flex: 1; font-size: 14px; font-weight: 600; }
.msg-dh { font-size: 11px; color: var(--text2); }
.msg-text { font-size: 13px; color: var(--text); margin-top: 3px; white-space: pre-wrap; }
.msg-del { float: right; width: 26px; height: 26px; margin-left: 8px; }

/* histórico / eventos */
.hist-item { display: block; min-height: 0; padding: 6px 12px; cursor: default; }
.hist-dh { font-size: 11px; color: var(--text2); }
.hist-text { font-size: 13px; }

/* cadastro / novo dispositivo (lista clique-para-preencher) */
.cad-item { display: flex; align-items: center; min-height: 54px; }
.cad-texts { flex: 1; }
.cad-label { font-size: 14px; }
.cad-value { font-size: 12px; color: #1668c9; margin-top: 2px; }
.cad-value.empty { color: var(--text3); }
.cad-check { color: var(--blue); font-size: 20px; width: 26px; text-align: center; }

/* alexa */
.alexa-head { padding: 10px 14px; font-size: 13px; color: var(--text2); border-bottom: 1px solid var(--line); }
.alexa-toggle { width: 52px; height: 32px; flex: 0 0 52px; cursor: pointer; }

/* ===== Config ===== */
.cfg-list { padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.cfg-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; background: var(--card);
  font-size: 13px;
}
.cfg-item span { flex: 1; }
.cfg-item .blue { color: var(--blue); font-weight: 600; }
.cfg-click { cursor: pointer; }
.cfg-click:active { background: var(--bg2); }

.cfg-card {
  margin: 10px; padding: 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card);
  display: flex; flex-direction: column; gap: 8px;
}
.cfg-label { font-size: 13px; font-weight: 600; }
.cfg-sublabel { font-size: 12px; color: var(--text2); }
.cfg-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.cfg-times { display: flex; gap: 10px; }
.cfg-times > div { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.cfg-times label { font-size: 11px; color: var(--text2); }
.editdev-bottom { margin-top: auto; padding: 10px; }

/* ===== Inputs / botões ===== */
input[type=text], input[type=password], input[type=email], input[type=time] {
  width: 100%;
  border: 0; border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 15px;
  padding: 9px 4px;
  outline: none;
}
input:focus { border-bottom-color: var(--blue); }

.btn {
  display: block; width: 100%;
  border: 0; border-radius: 8px;
  padding: 12px;
  font-size: 15px; font-weight: 600;
  color: #fff; cursor: pointer;
  margin-top: 6px;
}
.btn-blue { background: var(--blue); }
.btn-blue:active { background: #0077CC; }
.btn-red { background: #E53935; }
.btn-red:active { background: #C62828; }

.flatbtn {
  border: 0; background: none;
  color: var(--text2); font-size: 14px;
  cursor: pointer; padding: 6px 8px;
  text-decoration: none;
}
.flatbtn.blue { color: var(--blue); font-weight: 600; }
.iconbtn { width: 28px; height: 28px; cursor: pointer; }
.iconbtn.active { filter: drop-shadow(0 0 3px var(--blue)); }

/* switch estilo mobile */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: 0 0 46px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0;
  background: #B8BEC4; border-radius: 26px;
  transition: .2s; cursor: pointer;
}
.slider:before {
  content: ""; position: absolute;
  width: 20px; height: 20px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%;
  transition: .2s;
}
.switch input:checked + .slider { background: var(--blue); }
.switch input:checked + .slider:before { transform: translateX(20px); }

/* ===== Tab bar inferior ===== */
#tabbar {
  flex: 0 0 56px;
  display: flex;
  position: relative;
  border-top: 1px solid var(--line);
  background: var(--bg);
  z-index: 5;
}
.tabbtn {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px; cursor: pointer;
  opacity: .6; position: relative;
}
.tabbtn.active { opacity: 1; }
.tabbtn img { width: 22px; height: 22px; }
.tabbtn label { font-size: 10px; color: var(--blue); font-weight: 600; cursor: pointer; }
.tabline {
  position: absolute; top: -1px; left: 0;
  width: 56px; height: 2.5px;
  background: var(--blue); border-radius: 2px;
  transition: left .3s;
}
.badge {
  position: absolute; top: 6px; right: calc(50% - 20px);
  width: 10px; height: 10px;
  background: var(--crimson); border-radius: 50%;
}

/* ===== Telas sobrepostas ===== */
.screen {
  position: absolute; inset: 0;
  background: var(--bg);
  z-index: 20;
  display: flex; flex-direction: column;
  animation: slidein .22s ease;
}
.screen[hidden] { display: none; }
@keyframes slidein { from { transform: translateX(30%); opacity: .4; } to { transform: none; opacity: 1; } }

.login-tab { flex: 1; display: flex; flex-direction: column; overflow-y: auto; }
.login-tab[hidden] { display: none; }
.login-box { padding: 26px 22px; display: flex; flex-direction: column; gap: 14px; }
.login-link { color: var(--blue); font-size: 13px; text-align: center; cursor: pointer; margin-top: 4px; }
.login-info { font-size: 10px; color: var(--text3); text-align: center; word-break: break-all; cursor: pointer; }
.login-action { width: auto; margin: 10px 22px 16px; }
.logoff { position: absolute; right: 6px; }
.edit-box { padding-top: 40px; }

#web-frame { flex: 1; border: 0; width: 100%; }
#web-newtab { position: absolute; right: 8px; color: var(--blue); }

/* ===== Modal / Toast ===== */
.modal-bg {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
}
.modal-bg[hidden] { display: none; }
.modal {
  background: var(--card); border-radius: 12px;
  min-width: 240px; max-width: 90%;
  padding: 22px 18px 10px;
  box-shadow: 0 6px 28px rgba(0,0,0,.35);
}
.modal p { font-size: 15px; text-align: center; }
.modal-btns { display: flex; justify-content: flex-end; gap: 6px; margin-top: 16px; }

#toast {
  position: absolute; z-index: 50;
  left: 14px; right: 14px; bottom: 72px;
  background: var(--toast); color: #fff;
  font-size: 14px;
  padding: 12px 14px; border-radius: 8px;
  box-shadow: 0 3px 14px rgba(0,0,0,.3);
  animation: slidein .2s ease;
}
#toast[hidden] { display: none; }

.pull-hint {
  text-align: center; padding: 14px;
  color: var(--text3); font-size: 13px; cursor: pointer;
}
.empty-hint { text-align: center; padding: 30px 16px; color: var(--text3); font-size: 13px; }
