/* PWA Demo — mobile-first, sem framework */

:root {
  --bg: #0b0d12;
  --surface: #141822;
  --surface-2: #1c2130;
  --line: #262d3d;
  --text: #eef1f7;
  --muted: #98a2b8;
  --accent: #6ea8fe;
  --accent-ink: #0b0d12;
  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #f87171;
  --topbar-h: 52px;
  --tabbar-h: 60px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #eef1f7;
    --line: #dde3ee;
    --text: #131722;
    --muted: #5b6577;
    --accent: #2563eb;
    --accent-ink: #ffffff;
    --ok: #16a34a;
    --warn: #b45309;
    --err: #dc2626;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* ── topbar ── */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand img { border-radius: 7px; }

.pill {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
}

.pill.is-online { color: var(--ok); }
.pill.is-offline { color: var(--err); }

/* ── layout ── */
main {
  padding: calc(var(--topbar-h) + env(safe-area-inset-top) + 20px) 16px
           calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px);
  max-width: 640px;
  margin: 0 auto;
}

.screen { display: none; animation: fade .18s ease both; }
.screen.is-active { display: block; }

@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
}

h1 {
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

h2 {
  font-size: 15px;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
}

.lead { color: var(--muted); margin: 0 0 20px; }
.muted { color: var(--muted); font-size: 14px; }

p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 5px;
}

/* ── card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
}

/* ── botões ── */
.btn {
  appearance: none;
  width: 100%;
  min-height: 46px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: transform .08s ease, opacity .15s ease;
}

.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.row { display: flex; gap: 8px; }
.row .btn { flex: 1; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.card > .btn + .out-line,
.card > .row + .out-line,
.card > .grid + .out-line { margin: 12px 0 0; }

/* ── status ── */
.status {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 14px;
  margin: 0;
  font-size: 14px;
}

.status dt { color: var(--muted); }
.status dd { margin: 0; text-align: right; font-weight: 600; }
.status dd.ok { color: var(--ok); }
.status dd.warn { color: var(--warn); }
.status dd.err { color: var(--err); }

/* ── saídas ── */
.out, .out-line {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0 0;
  word-break: break-word;
}

.out {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px;
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
}

.out-line:empty { display: none; }
.out-line.ok { color: var(--ok); }
.out-line.err { color: var(--err); }

/* ── formulários ── */
textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  font-size: 16px; /* < 16px faz o iOS dar zoom */
  padding: 12px;
  resize: vertical;
  margin-bottom: 10px;
}

textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

details { margin-top: 12px; font-size: 14px; }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; }
details ol { margin: 10px 0 0; padding-left: 20px; color: var(--muted); }
details li { margin-bottom: 6px; }

ul.checks { margin: 0; padding-left: 0; list-style: none; }

ul.checks li {
  position: relative;
  padding-left: 24px;
  margin-bottom: 8px;
  font-size: 15px;
}

ul.checks li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 8px;
  width: 10px;
  height: 6px;
  border-left: 2px solid var(--ok);
  border-bottom: 2px solid var(--ok);
  transform: rotate(-45deg);
}

/* ── câmera ── */
.cam-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 3 / 4;
  margin-bottom: 10px;
}

.cam-wrap video,
.cam-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── tabbar ── */
.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.tab {
  appearance: none;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  padding: 0;
}

.tab svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab.is-active { color: var(--accent); }
.tab:active { opacity: .6; }

/* ── bottom sheet (modais) ── */
.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

/* Sem isto o display:flex acima vence o [hidden] do navegador (regra de autor
   sempre ganha da user-agent) e o modal fica visível pra sempre. */
.sheet-wrap[hidden] { display: none; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / .55);
  animation: sheet-fade .2s ease both;
}

.sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  text-align: center;
  animation: sheet-up .26s cubic-bezier(.22, 1, .36, 1) both;
}

.sheet-grip {
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  margin: 0 auto 16px;
}

.sheet-icon { border-radius: 14px; margin-bottom: 12px; }
.sheet-emoji { font-size: 42px; line-height: 1; margin-bottom: 10px; }

.sheet h2 { font-size: 20px; letter-spacing: -0.02em; margin: 0 0 8px; }

.sheet-text {
  color: var(--muted);
  font-size: 14.5px;
  margin: 0 0 18px;
}

.sheet-steps {
  text-align: left;
  color: var(--muted);
  font-size: 14.5px;
  margin: 0 0 18px;
  padding-left: 22px;
}

.sheet-steps li { margin-bottom: 8px; }

.sheet .btn + .btn { margin-top: 8px; }

.btn-ghost {
  background: none;
  border-color: transparent;
  color: var(--muted);
  font-weight: 500;
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: none; }
}

@keyframes sheet-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-backdrop { animation: none; }
}

/* ── toast ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  transform: translateX(-50%);
  z-index: 30;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  max-width: 88vw;
  text-align: center;
  box-shadow: 0 8px 24px rgb(0 0 0 / .25);
}
