/* Oferflux — camada mobile / app nativo.
   Só acrescenta comportamento; no computador nada muda além de detalhes de conforto. */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --nav-height: 64px;
  --app-bg: #0f172a;
  --app-accent: #34d399;
}

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; }

/* ---------- Celular ---------- */
@media (max-width: 767px) {
  /* 16px evita o zoom automático do iPhone/Android ao tocar no campo */
  input, select, textarea { font-size: 16px !important; }

  /* Alvos de toque confortáveis */
  button, .btn, input[type="submit"], input[type="button"], select { min-height: 44px; }
  input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
  input[type="url"], input[type="number"], input[type="search"], input[type="datetime-local"] { min-height: 44px; }

  /* Espaço para a barra inferior não cobrir o conteúdo */
  body.has-bottom-nav .app-main {
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  }

  /* Tabelas largas rolam de lado em vez de estourar a tela */
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ---------- Modo aplicativo (instalado na tela inicial) ---------- */
@media (display-mode: standalone) {
  html, body { overscroll-behavior-y: none; }
  body { padding-top: var(--safe-top); padding-left: var(--safe-left); padding-right: var(--safe-right); }
  /* sem seleção de texto acidental em botões/menus, como num app nativo */
  .bottom-nav, button { -webkit-user-select: none; user-select: none; }
}

/* ---------- Barra inferior (só em telas pequenas) ---------- */
.bottom-nav { display: none; }

@media (max-width: 767px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
    background: rgba(15, 23, 42, 0.97);
    border-top: 1px solid #1e293b;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
  }
}

.bottom-nav a {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
}
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a[aria-current="page"] { color: var(--app-accent); }
.bottom-nav a:active { opacity: 0.7; }

/* ---------- Aviso de sem internet ---------- */
.pwa-offline {
  position: fixed;
  top: calc(var(--safe-top) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  max-width: calc(100% - 24px);
  padding: 10px 16px;
  border-radius: 999px;
  background: #c2410c;
  color: #ffffff;
  font: 600 14px/1.3 system-ui, -apple-system, "Segoe UI", sans-serif;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  text-align: center;
}

/* ---------- Convite "Instalar app" ---------- */
.install-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--safe-bottom) + 12px);
  z-index: 55;
  max-width: 440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 14px;
  border-radius: 16px;
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.35);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (max-width: 767px) {
  body.has-bottom-nav .install-banner { bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px); }
}
.install-banner img { width: 44px; height: 44px; border-radius: 10px; flex: none; }
.install-banner__body { flex: 1 1 auto; min-width: 0; }
.install-banner__title { margin: 0 0 2px; font-size: 15px; font-weight: 700; }
.install-banner__text { margin: 0; font-size: 13px; line-height: 1.4; color: #475569; }
.install-banner__action {
  flex: none;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: #047857;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.install-banner__close {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #475569;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.install-banner__close:hover { background: #f1f5f9; }
