@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Nunito:wght@400;600;700;800;900&display=swap');

:root {
  --vermelho:     #C8102E;
  --vermelho-dk:  #A00D24;
  --dourado:      #B8860B;
  --bg:           #FAFAFA;
  --surface:      #FFFFFF;
  --border:       #E8E8E8;
  --text:         #1A1A1A;
  --cinza:        #888888;
  --cinza-claro:  #F4F4F4;
  --verde:        #2D6A2D;
  --danger:       #C0392B;
  --shadow:       0 2px 12px rgba(0,0,0,0.08);
  --shadow-md:    0 4px 20px rgba(0,0,0,0.12);
  --radius:       12px;
  --radius-lg:    16px;
  --nav-height:   68px;
  --nav-width:    220px;
  --z-nav:        999;
  --z-notif:      3000;
  --z-splash:     9999;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* FIX 1 — Android Chrome: dvh sem suporte trava a splash.
   Cadeia de fallback: -webkit-fill-available → 100vh → 100dvh */
html {
  height: -webkit-fill-available;
}
body {
  min-height: 100vh;
  min-height: -webkit-fill-available;
  height: 100dvh;
  overflow: hidden;
  font-family: 'Nunito', sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
a { color: inherit; }
button { font-family: inherit; }
input, textarea { font-family: inherit; }

/* FIX 5 — Android Chrome: splash independente da altura do body.
   Troca right/bottom por width/height explícitos. */
#splashApp {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: linear-gradient(160deg, #1A0008, #6B0018, #C8102E);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: var(--z-splash);
  transition: opacity 0.4s;
}

/* FIX 2 — iOS Safari: fallback explícito antes de dvh */
.page {
  display: none;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  overflow: hidden;
}

.page-header {
  background: var(--surface);
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

/* FIX 3 — iOS Safari: a barra tampava o conteúdo porque height da nav
   não incluía a safe-area — só o padding-bottom não basta. */
.nav-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: var(--z-nav);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--cinza);
  font-size: 0.68rem;
  font-weight: 800;
  font-family: 'Nunito', sans-serif;
  transition: color 0.15s, transform 0.1s;
  position: relative;
  overflow: hidden;
}
.nav-btn i { font-size: 1.4rem; line-height: 1; }
.nav-btn.ativo { color: var(--vermelho); }
.nav-btn:active { transform: scale(0.92); }

.bar-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  border-left: 4px solid var(--vermelho);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  position: relative;
  overflow: hidden;
}
.bar-card:active { transform: scale(0.98); box-shadow: 0 1px 6px rgba(0,0,0,0.08); }
.bar-card-nome { font-weight: 900; font-size: 0.9rem; color: var(--text); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-card-promo { font-size: 0.75rem; color: var(--vermelho); font-weight: 700; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-card-end { font-size: 0.72rem; color: var(--cinza); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.bar-card-dist { display: inline-flex; align-items: center; gap: 3px; font-size: 0.68rem; color: var(--cinza); font-weight: 700; margin-top: 6px; background: var(--cinza-claro); padding: 2px 8px; border-radius: 10px; }
.bar-card-visitado { position: absolute; top: 10px; right: 12px; background: var(--verde); color: white; font-size: 0.62rem; font-weight: 800; padding: 2px 8px; border-radius: 10px; }

.btn-primary { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px; border-radius: var(--radius); background: var(--vermelho); color: white; border: none; font-size: 0.95rem; font-weight: 800; font-family: 'Nunito', sans-serif; cursor: pointer; transition: background 0.15s, transform 0.1s; }
.btn-primary:active { background: var(--vermelho-dk); transform: scale(0.98); }
.btn-outline { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 13px; border-radius: var(--radius); background: white; color: var(--vermelho); border: 2px solid var(--vermelho); font-size: 0.9rem; font-weight: 800; font-family: 'Nunito', sans-serif; cursor: pointer; }

.filtro-btn { padding: 7px 14px; border-radius: 20px; font-size: 0.75rem; font-weight: 800; font-family: 'Nunito', sans-serif; cursor: pointer; border: 1.5px solid var(--border); background: white; color: var(--cinza); white-space: nowrap; transition: all 0.15s; flex-shrink: 0; }
.filtro-btn.ativo, .filtro-btn:active { background: var(--vermelho); color: white; border-color: var(--vermelho); }

.estrela { color: var(--dourado); font-size: 1.2rem; }
.aba-ranking { background: white; color: var(--cinza); transition: background 0.15s, color 0.15s; }
.aba-ranking.ativo { background: var(--vermelho); color: white; }

.ranking-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.ranking-pos { font-family: 'Bebas Neue', cursive; font-size: 1.4rem; color: var(--cinza); min-width: 32px; text-align: center; }
.ranking-pos.top-1 { color: #FFD700; }
.ranking-pos.top-2 { color: #C0C0C0; }
.ranking-pos.top-3 { color: #CD7F32; }
.ranking-nome { flex: 1; font-weight: 900; font-size: 0.88rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ranking-nota { font-weight: 900; font-size: 0.9rem; color: var(--vermelho); text-align: right; }
.ranking-sub { font-size: 0.7rem; color: var(--cinza); font-weight: 700; text-align: right; }

.notif {
  position: fixed;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 12px);
  left: 16px; right: 16px;
  background: var(--vermelho); color: white;
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 0.88rem; font-weight: 700;
  z-index: var(--z-notif);
  opacity: 0; transform: translateY(12px);
  transition: opacity 0.22s, transform 0.22s;
  pointer-events: none; box-shadow: var(--shadow-md); text-align: center;
}
.notif.show { opacity: 1; transform: translateY(0); }
.notif.erro { background: #C0392B; }
.notif.ok { background: var(--verde); }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 24px; color: var(--cinza); text-align: center; }
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.4; }
.empty p { font-size: 0.88rem; font-weight: 700; opacity: 0.7; }

.leaflet-popup-content-wrapper { border-radius: var(--radius) !important; box-shadow: var(--shadow-md) !important; padding: 0 !important; overflow: hidden; }
.leaflet-popup-content { margin: 0 !important; }
.leaflet-popup-tip-container { display: none; }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.filtros-scroll::-webkit-scrollbar { display: none; }

.text-vermelho { color: var(--vermelho); }
.text-cinza    { color: var(--cinza); }
.font-heavy    { font-weight: 900; }
.bebas         { font-family: 'Bebas Neue', cursive; }

/* FIX 4 — padding-bottom agora cobre a altura real da nav (que cresceu no Fix 3) */
.scroll-safe {
  padding-bottom: calc(var(--nav-height) + 24px + env(safe-area-inset-bottom, 0px));
}

/* ── MOBILE médio ── */
@media (min-width: 480px) and (max-width: 767px) {
  body { max-width: 440px; margin: 0 auto; box-shadow: 0 0 40px rgba(0,0,0,0.12); }
  .nav-bar { max-width: 440px; left: 50%; transform: translateX(-50%); }
  .notif { max-width: 408px; left: 50%; transform: translateX(-50%) translateY(12px); }
  .notif.show { transform: translateX(-50%) translateY(0); }
}

/* ── TABLET + DESKTOP: nav lateral ── */
@media (min-width: 768px) {
  body { display: flex; overflow: hidden; background: #ebebeb; }

  /* Nav lateral não tem safe-area-inset-bottom — resetar */
  .nav-bar {
    position: fixed;
    top: 0; left: 0; bottom: 0; right: unset;
    width: var(--nav-width);
    height: 100dvh;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: 0;
    padding-top: 8px;
    border-top: none;
    border-right: 1px solid var(--border);
    box-shadow: 2px 0 12px rgba(0,0,0,0.06);
  }

  .nav-bar::before {
    content: 'AMSTEL BH';
    font-family: 'Bebas Neue', cursive;
    font-size: 1.4rem;
    color: var(--vermelho);
    letter-spacing: 2px;
    padding: 16px 24px 20px;
    border-bottom: 1px solid var(--border);
    display: block;
    width: 100%;
    margin-bottom: 8px;
  }

  .nav-btn {
    flex: unset;
    width: 100%;
    flex-direction: row;
    justify-content: flex-start;
    padding: 14px 24px;
    gap: 12px;
    font-size: 0.82rem;
    border-radius: 0;
  }
  .nav-btn i { font-size: 1.25rem; }
  .nav-btn:active { transform: none; background: var(--cinza-claro); }
  .nav-btn.ativo { background: rgba(200,16,46,0.06); }

  .page {
    margin-left: var(--nav-width);
    width: calc(100vw - var(--nav-width));
    height: 100dvh;
  }

  .notif {
    left: calc(var(--nav-width) + 16px);
    right: 16px;
    bottom: 16px;
  }

  /* Desktop: scroll-safe sem safe-area */
  .scroll-safe {
    padding-bottom: 24px;
  }
}

/* ── DESKTOP ── */
@media (min-width: 1024px) {
  :root { --nav-width: 260px; }

  .nav-btn { padding: 16px 28px; font-size: 0.88rem; }
  .page-header { padding: 20px 24px 16px; }

  .bar-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .notif { max-width: 500px; }
}