/* Domivo · visual do app (estilo Apple). Tema padrão "Domivo" (azul-marinho), opção "Clara" e "Automática". */

/* Manrope, SIL Open Font License 1.1 (Google Fonts) */
@font-face {
  font-family: 'Manrope';
  src: url('/fonts/manrope-latin.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}
/* Poppins nos títulos (a mesma do DoorVi), SIL Open Font License 1.1 (Google Fonts) */
@font-face { font-family: 'Poppins'; src: url('/fonts/poppins-600-latin.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Poppins'; src: url('/fonts/poppins-700-latin.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --bg: #0d0d0d; --card: #17181a; --card-2: #232528; --sep: rgba(255, 255, 255, 0.08);
  --text: #f4f5f6; --text-2: #b4b8bd; --text-3: #8f9398;
  --accent: #d4d7db; --accent-fill: #c9ccd0; --on-accent: #0d0d0d;
  --silver: linear-gradient(180deg, #eceef0 0%, #c9ccd0 55%, #a9adb2 100%);
  --danger: #ff8d8d; --warn: #fcd34d; --warn-bg: rgba(252, 211, 77, 0.16);
  --tabbar: #111213; --overlay: rgba(0, 0, 0, 0.65);
  --radius: 16px;
  color-scheme: dark;
}
:root[data-theme="clara"] {
  --bg: #f4f5f7; --card: #ffffff; --card-2: #eceef1; --sep: #e2e4e8;
  --text: #111111; --text-2: #565b62; --text-3: #6c7178;
  --accent: #2f3236; --accent-fill: #111111; --on-accent: #f4f5f6;
  --silver: linear-gradient(180deg, #2a2c2f 0%, #111111 100%);
  --danger: #d92d2d; --warn: #8a5300; --warn-bg: #fff3d6;
  --tabbar: #ffffff; --overlay: rgba(0, 0, 0, 0.35);
  color-scheme: light;
}
/* Oceano: os tons da primeira versão do Domivo (azul-marinho e verde-água). */
:root[data-theme="azul"] {
  --bg: #0f2a4a; --card: #17375d; --card-2: #1f4370; --sep: rgba(255, 255, 255, 0.09);
  --text: #ffffff; --text-2: #a9c2df; --text-3: #7f97b5;
  --accent: #5eead4; --accent-fill: #14b8a6; --on-accent: #04342c;
  --silver: linear-gradient(180deg, #5eead4 0%, #14b8a6 100%);
  --danger: #ff8d8d; --warn: #fcd34d; --warn-bg: rgba(252, 211, 77, 0.16);
  --tabbar: #0b2240; --overlay: rgba(2, 10, 22, 0.6);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg: #f4f5f7; --card: #ffffff; --card-2: #eceef1; --sep: #e2e4e8;
    --text: #111111; --text-2: #565b62; --text-3: #6c7178;
    --accent: #2f3236; --accent-fill: #111111; --on-accent: #f4f5f6;
    --silver: linear-gradient(180deg, #2a2c2f 0%, #111111 100%);
    --danger: #d92d2d; --warn: #8a5300; --warn-bg: #fff3d6;
    --tabbar: #ffffff; --overlay: rgba(0, 0, 0, 0.35);
    color-scheme: light;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 400 16px/1.45 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
.large-title, .center-stack h1, .sheet h2, .sheet-head h2, .code-head .name, .row-item .title, .fullscreen .store, .install-card .title {
  font-family: 'Poppins', 'Manrope', system-ui, sans-serif; font-weight: 600;
}
.large-title { font-weight: 700; letter-spacing: -0.4px; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.hidden { display: none !important; }
body.staff .owner-only, body:not(.staff) .staff-only { display: none !important; }
body.no-access .screen, body.no-access .tabbar { display: none !important; }

/* ---- Telas ---- */
.screen { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 14px) 16px calc(96px + env(safe-area-inset-bottom)); }
.topline { display: flex; justify-content: space-between; align-items: center; min-height: 32px; }
.eyebrow { font-size: 14px; color: var(--text-2); }
.large-title { font-size: 34px; font-weight: 700; letter-spacing: -0.6px; line-height: 1.15; margin: 2px 0 6px; }
.section-label { font-size: 13px; color: var(--text-2); margin: 24px 6px 8px; }
.footnote { font-size: 13px; color: var(--text-3); margin: 8px 6px 0; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--card); color: var(--accent); }
.icon-btn svg, .row-item svg, .tab svg { width: 22px; height: 22px; }

/* ---- Grupos e linhas (estilo Ajustes do iPhone) ---- */
.group { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.row-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px; padding: 12px 16px;
  text-align: left; border-bottom: 0.5px solid var(--sep);
}
.row-item:last-child { border-bottom: 0; }
.row-item .grow { flex: 1; min-width: 0; }
.row-item .title { font-size: 16px; font-weight: 600; }
.row-item .sub { font-size: 13px; color: var(--text-2); }
.row-item .value { font-size: 15px; color: var(--text-2); }
.row-item .chev { color: var(--text-3); width: 16px; height: 16px; flex: none; }
.row-item.action { color: var(--accent); font-weight: 600; }
.row-item.danger { color: var(--danger); font-weight: 600; }
.row-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--card-2); color: var(--accent); }
.row-icon svg { width: 18px; height: 18px; }
.row-icon.g-icon { background: #fff; }
.row-item .pill { flex: none; }
button.row-item:active, .code-item:active { background: var(--card-2); }

/* ---- Cartão de código ---- */
.code-item { display: block; width: 100%; text-align: left; padding: 14px 16px 12px; border-bottom: 0.5px solid var(--sep); }
.code-item:last-child { border-bottom: 0; }
.code-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.code-head .name { font-size: 16px; font-weight: 700; }
.code-value { font-size: 30px; font-weight: 600; letter-spacing: 6px; margin: 6px 0 4px; }
.code-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.code-foot .copy { color: var(--accent); font-weight: 700; padding: 6px 0 6px 12px; }
.pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; background: var(--accent-fill); color: var(--on-accent); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.soft { background: var(--card-2); color: var(--text-2); }
.returns { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--text-2); }
.returns li { padding: 2px 0; }
.empty { text-align: center; padding: 34px 16px; color: var(--text-2); }
.empty strong { display: block; color: var(--text); font-size: 18px; margin-bottom: 6px; }

/* ---- Botões e campos ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 18px; border-radius: 14px; font-weight: 700; background: var(--card-2); color: var(--text); }
.btn-primary { background: var(--accent-fill); color: var(--on-accent); }
.btn-block { width: 100%; }
a.btn { text-decoration: none; }
.btn:active { transform: scale(0.98); }
.link { color: var(--accent); font-weight: 700; }
input[type=text], input[type=password], input[type=tel], textarea {
  width: 100%; font: inherit; font-size: 17px; color: var(--text); background: var(--card-2);
  border: 0; border-radius: 12px; padding: 13px 14px; outline: none;
}
input::placeholder { color: var(--text-3); }
input:focus, textarea:focus { box-shadow: 0 0 0 2px var(--accent-fill); }
.field-label { display: block; font-size: 13px; color: var(--text-2); margin: 14px 4px 6px; }
.error { color: var(--danger); font-size: 14px; min-height: 1.2em; margin-top: 8px; }
.inline-form { display: flex; gap: 8px; padding: 12px; }
.inline-form input { flex: 1; }
.inline-form .btn { min-height: 48px; }
textarea { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

/* Controle segmentado (Aparência) */
.segmented { display: flex; background: var(--card-2); border-radius: 10px; padding: 3px; margin: 12px; }
.segmented button { flex: 1; padding: 8px 4px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--text-2); }
.segmented button.on { background: var(--card); color: var(--text); }

/* ---- Barra de abas ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: space-around;
  background: var(--tabbar); border-top: 0.5px solid var(--sep); padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
}
.tab { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--text-3); }
.tab.on { color: var(--accent); }

/* ---- Painéis que sobem de baixo e telas sobrepostas ---- */
.overlay { position: fixed; inset: 0; z-index: 20; background: var(--overlay); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--bg);
  border-radius: 22px 22px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); animation: rise 0.22s ease-out;
}
.sheet .grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--text-3); opacity: 0.5; margin: 0 auto 12px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.sheet-head h2 { margin: 0; font-size: 20px; }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }

.fullscreen { position: fixed; inset: 0; z-index: 30; background: var(--bg); display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top) + 14px) 18px calc(20px + env(safe-area-inset-bottom)); }
.fullscreen .middle { flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center; }
.fullscreen .caption { font-size: 14px; color: var(--text-2); }
.fullscreen .store { font-size: 22px; font-weight: 700; margin: 4px 0 22px; }

/* Código letra por letra */
.code-big { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 360px; margin: 0 auto; }
.code-big span {
  position: relative; display: grid; place-items: center; height: 72px; border-radius: 12px;
  background: var(--card); font-size: 36px; font-weight: 700;
}
.code-big span.zero::after { content: ""; position: absolute; width: 3px; height: 46%; background: currentColor; transform: rotate(35deg); border-radius: 2px; }
.code-big.small span { height: 52px; font-size: 26px; }

/* Bloqueio, conexão e instalação */
.center-stack { max-width: 420px; margin: 0 auto; text-align: center; padding: calc(env(safe-area-inset-top) + 40px) 20px 30px; }
.app-mark { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto 16px; display: block; }
.center-stack h1 { font-size: 26px; margin: 0 0 6px; }
.center-stack p { color: var(--text-2); margin: 0 0 20px; }
.pair-input { text-align: center; font-size: 26px !important; letter-spacing: 4px; font-weight: 700; }
.install-card { display: flex; gap: 14px; align-items: center; padding: 14px 16px; margin-top: 12px; }
.install-card img { width: 48px; height: 48px; border-radius: 12px; flex: none; }
.install-steps { list-style: none; padding: 0; margin: 14px 0; counter-reset: passo; }
.install-steps li { counter-increment: passo; position: relative; padding: 14px 14px 14px 56px; margin-bottom: 10px; background: var(--card); border-radius: 14px; }
.install-steps li::before { content: counter(passo); position: absolute; left: 14px; top: 12px; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-fill); color: var(--on-accent); font-weight: 700; display: grid; place-items: center; }
.install-steps .ico { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 6px; border-radius: 8px; background: var(--card-2); font-weight: 700; }

/* Chave liga/desliga (estilo iPhone) */
.switch { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 16px; background: var(--card-2); position: relative; flex: none; cursor: pointer; transition: background 0.15s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
.switch:checked { background: var(--accent-fill); }
.switch:checked::after { transform: translateX(20px); }
label.row-item { cursor: pointer; }

/* Recados da campainha */
.recado-card { background: var(--card); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.recado-card .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.recado-card .head strong { font-size: 15px; }
.recado-card textarea { font-family: inherit; font-size: 15px; resize: vertical; }
.warn-text { color: var(--warn); }

/* Vídeo da chamada (app e placa) */
.video-wrap { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 3 / 4; margin: 12px 0 14px; }
.video-wrap video.remote { width: 100%; height: 100%; object-fit: cover; }
.video-wrap video.local { position: absolute; right: 10px; bottom: 10px; width: 28%; border-radius: 12px; border: 2px solid rgba(255, 255, 255, 0.7); object-fit: cover; }
.video-wrap .placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #cfd8e6; text-align: center; padding: 20px; }

/* Tela da campainha no app */
.call-screen { overflow-y: auto; z-index: 35; }
/* flex-shrink 0: com o vídeo aberto, a tela rola em vez de espremer até sumir a parte "Responder" (código, recado). */
.call-screen > * { width: 100%; max-width: 560px; margin-left: auto; margin-right: auto; flex-shrink: 0; }
.call-screen .video-wrap { max-height: 55vh; }
.call-screen .large-title { margin-bottom: 8px; }
.ring-photo { display: block; width: 100%; max-height: 42vh; object-fit: cover; border-radius: var(--radius); margin: 14px 0; }
.call-buttons { display: grid; gap: 10px; margin-top: 14px; }
.print-img { width: 100%; border-radius: var(--radius); margin-bottom: 8px; }

/* Aviso rápido */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 14px; padding: 11px 16px; border-radius: 14px;
  max-width: calc(100% - 32px); text-align: center;
}

/* ---- Histórico de visitas ---- */
.visit-thumb {
  flex: none; width: 46px; height: 46px; border-radius: 12px; overflow: hidden;
  display: grid; place-items: center; background: var(--card-2); color: var(--text-3);
}
.visit-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.visit-photo-big { width: 100%; border-radius: var(--radius); background: var(--card-2); min-height: 200px; object-fit: contain; display: block; }

/* ---- Aviso importante no topo (ex.: Gmail desconectado) ---- */
.alert-card {
  display: flex; flex-direction: column; gap: 8px; margin-top: 12px; padding: 16px;
  border-radius: var(--radius); background: var(--warn-bg); color: var(--text);
}
.alert-card strong { color: var(--warn); font-size: 17px; }
.alert-card .btn { background: var(--accent-fill); color: var(--on-accent); margin-top: 4px; }

/* ---- Devolução do ML: esperando (contorno) x entregue (preenchido em prata) ---- */
.pill.pending { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1.5px var(--text-2); }
.pill.done { background: var(--silver); color: var(--on-accent); }
.code-item.pending { box-shadow: inset 4px 0 0 var(--card-2); }
.code-item.done { box-shadow: inset 4px 0 0 var(--accent-fill); }

/* ---- Primeiros passos ---- */
.setup-card { margin-top: 12px; padding: 14px 16px 6px; border-radius: var(--radius); background: var(--card); }
.setup-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.setup-head strong { font-family: 'Poppins', system-ui, sans-serif; font-size: 18px; }
.setup-head span { font-size: 13px; color: var(--text-2); }
.setup-step { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 0.5px solid var(--sep); }
.setup-step:first-child { border-top: 0; }
.setup-step .dot { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--card-2); color: var(--text-2); }
.setup-step.ok .dot { background: var(--silver); color: var(--on-accent); }
.setup-step.ok .txt { color: var(--text-2); text-decoration: line-through; }
.setup-step .txt { flex: 1; font-size: 15px; }
.setup-step .txt small { display: block; font-size: 12px; color: var(--text-3); text-decoration: none; }
.setup-step .btn { min-height: 36px; padding: 0 14px; font-size: 14px; background: var(--accent-fill); color: var(--on-accent); }

/* ---- Preto e prata: botão principal com brilho de metal escovado ---- */
.btn-primary, .setup-step .btn, .alert-card .btn { background: var(--silver); color: var(--on-accent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35); }

/* ---- Entrada (trava): sempre preto e prata, com o logo ---- */
#lock {
  --bg: #0d0d0d; --card: #17181a; --card-2: #232528; --text: #f4f5f6; --text-2: #b4b8bd; --text-3: #8f9398;
  --accent: #d4d7db; --accent-fill: #c9ccd0; --on-accent: #0d0d0d; --danger: #ff8d8d;
  --silver: linear-gradient(180deg, #eceef0 0%, #c9ccd0 55%, #a9adb2 100%);
  background: var(--bg); color: var(--text);
}
/* A porta: só o contorno maior, o olho mágico e o puxador (inspirada na Caixa Black). */
#lock.fullscreen { padding: calc(env(safe-area-inset-top) + 14px) 14px calc(14px + env(safe-area-inset-bottom)); }
.door-scene {
  flex: 1; display: flex; flex-direction: column; border: 1px solid #6f7378; border-radius: 10px;
  padding: 9% 12% 0; box-sizing: border-box; min-height: 0;
}
.door {
  position: relative; flex: 1; min-height: 300px;
}
.peephole {
  position: absolute; left: 50%; top: 20%; transform: translate(-50%, -50%);
  width: 132px; height: 132px; border-radius: 50%; padding: 0; background: none;
}
.peephole img { width: 100%; height: 100%; display: block; transition: transform 0.55s cubic-bezier(0.34, 1.45, 0.5, 1); }
@media (prefers-reduced-motion: reduce) { .peephole img { transition: none; } }
.peephole:active { transform: translate(-50%, -50%) scale(0.96); }
.door-handle {
  position: absolute; right: 2%; top: 44%; width: 1px; height: 26%; background: #6f7378; /* mesmo traço da borda da porta */
}
.door-sill { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 22px 0 18px; }
.lock-brand { display: flex; align-items: flex-start; gap: 2px; opacity: 0.6; margin-top: 10px; }
.lock-word { width: 62px; height: auto; display: block; }
.lock-mark-tm { font-size: 7px; line-height: 1; color: var(--text-3); margin-top: -2px; }
.pin-forgot { font-size: 12px; color: var(--text-3); padding: 6px 10px; text-decoration: underline; text-underline-offset: 3px; }

.lock-hint { margin: 0; font-size: 13px; letter-spacing: 0.02em; color: var(--text-3); text-align: center; min-height: 18px; }
.pin-dots { position: relative; display: flex; justify-content: center; padding: 6px 12px; cursor: text; }
.pin-dots input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; font-size: 16px; border: 0; background: none; color: transparent; }
.pin-dots span { display: flex; gap: 14px; }
.pin-dots i { width: 9px; height: 9px; border-radius: 50%; box-shadow: inset 0 0 0 1px #8f9398; }
.pin-dots i.on { background: var(--silver); box-shadow: none; }
.pin-dots.wrong span { animation: pin-shake 0.35s; }
.pin-dots.wrong i.on { background: #ff8d8d; }
@keyframes pin-shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* Entrando: a cena cresce a partir do olho mágico (origem calculada no app.js), como quem atravessa a lente;
   a porta sai pelas bordas, a lente se dissolve e o app aparece do outro lado. */
#lock { transition: background-color 0.5s 0.45s; }
#lock.opening { background-color: transparent; pointer-events: none; }
#lock.opening .door-scene { animation: door-through 0.95s 0.2s cubic-bezier(0.6, 0, 0.9, 0.35) forwards; }
#lock.opening .peephole img { animation: lens-fade 0.6s 0.45s ease-out forwards; }
@keyframes door-through { 55% { opacity: 1; } to { transform: scale(16); opacity: 0; } }
@keyframes lens-fade { to { opacity: 0; filter: blur(6px); } }

/* Brilho discreto: um reflexo de metal passa pelos botões do que ainda falta configurar. */
.shine { position: relative; overflow: hidden; isolation: isolate; }
.shine::after {
  content: ''; position: absolute; inset: -20% auto -20% -60%; width: 45%; z-index: 1; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.75), transparent);
  transform: skewX(-18deg); animation: shine 4.2s var(--shine-delay, 0s) ease-in-out infinite;
}
:root[data-theme="clara"] .shine::after { background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.45), transparent); }
@keyframes shine { 0%, 72% { left: -60%; } 100% { left: 130%; } }
@media (prefers-reduced-motion: reduce) { .shine::after { animation: none; display: none; } }

/* "Testar": treme de leve, como uma campainha tocando, a cada poucos segundos. */
.buzz { animation: buzz 3.6s 1.2s ease-in-out infinite; }
@keyframes buzz {
  0%, 78%, 100% { transform: none; }
  80% { transform: rotate(-4deg); } 83% { transform: rotate(4deg); } 86% { transform: rotate(-3deg); }
  89% { transform: rotate(3deg); } 92% { transform: rotate(-1.5deg); } 95% { transform: rotate(0); }
}
@media (prefers-reduced-motion: reduce) { .buzz { animation: none; } }
