@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --color-paper: #F5F1E8;
  --color-paper-raised: #FBF9F3;
  --color-ink: #1F2A1C;
  --color-olive: #3D5C3A;
  --color-olive-dark: #2C4429;
  --color-earth: #8B6F47;
  --color-earth-light: #D9CBB0;
  --color-amber: #C9862F;
  --color-amber-dark: #A3691F;
  --color-terracotta: #B5433E;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body);
  overscroll-behavior-y: none;
}

body {
  min-height: 100dvh;
  min-height: 100vh;
}

h1, h2, h3, h4, .font-display {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

.font-mono { font-family: var(--font-mono); }

/* Focus visibility */
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--color-amber);
  outline-offset: 2px;
}

/* Scrollbars minimal */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--color-earth-light); border-radius: 4px; }

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 1500;
  background: var(--color-paper-raised);
  border-top: 1px solid var(--color-earth-light);
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
}

/* Botão de ação flutuante sobre um mapa em tela cheia: fica acima da
   bottom nav fixa (que sobrepõe o mapa) em vez de colado nela. */
.fab-above-bottom-nav {
  bottom: calc(env(safe-area-inset-bottom) + 88px);
}
@media (min-width: 1024px) {
  .fab-above-bottom-nav {
    bottom: 16px;
  }
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px 6px;
  color: var(--color-earth);
  font-size: 11px;
  font-weight: 500;
  min-height: 56px;
}

.bottom-nav-item.active {
  color: var(--color-olive-dark);
}

.bottom-nav-item.active .bottom-nav-icon {
  background: var(--color-olive);
  color: white;
}

.bottom-nav-icon {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  transition: background .15s ease;
}

/* ---------- Bottom sheet ---------- */
.bottom-sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(31,42,28,0.45);
  z-index: 1900;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.bottom-sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.bottom-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1901;
  background: var(--color-paper-raised);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px rgba(31,42,28,0.2);
  max-height: 86dvh;
  transform: translateY(100%);
  transition: transform .25s cubic-bezier(.32,.72,0,1);
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-sheet.open { transform: translateY(0); }

.bottom-sheet-handle {
  width: 40px; height: 4px;
  background: var(--color-earth-light);
  border-radius: 4px;
  margin: 10px auto 4px;
}

/* ---------- Custom map pins ---------- */
.pin-badge {
  width: 34px; height: 34px;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(31,42,28,0.35);
  border: 2px solid var(--color-paper-raised);
}
.pin-badge svg, .pin-badge img { transform: rotate(45deg); }
.pin-badge.pin-acude { background: #2E6E8E; }
.pin-badge.pin-outro { background: var(--color-olive); }

.pin-user-location {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #2E6E8E;
  border: 3px solid white;
  box-shadow: 0 0 0 4px rgba(46,110,142,0.25);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  white-space: nowrap;
}
.badge-olive { background: #E4EBDF; color: var(--color-olive-dark); }
.badge-amber { background: #F5E4CB; color: var(--color-amber-dark); }
.badge-terracotta { background: #F4DEDC; color: var(--color-terracotta); }
.badge-neutral { background: var(--color-earth-light); color: var(--color-earth); }
.badge-blue { background: #DCEAF1; color: #2E6E8E; }

/* ---------- Skeleton ---------- */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}
.skeleton {
  background: var(--color-earth-light);
  border-radius: 8px;
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}

/* ---------- Toasts ---------- */
#toast-container {
  position: fixed;
  top: max(env(safe-area-inset-top), 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 24px);
  max-width: 420px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--color-ink);
  color: var(--color-paper);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(31,42,28,0.3);
  display: flex; align-items: center; gap: 10px;
  animation: toast-in .2s ease;
}
.toast.toast-error { background: var(--color-terracotta); }
.toast.toast-success { background: var(--color-olive-dark); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Misc ---------- */
.tap-target { min-height: 44px; min-width: 44px; }

/* Indica visualmente que uma linha de chips/abas rola horizontalmente,
   esmaecendo o conteúdo perto das bordas em vez de cortá-lo abruptamente. */
.tab-scroll-fade {
  -webkit-mask-image: linear-gradient(to right, transparent 0, black 16px, black calc(100% - 16px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, black 16px, black calc(100% - 16px), transparent 100%);
}

.card {
  background: var(--color-paper-raised);
  border: 1px solid var(--color-earth-light);
  border-radius: 16px;
}

.input-field {
  width: 100%;
  background: var(--color-paper-raised);
  border: 1.5px solid var(--color-earth-light);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  color: var(--color-ink);
}
.input-field:focus {
  border-color: var(--color-olive);
  outline: none;
}

.btn-primary {
  background: var(--color-olive);
  color: white;
  font-weight: 600;
  border-radius: 12px;
  transition: background .15s ease;
}
.btn-primary:active { background: var(--color-olive-dark); }

.btn-amber {
  background: var(--color-amber);
  color: white;
  font-weight: 600;
  border-radius: 12px;
}
.btn-amber:active { background: var(--color-amber-dark); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--color-earth-light);
  color: var(--color-ink);
  font-weight: 600;
  border-radius: 12px;
}

.btn-danger {
  background: transparent;
  border: 1.5px solid var(--color-terracotta);
  color: var(--color-terracotta);
  font-weight: 600;
  border-radius: 12px;
}

/* Sync status dot */
.sync-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.sync-dot.synced { background: var(--color-olive); }
.sync-dot.pending { background: var(--color-amber); }
.sync-dot.error { background: var(--color-terracotta); }

/* MapLibre control tweaks */
.maplibregl-map { font-family: var(--font-body); }
.maplibregl-popup-content { border-radius: 12px; padding: 10px 12px; }
.maplibregl-ctrl-group { border-radius: 10px; overflow: hidden; box-shadow: 0 2px 6px rgba(31,42,28,0.2); }
.maplibregl-ctrl-group button { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; }
.map-layer-toggle button { background: #FBF9F3; }

/* ---------- Shell mobile: altura de viewport travada via flexbox ----------
   Header (altura natural) + main (flex:1, rola internamente) em vez de um
   documento que cresce livremente. Isso permite que qualquer página use
   h-full para genuinamente preencher "o resto da tela", sem calc(100dvh -
   Npx) chutado — a causa do mapa geral quebrar quando o header mudou de
   altura. Restrito ao mobile; desktop mantém o scroll de documento normal. */
.app-shell {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-shell > header {
  flex-shrink: 0;
}

.app-shell > #shell-content {
  flex: 1;
  min-height: 0; /* permite que overflow-y:auto funcione dentro do flex item */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Desktop sidebar — mesmo breakpoint do Tailwind (md sobrescrito para 1024px),
   assim celulares grandes em paisagem continuam com a bottom nav mobile. */
@media (min-width: 1024px) {
  .app-shell {
    height: auto;
    display: block;
    overflow: visible;
    padding-left: 250px;
  }
  .app-shell > #shell-content {
    overflow: visible;
  }
  .bottom-nav { display: none; }
}
