/* WGO Mobile — frontend */
:root {
  --wgom-nav-h: 62px;
  /* Barra fixa de outro módulo WGO (ex.: WGO Float) — o aviso de instalação fica por cima dela. */
  --wgom-offset: var(--wgo-offset-bottom, 0px);
  --wgom-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Aviso de instalação ---------- */
.wgom-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom) + var(--wgom-offset));
  z-index: 2147483000;
  max-width: 440px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 40px 14px 14px;
  background: #fff;
  color: #0f172a;
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, .22), 0 2px 6px rgba(15, 23, 42, .08);
  font: 14px/1.45 var(--wgom-font);
  text-align: left;
  transform: translateY(calc(100% + 40px));
  opacity: 0;
  transition: transform .4s cubic-bezier(.2, .8, .2, 1), opacity .3s ease;
}
.wgom-banner.is-top {
  top: calc(12px + env(safe-area-inset-top));
  bottom: auto;
  transform: translateY(calc(-100% - 40px));
}
.wgom-banner.is-in { transform: none; opacity: 1; }

.wgom-banner__icon {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.wgom-banner__body { flex: 1 1 auto; min-width: 0; }
.wgom-banner__title { display: block; font-size: 15px; font-weight: 700; margin: 0 0 2px; color: inherit; }
.wgom-banner__text { margin: 0 0 10px; color: #475569; font-size: 13.5px; }
.wgom-banner__text .wgom-ico {
  display: inline-flex;
  vertical-align: -4px;
  margin: 0 2px;
  color: #2563eb;
}
.wgom-banner__actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.wgom-banner__close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
}
.wgom-banner__close:hover { background: #f1f5f9; color: #0f172a; }

.wgom-btn,
.wgom-install-btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--wgom-theme, #0f172a);
  color: var(--wgom-theme-fg, #fff);
  font: 600 14px/1 var(--wgom-font);
  cursor: pointer;
  text-decoration: none;
  box-shadow: none;
}
.wgom-btn--ghost { background: transparent; color: #475569; }
.wgom-btn--ghost:hover { background: #f1f5f9; }

/* Botão do shortcode [wgo_mobile_install] escondido dentro da app */
html.wgom-app .wgo-install-trigger,
html.wgom-app a[href="#wgo-install"] { display: none !important; }

/* ---------- Barra de navegação inferior ---------- */
.wgom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2147482000;
  height: calc(var(--wgom-nav-h) + env(safe-area-inset-bottom));
  padding: 0 4px env(safe-area-inset-bottom);
  background: var(--wgom-nav-bg, #fff);
  border-top: 1px solid rgba(15, 23, 42, .08);
  box-shadow: 0 -6px 24px rgba(15, 23, 42, .06);
  justify-content: space-around;
  align-items: stretch;
}
.wgom-nav a {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px;
  color: var(--wgom-nav-color, #64748b) !important;
  text-decoration: none !important;
  font: 500 11px/1.15 var(--wgom-font);
  letter-spacing: .01em;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.wgom-nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wgom-nav a svg { width: 24px; height: 24px; transition: transform .2s ease; }
.wgom-nav a:active svg { transform: scale(.88); }
.wgom-nav a[aria-current="page"] { color: var(--wgom-nav-active, #0f172a) !important; font-weight: 700; }
.wgom-nav a[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: 0;
  left: 30%;
  right: 30%;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: currentColor;
}

@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
  .wgom-nav { display: flex; }
}
html.wgom-app .wgom-nav { display: flex; }
@media (max-width: 782px) {
  .wgom-nav--mobile { display: flex; }
}
@media print { .wgom-nav, .wgom-back, .wgom-banner { display: none !important; } }

html.wgom-nav-on { --wgom-offset: calc(var(--wgom-nav-h) + env(safe-area-inset-bottom)); }
/* Zonas do ecrã do WGO Core: com a barra da app visível, os outros módulos (Float, Legal…) sobem acima dela. */
html.wgom-nav-on { --wgo-offset-bottom: calc(var(--wgom-nav-h) + env(safe-area-inset-bottom)); }
html.wgom-nav-on body { padding-bottom: calc(var(--wgom-nav-h) + env(safe-area-inset-bottom)) !important; }
html.wgom-nav-on .wgom-banner:not(.is-top) { bottom: calc(12px + var(--wgom-offset)); }

/* ---------- Botão voltar (modo app) ---------- */
.wgom-back {
  display: none;
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 10px;
  z-index: 2147482001;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 23, 42, .55);
  color: #fff;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
}
html.wgom-back-on .wgom-back { display: flex; }

/* ---------- Pesquisa rápida ---------- */
.wgom-search {
  position: fixed;
  inset: 0;
  z-index: 2147483001;
  display: block;
  padding: calc(12px + env(safe-area-inset-top)) 12px 0;
  background: rgba(15, 23, 42, .5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity .2s ease;
}
.wgom-search.is-in { opacity: 1; }
.wgom-search *, .wgom-search *::before, .wgom-search *::after { box-sizing: border-box; }
.wgom-search .wgom-search__form {
  display: flex !important;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 600px;
  margin: 0 auto !important;
  padding: 6px !important;
  border: 0 !important;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 14px 40px rgba(15, 23, 42, .28);
  transform: translateY(-14px);
  transition: transform .25s cubic-bezier(.2, .8, .2, 1);
}
.wgom-search.is-in .wgom-search__form { transform: none; }
.wgom-search .wgom-search__field {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  height: 46px;
  margin: 0;
  padding: 0 4px 0 42px;
  border-radius: 999px;
  background: #f1f5f9;
  transition: box-shadow .15s ease, background .15s ease;
}
.wgom-search .wgom-search__field:focus-within { background: #fff; box-shadow: 0 0 0 2px var(--wgom-theme, #0f172a); }
.wgom-search .wgom-search__ico {
  position: absolute;
  left: 14px;
  top: 50%;
  display: flex;
  color: #64748b;
  transform: translateY(-50%);
  pointer-events: none;
}
.wgom-search input.wgom-search__input {
  flex: 1 1 auto;
  min-width: 0;
  width: auto !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  outline: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #0f172a !important;
  font: 400 16px/1.2 var(--wgom-font) !important;
  -webkit-appearance: none;
  appearance: none;
}
.wgom-search input.wgom-search__input::placeholder { color: #94a3b8; opacity: 1; }
.wgom-search input.wgom-search__input::-webkit-search-cancel-button,
.wgom-search input.wgom-search__input::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.wgom-search button.wgom-search__go,
.wgom-search button.wgom-search__close {
  flex: 0 0 auto;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 38px !important;
  height: 38px !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 50% !important;
  box-shadow: none !important;
  line-height: 1 !important;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s ease, transform .15s ease;
}
.wgom-search button.wgom-search__go { background: var(--wgom-theme, #0f172a) !important; color: var(--wgom-theme-fg, #fff) !important; }
.wgom-search button.wgom-search__go[hidden] { display: none !important; }
.wgom-search button.wgom-search__close { width: 46px !important; height: 46px !important; background: transparent !important; color: #475569 !important; }
.wgom-search button.wgom-search__close:hover, .wgom-search button.wgom-search__close:focus-visible { background: #f1f5f9 !important; }
.wgom-search button:active { transform: scale(.92); }
.wgom-search svg { display: block; width: 20px; height: 20px; }

@media (prefers-reduced-motion: reduce) {
  .wgom-banner, .wgom-search, .wgom-search__form, .wgom-search__field, .wgom-nav a svg { transition: none; }
}

/* ---------- Notificações ---------- */
.wgom-topics { margin: 4px 0 10px; }
.wgom-topics__hint { margin: 0 0 6px; color: #475569; font-size: 13px; }
.wgom-topics { display: flex; flex-wrap: wrap; gap: 6px; }
.wgom-topics__hint { flex: 0 0 100%; }
.wgom-topic {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #f8fafc;
  color: #0f172a;
  font: 500 13px/1.2 var(--wgom-font);
  cursor: pointer;
  user-select: none;
}
.wgom-topic input { width: 16px; height: 16px; margin: 0; accent-color: var(--wgom-theme, #0f172a); }
.wgom-topic:has(input:checked) { border-color: var(--wgom-theme, #0f172a); background: #fff; }
.wgom-topic.is-all { font-weight: 700; }
.wgom-banner--push { max-height: calc(100vh - 40px); overflow: auto; }

.wgom-bell {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom) + var(--wgom-offset));
  z-index: 2147481999;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--wgom-theme, #0f172a);
  color: var(--wgom-theme-fg, #fff);
  box-shadow: 0 6px 20px rgba(15, 23, 42, .25);
  cursor: pointer;
  transition: transform .2s ease, opacity .2s ease;
}
.wgom-bell.is-left { left: 16px; }
.wgom-bell.is-right { right: 16px; }
.wgom-bell:active { transform: scale(.92); }
.wgom-bell.is-on { opacity: .75; }
.wgom-bell.is-on svg path:first-child { fill: currentColor; }
.wgom-bell::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 11px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 2px var(--wgom-theme, #0f172a);
}
.wgom-bell.is-on::after { display: none; }

.wgom-toast {
  position: fixed;
  left: 50%;
  top: calc(16px + env(safe-area-inset-top));
  z-index: 2147483002;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 12px;
  background: #0f172a;
  color: #fff;
  font: 500 14px/1.4 var(--wgom-font);
  box-shadow: 0 10px 30px rgba(15, 23, 42, .3);
  transform: translate(-50%, -20px);
  opacity: 0;
  transition: transform .3s ease, opacity .3s ease;
}
.wgom-toast.is-in { transform: translate(-50%, 0); opacity: 1; }
@media print { .wgom-bell, .wgom-toast { display: none !important; } }

/* ---------- Diagnóstico (?wgom-debug) ---------- */
.wgom-debug {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  z-index: 2147483003;
  max-width: 520px;
  margin: 0 auto;
  max-height: 70vh;
  overflow: auto;
  padding: 12px 14px;
  border-radius: 14px;
  background: #0f172a;
  color: #e2e8f0;
  font: 13px/1.45 var(--wgom-font);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
  text-align: left;
}
.wgom-debug__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.wgom-debug__head button { background: none; border: 0; color: #94a3b8; font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px; }
.wgom-debug ul { list-style: none; margin: 0; padding: 0; }
.wgom-debug li { display: flex; gap: 8px; padding: 5px 0; border-top: 1px solid rgba(255, 255, 255, .07); }
.wgom-debug li b { flex: 0 0 14px; text-align: center; }
.wgom-debug li.ok b { color: #4ade80; }
.wgom-debug li.ko b { color: #f87171; }
.wgom-debug li.info b { color: #60a5fa; }
.wgom-debug__actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; flex-wrap: wrap; }
.wgom-debug .wgom-btn--ghost { color: #cbd5e1; }
