/* Luzes LIPS — mesma identidade do PontoLips (vermelho #B41B24, Montserrat nos títulos, Open Sans no texto).
   Toda cor vem das variáveis abaixo (valores iguais a app/src/tema/paletas.ts do PontoLips). */

@font-face { font-family: "Montserrat"; font-weight: 600; font-display: swap; src: url("/fontes/Montserrat-SemiBold.ttf"); }
@font-face { font-family: "Montserrat"; font-weight: 700; font-display: swap; src: url("/fontes/Montserrat-Bold.ttf"); }
@font-face { font-family: "Open Sans"; font-weight: 400; font-display: swap; src: url("/fontes/OpenSans-Regular.ttf"); }
@font-face { font-family: "Open Sans"; font-weight: 600; font-display: swap; src: url("/fontes/OpenSans-SemiBold.ttf"); }

:root {
  color-scheme: light dark;
  --fundo: #F6F6F7;
  --superficie: #FFFFFF;
  --superficie-alt: #F0F0F2;
  --borda: #E3E3E6;
  --texto: #17171A;
  --texto-secundario: #5F6068;
  --marca: #B41B24;
  --marca-texto: #B41B24;
  --marca-suave: #FBEAEB;
  --sucesso: #1E7B45;
  --sucesso-suave: #E6F4EC;
  --perigo: #B3261E;
  --perigo-suave: #FDECEA;
  --luz: #E9A200;          /* lâmpada acesa */
  --luz-suave: #FFF6DC;
  --sombra: 0 1px 2px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.05);
  --raio: 14px;
  --titulo: "Montserrat", system-ui, sans-serif;
  --corpo: "Open Sans", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #0E0E10;
    --superficie: #18181B;
    --superficie-alt: #222226;
    --borda: #2E2E33;
    --texto: #F2F2F3;
    --texto-secundario: #A3A3AB;
    --marca-texto: #F06A71;
    --marca-suave: #3A1517;
    --sucesso: #4CC38A;
    --sucesso-suave: #12301F;
    --perigo: #FF7A70;
    --perigo-suave: #3A1714;
    --luz: #FFC23D;
    --luz-suave: #33280C;
    --sombra: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  background: var(--fundo);
  color: var(--texto);
  font: 400 15px/1.45 var(--corpo);
  -webkit-tap-highlight-color: transparent;
}
h1, h2, strong { font-family: var(--titulo); font-weight: 700; }
h1 { font-size: 22px; margin: 8px 0 4px; }
h2 { font-size: 15px; margin: 0 0 12px; }
.secundario { color: var(--texto-secundario); }
.erro { color: var(--perigo); background: var(--perigo-suave); padding: 10px 12px; border-radius: 10px; margin: 12px 0 0; }

.cartao {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  padding: 16px;
  margin-bottom: 16px;
}
.cartao-cabecalho { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cartao-cabecalho h2 { margin: 0; }

/* Botões */
.botao {
  font: 600 15px var(--corpo);
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  color: var(--texto);
  background: transparent;
}
.botao.primario { background: var(--marca); color: #fff; width: 100%; padding: 12px; margin-top: 8px; }
.botao.contorno { border: 1.5px solid var(--borda); background: var(--superficie); width: 100%; padding: 12px; }
.botao.discreto { padding: 8px 12px; color: var(--marca-texto); }
.botao:disabled { opacity: 0.6; cursor: default; }
.botao:focus-visible, .luz:focus-visible, .filtro button:focus-visible { outline: 2px solid var(--marca-texto); outline-offset: 2px; }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-cartao { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 4px; }
.login-logo { height: 52px; width: auto; align-self: flex-start; }
.login-cartao p { margin: 0 0 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; margin-bottom: 8px; }
input {
  font: 400 16px var(--corpo);
  color: var(--texto);
  background: var(--superficie-alt);
  border: 1px solid var(--borda);
  border-radius: 10px;
  padding: 11px 12px;
}

/* Topo e abas */
.topo {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--superficie);
  border-bottom: 1px solid var(--borda);
}
.topo-simbolo { width: 32px; height: 32px; border-radius: 8px; }
.topo-titulo { flex: 1; display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.topo-titulo strong { font-size: 17px; }
.topo-titulo span { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.abas {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 2;
  display: flex;
  background: var(--superficie);
  border-top: 1px solid var(--borda);
  padding-bottom: env(safe-area-inset-bottom);
}
.abas a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 10px; font-size: 12px; font-weight: 600;
  color: var(--texto-secundario); text-decoration: none;
}
.abas svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.abas a[aria-current="page"] { color: var(--marca-texto); }

.conteudo { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(88px + env(safe-area-inset-bottom)); }

@media (min-width: 900px) {
  .abas { position: sticky; top: 53px; bottom: auto; border-top: 0; border-bottom: 1px solid var(--borda); justify-content: center; gap: 8px; padding: 0; }
  .abas a { flex: 0 0 auto; flex-direction: row; gap: 8px; padding: 12px 20px; font-size: 14px; border-bottom: 2px solid transparent; }
  .abas a[aria-current="page"] { border-bottom-color: var(--marca); }
  .abas svg { width: 18px; height: 18px; }
  .conteudo { padding-bottom: 32px; }
}

/* Conexão com o interruptor */
.conexao { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--texto-secundario); margin-bottom: 12px; }
.conexao::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--sucesso); flex: none; }
.conexao.offline { color: var(--perigo); background: var(--perigo-suave); padding: 10px 12px; border-radius: 10px; }
.conexao.offline::before { background: var(--perigo); }

/* Cartões das luzes */
.luzes { display: grid; gap: 12px; margin-bottom: 16px; }
.luz {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  width: 100%; text-align: left; cursor: pointer;
  font: inherit; color: inherit;
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  padding: 16px;
  transition: background 0.2s, border-color 0.2s;
}
.luz.ligada { background: var(--luz-suave); border-color: var(--luz); }
.luz:disabled { cursor: default; }
.luz:disabled:not(.enviando) { opacity: 0.6; } /* sem conexão: é o último estado conhecido */
.luz-icone {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--superficie-alt); color: var(--texto-secundario);
}
.luz.ligada .luz-icone { background: var(--luz); color: #3A2A00; box-shadow: 0 0 18px var(--luz); }
.luz-icone svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.luz.ligada .luz-icone svg path:first-child { fill: currentColor; fill-opacity: 0.25; }
.luz-textos { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.luz-nome { font-family: var(--titulo); font-weight: 700; font-size: 16px; }
.luz-estado { font-weight: 600; }
.luz-detalhe { font-size: 13px; color: var(--texto-secundario); }

.chave { width: 48px; height: 28px; border-radius: 999px; background: var(--borda); position: relative; flex: none; transition: background 0.2s; }
.chave::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform 0.2s; }
.luz.ligada .chave { background: var(--marca); }
.luz.ligada .chave::after { transform: translateX(20px); }
.luz.enviando .chave { opacity: 0.5; }
.luz.enviando .luz-estado::after { content: "…"; }

/* Histórico */
.navegar-dia { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.navegar-dia .botao { font-size: 24px; line-height: 1; padding: 6px 14px; }
.dia-escolhido { position: relative; flex: 1; text-align: center; margin: 0; font-family: var(--titulo); font-size: 16px; cursor: pointer; }
.dia-escolhido input { position: absolute; inset: 0; opacity: 0; cursor: pointer; padding: 0; }

.tempo-linha { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin-bottom: 14px; }
.tempo-nome { font-weight: 600; font-size: 14px; }
.tempo-total { font-size: 13px; color: var(--texto-secundario); text-align: right; }
.trilho { grid-column: 1 / -1; position: relative; height: 18px; border-radius: 4px; background: var(--superficie-alt); }
.trilho .periodo { position: absolute; top: 0; bottom: 0; min-width: 3px; border-radius: 4px; background: var(--marca); }
.trilho .periodo::before { content: ""; position: absolute; inset: -8px 0; } /* área de toque maior */
.trilho .agora { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--texto); border-radius: 1px; }
.trilho .futuro { position: absolute; top: 0; bottom: 0; right: 0; border-radius: 0 4px 4px 0;
  background: repeating-linear-gradient(135deg, transparent 0 4px, var(--borda) 4px 5px); }
.horas { position: relative; height: 16px; font-size: 11px; color: var(--texto-secundario); margin-top: -4px; }
.horas span { position: absolute; transform: translateX(-50%); }
.horas span:first-child { transform: none; }
.horas span:last-child { transform: translateX(-100%); }

.filtro { display: flex; flex-wrap: wrap; gap: 6px; }
.filtro button {
  font: 600 13px var(--corpo); color: var(--texto-secundario);
  background: var(--superficie-alt); border: 1px solid var(--borda); border-radius: 999px;
  padding: 5px 12px; cursor: pointer;
}
.filtro button[aria-pressed="true"] { background: var(--marca-suave); color: var(--marca-texto); border-color: transparent; }

.eventos { list-style: none; margin: 0; padding: 0; }
.eventos li { display: grid; grid-template-columns: 64px 14px 1fr; gap: 10px; align-items: baseline; padding: 10px 0; border-top: 1px solid var(--borda); }
.eventos li:first-child { border-top: 0; }
.eventos time { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--texto-secundario); }
.eventos .ponto { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--texto-secundario); align-self: center; }
.eventos .ponto.on { background: var(--luz); border-color: var(--luz); }
.eventos .ponto.sistema { border-style: dashed; }
.eventos .origem { display: block; font-size: 13px; color: var(--texto-secundario); }
.vazio { color: var(--texto-secundario); text-align: center; padding: 16px 0; margin: 0; }

.resumo-luz { margin-bottom: 18px; }
.resumo-luz:last-child { margin-bottom: 0; }
.resumo-cabecalho { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.resumo-cabecalho span:first-child { font-weight: 600; }
.resumo-cabecalho span:last-child { color: var(--texto-secundario); font-size: 13px; }
.barras { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; align-items: end; height: 72px; border-bottom: 1px solid var(--borda); }
.barras .coluna { height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: default; }
.barras .barra { width: min(28px, 70%); background: var(--marca); border-radius: 4px 4px 0 0; }
.barras .coluna.hoje .barra { background: var(--marca-texto); }
.dias { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; font-size: 11px; color: var(--texto-secundario); text-align: center; margin-top: 4px; }

.dica {
  position: fixed; z-index: 10; pointer-events: none;
  background: var(--texto); color: var(--fundo);
  font-size: 13px; padding: 6px 10px; border-radius: 8px; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px));
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
