/* ============================================================================
   HYBRID ATHLETE — Design System
   Dark mode atlético: verde de performance + dourado/âmbar de "conquista líquida".
   Glassmorphism, mobile-first, animações suaves, navegação inferior nativa.
   ============================================================================ */

/* ---------------------------------------------------------------------------
   1. Design tokens
   --------------------------------------------------------------------------- */
:root {
  /* Superfícies */
  --bg-base: #0a0e0c;
  --bg-elevated: #101613;
  --bg-elevated-2: #151d19;
  --bg-gradient: radial-gradient(120% 120% at 50% -10%, #16261d 0%, #0a0e0c 55%);

  /* Verde atlético (primária) */
  --green-50: #e6fff2;
  --green-300: #5cf2a6;
  --green-400: #2ee88a;
  --green-500: #00e676;
  --green-600: #00c766;
  --green-700: #009651;
  --green-glow: rgba(0, 230, 118, 0.35);

  /* Dourado / âmbar (accent "cerveja") */
  --gold-300: #ffd873;
  --gold-400: #ffc94d;
  --gold-500: #f5a623;
  --gold-600: #d68910;
  --gold-glow: rgba(245, 166, 35, 0.35);

  /* Neutros / texto */
  --text-primary: #f4f7f5;
  --text-secondary: #a9b8b0;
  --text-tertiary: #6f8079;
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glass-strong: rgba(255, 255, 255, 0.14);

  /* Estado */
  --danger: #ff5c72;
  --info: #4fb8ff;

  /* Glass */
  --glass-bg: rgba(21, 29, 25, 0.55);
  --glass-bg-strong: rgba(21, 29, 25, 0.78);
  --glass-blur: blur(18px);

  /* Espaçamento */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 14px;
  --space-lg: 20px;
  --space-xl: 28px;
  --space-2xl: 40px;

  /* Raios */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-pill: 999px;

  /* Sombra */
  --shadow-soft: 0 8px 30px rgba(0, 0, 0, 0.35);
  --shadow-glow-green: 0 8px 24px var(--green-glow);
  --shadow-glow-gold: 0 8px 24px var(--gold-glow);

  /* Tipografia */
  --font-sans: "Plus Jakarta Sans", "Inter", -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;

  /* Nav inferior */
  --nav-height: 74px;
  --topbar-height: 64px;

  /* Transições */
  --ease-smooth: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------------------------------------------------------------------------
   2. Reset & base
   --------------------------------------------------------------------------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  color-scheme: dark;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
}

input,
select {
  font-family: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: var(--green-glow);
  color: var(--text-primary);
}

/* Scrollbar discreto */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-thumb {
  background: var(--border-glass-strong);
  border-radius: var(--radius-pill);
}

.icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.icon-sm {
  width: 16px;
  height: 16px;
}
.icon-lg {
  width: 30px;
  height: 30px;
}

/* ---------------------------------------------------------------------------
   3. App shell
   --------------------------------------------------------------------------- */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: var(--bg-gradient);
  background-attachment: fixed;
  isolation: isolate;
}

/* Textura de fundo subtil (grão + brilho verde no topo) */
#app::before {
  content: "";
  position: fixed;
  inset: 0;
  max-width: 480px;
  margin: 0 auto;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(60% 40% at 85% 0%, var(--gold-glow) 0%, transparent 60%),
    radial-gradient(50% 30% at 10% 0%, var(--green-glow) 0%, transparent 60%);
  opacity: 0.35;
}

.screen {
  position: relative;
  z-index: 1;
  padding: var(--space-lg) var(--space-lg) calc(var(--nav-height) + var(--space-2xl));
  min-height: 100vh;
  animation: screenIn 0.42s var(--ease-smooth);
}

.screen[hidden] {
  display: none !important;
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-sm);
  padding-bottom: var(--space-lg);
}

.topbar__title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.topbar__subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 2px;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 800;
  font-size: 1.05rem;
}

.brand__mark {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--green-500), var(--green-700));
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  box-shadow: var(--shadow-glow-green);
}

/* ---------------------------------------------------------------------------
   4. Navegação inferior (estilo app nativa)
   --------------------------------------------------------------------------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
}

.bottom-nav__inner {
  width: 100%;
  max-width: 480px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: var(--nav-height);
  padding: 0 var(--space-sm) env(safe-area-inset-bottom, 0);
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--border-glass);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.4);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  padding: var(--space-sm) 0;
  color: var(--text-tertiary);
  transition: color 0.25s var(--ease-smooth), transform 0.25s var(--ease-bounce);
  position: relative;
}

.nav-item span {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.nav-item.is-active {
  color: var(--green-400);
  transform: translateY(-2px);
}

.nav-item.is-active .icon {
  filter: drop-shadow(0 0 8px var(--green-glow));
}

.nav-item__dot {
  position: absolute;
  top: 2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold-400);
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s var(--ease-bounce);
}
.nav-item__dot.is-visible {
  opacity: 1;
  transform: scale(1);
}

/* ---------------------------------------------------------------------------
   5. Glassmorphism cards & superfícies genéricas
   --------------------------------------------------------------------------- */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
}

.glass-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent 40%);
  pointer-events: none;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: var(--space-xl) 0 var(--space-md);
}

.section-title h2 {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.section-title a,
.section-title button.link,
button.link {
  font-size: 0.8rem;
  color: var(--green-400);
  font-weight: 700;
}

/* ---------------------------------------------------------------------------
   6. Botões
   --------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 14px 22px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.95rem;
  transition: transform 0.18s var(--ease-bounce), box-shadow 0.25s var(--ease-smooth),
    filter 0.2s ease, background 0.2s ease;
  white-space: nowrap;
  user-select: none;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, var(--green-400), var(--green-600));
  color: #06210f;
  box-shadow: var(--shadow-glow-green);
}
.btn-primary:hover {
  filter: brightness(1.08);
}
.btn-primary:disabled {
  opacity: 0.45;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold-400), var(--gold-600));
  color: #2b1900;
  box-shadow: var(--shadow-glow-gold);
}

.btn-glass {
  background: var(--glass-bg);
  border: 1px solid var(--border-glass-strong);
  color: var(--text-primary);
  backdrop-filter: var(--glass-blur);
}
.btn-glass:hover {
  border-color: var(--green-500);
}

.btn-ghost {
  color: var(--text-secondary);
  padding: 10px 14px;
}
.btn-ghost:hover {
  color: var(--text-primary);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 50%;
  background: var(--glass-bg);
  border: 1px solid var(--border-glass-strong);
  display: grid;
  place-items: center;
}
.btn-icon:active {
  transform: scale(0.9);
}

/* ---------------------------------------------------------------------------
   7. Toasts
   --------------------------------------------------------------------------- */
.toast-stack {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  padding: 0 var(--space-lg);
}

.toast {
  pointer-events: auto;
  max-width: 440px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-glass-strong);
  box-shadow: var(--shadow-soft);
  animation: toastIn 0.4s var(--ease-bounce);
  font-size: 0.88rem;
  font-weight: 600;
}

.toast.is-leaving {
  animation: toastOut 0.3s var(--ease-smooth) forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
}

.toast__icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 0.85rem;
}
.toast--success .toast__icon {
  background: var(--green-glow);
  color: var(--green-400);
}
.toast--warning .toast__icon {
  background: var(--gold-glow);
  color: var(--gold-400);
}
.toast--error .toast__icon {
  background: rgba(255, 92, 114, 0.25);
  color: var(--danger);
}
.toast--info .toast__icon {
  background: rgba(79, 184, 255, 0.2);
  color: var(--info);
}

/* ---------------------------------------------------------------------------
   8. Ecrã Rota / Mapa
   --------------------------------------------------------------------------- */
.hero-card {
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.hero-card__row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: rgba(0, 230, 118, 0.14);
  color: var(--green-400);
}
.status-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green-400);
  box-shadow: 0 0 8px var(--green-400);
  animation: pulse 1.8s infinite;
}
.status-pill.is-off {
  background: rgba(255, 92, 114, 0.14);
  color: var(--danger);
}
.status-pill.is-off .dot {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.distance-selector {
  margin: var(--space-lg) 0;
}

.distance-selector__label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-sm);
}

.distance-selector__value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--green-400);
}

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  background: var(--glass-bg);
  border: 1px solid var(--border-glass-strong);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  transition: all 0.2s var(--ease-smooth);
}

.chip.is-active {
  background: linear-gradient(135deg, var(--green-400), var(--green-600));
  color: #06210f;
  border-color: transparent;
  box-shadow: var(--shadow-glow-green);
}

.address-search-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-tertiary);
  padding: 4px 0;
  margin-bottom: var(--space-sm);
  transition: color 0.2s var(--ease-smooth);
}
.address-search-toggle:hover,
.address-search-toggle:active {
  color: var(--green-400);
}

.address-search-panel {
  margin-bottom: var(--space-md);
  animation: screenIn 0.3s var(--ease-smooth);
}
.address-search-panel__input {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass-strong);
  color: var(--text-primary);
  font-size: 0.85rem;
}
.address-search-panel__input:focus {
  outline: none;
  border-color: var(--green-400);
}
.address-search-panel__results {
  margin-top: 8px;
  max-height: 220px;
  overflow-y: auto;
  border-radius: var(--radius-md);
}
.address-result-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-glass);
  transition: background 0.15s var(--ease-smooth);
}
.address-result-item:last-child {
  border-bottom: none;
}
.address-result-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}
.address-result-item--empty {
  color: var(--text-tertiary);
  font-style: italic;
}

.stat-tile--clickable {
  cursor: pointer;
  transition: transform 0.15s var(--ease-smooth), background 0.15s var(--ease-smooth);
}
.stat-tile--clickable:hover {
  background: rgba(255, 255, 255, 0.06);
}
.stat-tile--clickable:active {
  transform: scale(0.95);
}

input[type="range"].slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: var(--radius-pill);
  background: linear-gradient(
    90deg,
    var(--green-500) 0%,
    var(--green-500) var(--fill, 50%),
    rgba(255, 255, 255, 0.1) var(--fill, 50%)
  );
  margin-top: var(--space-md);
}

input[type="range"].slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 4px solid var(--green-500);
  box-shadow: var(--shadow-glow-green);
  cursor: pointer;
  transition: transform 0.15s var(--ease-bounce);
}
input[type="range"].slider::-webkit-slider-thumb:active {
  transform: scale(1.15);
}
input[type="range"].slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 4px solid var(--green-500);
  cursor: pointer;
}

#map {
  width: 100%;
  height: 320px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-soft);
  background: var(--bg-elevated);
  position: relative;
  z-index: 0;
}

.map-wrap {
  position: relative;
  margin-bottom: var(--space-lg);
}

.map-overlay-btn {
  position: absolute;
  z-index: 500;
  top: 12px;
  right: 12px;
}

/* Popups do Leaflet ajustados ao tema */
.leaflet-popup-content-wrapper {
  background: var(--bg-elevated-2);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass-strong);
}
.leaflet-popup-tip {
  background: var(--bg-elevated-2);
}
.leaflet-container {
  font-family: var(--font-sans);
  background: var(--bg-elevated) !important;
}

/* Marcadores customizados do mapa */
.user-marker-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--green-400);
  border: 3px solid #06210f;
  box-shadow: 0 0 0 6px rgba(0, 230, 118, 0.22), 0 0 14px var(--green-glow);
  position: relative;
}
.user-marker-dot::after {
  content: "";
  position: absolute;
  inset: -11px;
  border-radius: 50%;
  border: 2px solid var(--green-400);
  opacity: 0.55;
  animation: radarPing 1.8s infinite ease-out;
}
@keyframes radarPing {
  0% {
    transform: scale(0.4);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.9);
    opacity: 0;
  }
}

.bar-marker {
  width: 36px;
  height: 36px;
  border-radius: 50% 50% 50% 0;
  background: linear-gradient(135deg, var(--gold-400), var(--gold-600));
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow-gold);
  border: 2px solid rgba(255, 255, 255, 0.35);
}
.bar-marker span {
  transform: rotate(45deg);
  font-size: 1.1rem;
}

.leaflet-popup-content b {
  color: var(--gold-400);
}

.route-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.stat-tile {
  padding: var(--space-md);
  text-align: center;
}

.stat-tile__value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
}
.stat-tile__value.gold {
  color: var(--gold-400);
}
.stat-tile__value.green {
  color: var(--green-400);
}

.stat-tile__label {
  font-size: 0.68rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.contingency-banner {
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: linear-gradient(120deg, rgba(245, 166, 35, 0.16), rgba(245, 166, 35, 0.04));
  border: 1px solid rgba(245, 166, 35, 0.3);
  margin-bottom: var(--space-lg);
  animation: screenIn 0.4s var(--ease-smooth);
}
.contingency-banner__icon {
  font-size: 1.4rem;
}
.contingency-banner strong {
  color: var(--gold-400);
}
.contingency-banner p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.4;
}

.action-row {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}
.action-row .btn {
  flex: 1;
}

/* Dropzone GPX */
.dropzone {
  border: 2px dashed var(--border-glass-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
  transition: all 0.25s var(--ease-smooth);
  margin-top: var(--space-lg);
  cursor: pointer;
}
.dropzone.is-dragover {
  border-color: var(--green-500);
  background: rgba(0, 230, 118, 0.08);
  transform: scale(1.01);
}
.dropzone__icon {
  width: 44px;
  height: 44px;
  margin: 0 auto var(--space-sm);
  border-radius: 50%;
  background: var(--glass-bg);
  display: grid;
  place-items: center;
  color: var(--green-400);
}
.dropzone p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.dropzone strong {
  color: var(--text-primary);
}
.dropzone input[type="file"] {
  display: none;
}

/* ---------------------------------------------------------------------------
   9. Feed social
   --------------------------------------------------------------------------- */
.feed-card {
  padding: var(--space-md) var(--space-md) var(--space-md);
  margin-bottom: var(--space-md);
}

.feed-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.8rem;
  background: linear-gradient(135deg, var(--green-500), var(--gold-500));
  color: #06210f;
  flex-shrink: 0;
}

.avatar.sm {
  width: 32px;
  height: 32px;
  font-size: 0.68rem;
}

.feed-card__meta {
  flex: 1;
  min-width: 0;
}
.feed-card__name {
  font-weight: 700;
  font-size: 0.92rem;
}
.feed-card__time {
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

.feed-card__badge-pill {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--gold-glow);
  color: var(--gold-400);
}

.feed-card__body {
  margin-top: var(--space-md);
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.feed-card__stats {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-glass);
}

.feed-card__distance {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--green-400);
}

.like-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-tertiary);
  transition: color 0.2s ease;
}
.like-btn .icon {
  transition: transform 0.35s var(--ease-bounce);
}
.like-btn.is-liked {
  color: var(--danger);
}
.like-btn.is-liked .icon {
  transform: scale(1.15);
}
.like-btn.is-bursting .icon {
  animation: likeBurst 0.5s var(--ease-bounce);
}
@keyframes likeBurst {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.5) rotate(-8deg);
  }
  70% {
    transform: scale(0.9) rotate(4deg);
  }
  100% {
    transform: scale(1.15);
  }
}

.comment-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-tertiary);
}

/* Partículas de "gosto" (corações/canecas flutuantes) */
.like-particle {
  position: fixed;
  z-index: 999;
  pointer-events: none;
  font-size: 1.4rem;
  animation: floatUp 1s ease-out forwards;
}
@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translateY(0) scale(0.6) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(-70px) scale(1.3) rotate(18deg);
  }
}

/* Conexões */
.connections-scroll {
  display: flex;
  gap: var(--space-md);
  overflow-x: auto;
  padding: 4px 2px var(--space-sm);
  margin-bottom: var(--space-lg);
  scrollbar-width: none;
}
.connections-scroll::-webkit-scrollbar {
  display: none;
}

.connection-card {
  flex-shrink: 0;
  width: 84px;
  text-align: center;
  padding: var(--space-md) var(--space-sm);
}

.connection-card .avatar {
  margin: 0 auto 6px;
  width: 50px;
  height: 50px;
  font-size: 0.9rem;
  position: relative;
}

.online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green-400);
  border: 2px solid var(--bg-elevated-2);
}

.connection-card__name {
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.connection-card__meta {
  font-size: 0.62rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ---------------------------------------------------------------------------
   10. Badges / Gamificação
   --------------------------------------------------------------------------- */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}

.badge-card {
  padding: var(--space-lg) var(--space-md);
  text-align: center;
  position: relative;
  transition: transform 0.25s var(--ease-bounce);
}
.badge-card:active {
  transform: scale(0.97);
}

.badge-card__icon-wrap {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-sm);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--glass-bg);
  border: 1px solid var(--border-glass-strong);
  color: var(--text-tertiary);
  position: relative;
}

.badge-card.is-unlocked .badge-card__icon-wrap {
  color: #06210f;
  background: linear-gradient(135deg, var(--green-400), var(--green-600));
  box-shadow: var(--shadow-glow-green);
}

.badge-card.tier-gold.is-unlocked .badge-card__icon-wrap {
  background: linear-gradient(135deg, var(--gold-400), var(--gold-600));
  color: #2b1900;
  box-shadow: var(--shadow-glow-gold);
}

.badge-card__name {
  font-size: 0.82rem;
  font-weight: 800;
  margin-bottom: 2px;
}
.badge-card.is-locked .badge-card__name {
  color: var(--text-tertiary);
}

.badge-card__progress-track {
  height: 5px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.08);
  margin-top: var(--space-sm);
  overflow: hidden;
}
.badge-card__progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--green-500), var(--green-300));
  transition: width 0.6s var(--ease-smooth);
}

.badge-card__lock {
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--text-tertiary);
  opacity: 0.6;
}

/* Badge lendária Bierathlet — tratamento visual ultra-raro */
.badge-card.is-legendary {
  grid-column: span 2;
  background: linear-gradient(135deg, rgba(245, 166, 35, 0.14), rgba(0, 230, 118, 0.08));
  border: 1px solid rgba(245, 166, 35, 0.4);
  padding: var(--space-xl) var(--space-lg);
  overflow: hidden;
}

.badge-card.is-legendary::before {
  content: "";
  position: absolute;
  inset: -50%;
  background: conic-gradient(
    from 0deg,
    transparent,
    rgba(245, 166, 35, 0.25),
    transparent 30%
  );
  animation: legendarySpin 6s linear infinite;
}

@keyframes legendarySpin {
  to {
    transform: rotate(360deg);
  }
}

.badge-card.is-legendary .badge-card__inner {
  position: relative;
  z-index: 2;
}

.badge-card.is-legendary .badge-card__icon-wrap {
  width: 78px;
  height: 78px;
  background: linear-gradient(135deg, var(--gold-300), var(--gold-600));
  color: #2b1900;
  box-shadow: 0 0 0 4px rgba(245, 166, 35, 0.15), var(--shadow-glow-gold);
  animation: legendaryPulse 2.4s infinite var(--ease-smooth);
}

@keyframes legendaryPulse {
  0%,
  100% {
    box-shadow: 0 0 0 4px rgba(245, 166, 35, 0.15), var(--shadow-glow-gold);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(245, 166, 35, 0.05), var(--shadow-glow-gold);
  }
}

.badge-card.is-legendary .badge-card__name {
  font-size: 1.05rem;
  background: linear-gradient(90deg, var(--gold-300), var(--gold-500));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.legendary-stats {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  margin-top: var(--space-md);
}
.legendary-stats div {
  text-align: center;
}
.legendary-stats strong {
  display: block;
  font-size: 1.15rem;
  color: var(--gold-400);
}
.legendary-stats span {
  font-size: 0.65rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Tooltip de badge (modal leve) */
.badge-tooltip-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.badge-tooltip {
  width: 100%;
  max-width: 480px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border-glass-strong);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-xl) var(--space-lg) calc(var(--space-2xl));
  animation: sheetUp 0.35s var(--ease-smooth);
  text-align: center;
}
@keyframes sheetUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.badge-tooltip .badge-card__icon-wrap {
  width: 84px;
  height: 84px;
  margin-bottom: var(--space-md);
}

.badge-tooltip h3 {
  font-size: 1.2rem;
  margin-bottom: var(--space-sm);
}
.badge-tooltip p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: var(--space-lg);
}

/* ---------------------------------------------------------------------------
   11. Perfil
   --------------------------------------------------------------------------- */
.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-xl) var(--space-lg);
  margin-bottom: var(--space-lg);
}

.profile-header .avatar {
  width: 84px;
  height: 84px;
  font-size: 1.6rem;
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-glow-green);
  border: 3px solid var(--bg-elevated-2);
}

.profile-header__name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.profile-header__name {
  font-size: 1.25rem;
  font-weight: 800;
}

.profile-header__edit-btn {
  width: 26px;
  height: 26px;
  color: var(--text-tertiary);
  transition: color 0.2s var(--ease-smooth);
}
.profile-header__edit-btn:hover,
.profile-header__edit-btn:active {
  color: var(--green-400);
}
.profile-header__edit-btn .icon {
  width: 14px;
  height: 14px;
}

.profile-header__username {
  color: var(--text-tertiary);
  font-size: 0.85rem;
  margin-bottom: var(--space-sm);
}

.profile-header__title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--gold-glow), transparent);
  border: 1px solid rgba(245, 166, 35, 0.35);
  color: var(--gold-400);
  transition: transform 0.15s var(--ease-smooth), background 0.15s var(--ease-smooth);
}
.profile-header__title:hover {
  background: linear-gradient(135deg, rgba(245, 166, 35, 0.28), transparent);
}
.profile-header__title:active {
  transform: scale(0.97);
}

/* Badge em destaque no cartão de Conquistas */
.featured-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding-bottom: var(--space-md);
  margin-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-glass);
}
.featured-badge-chip {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Picker genérico (títulos / badge em destaque) — reaproveita o modal de badge-tooltip */
.picker-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
}
.picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  transition: background 0.15s var(--ease-smooth);
}
.picker-item:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.08);
}
.picker-item.is-selected {
  border-color: var(--green-400);
  background: rgba(46, 232, 138, 0.1);
  color: var(--green-400);
}
.picker-item.is-locked {
  opacity: 0.45;
  cursor: not-allowed;
}
.picker-item__name {
  font-size: 0.88rem;
  font-weight: 700;
}
.picker-item__meta {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.settings-list {
  display: flex;
  flex-direction: column;
}
.settings-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-md);
  border-bottom: 1px solid var(--border-glass);
}
.settings-item:last-child {
  border-bottom: none;
}
.settings-item__icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  display: grid;
  place-items: center;
  color: var(--green-400);
  flex-shrink: 0;
}
.settings-item__text {
  flex: 1;
}
.settings-item__title {
  font-weight: 700;
  font-size: 0.88rem;
}
.settings-item__desc {
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

.toggle {
  width: 44px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: var(--border-glass-strong);
  position: relative;
  transition: background 0.25s ease;
  flex-shrink: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-primary);
  transition: transform 0.25s var(--ease-bounce);
}
.toggle.is-on {
  background: var(--green-600);
}
.toggle.is-on::after {
  transform: translateX(18px);
  background: #06210f;
}

/* ---------------------------------------------------------------------------
   12. Loading / skeleton / spinner
   --------------------------------------------------------------------------- */
.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--green-400);
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--glass-bg) 25%,
    rgba(255, 255, 255, 0.06) 37%,
    var(--glass-bg) 63%
  );
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-md);
}
@keyframes shimmer {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  color: var(--text-tertiary);
}
.empty-state .icon-lg {
  margin: 0 auto var(--space-md);
  opacity: 0.5;
}

/* ---------------------------------------------------------------------------
   13. Utilitários
   --------------------------------------------------------------------------- */
.flex {
  display: flex;
}
.flex-col {
  display: flex;
  flex-direction: column;
}
.items-center {
  align-items: center;
}
.justify-between {
  justify-content: space-between;
}
.gap-xs {
  gap: var(--space-xs);
}
.gap-sm {
  gap: var(--space-sm);
}
.gap-md {
  gap: var(--space-md);
}
.mt-sm {
  margin-top: var(--space-sm);
}
.mt-md {
  margin-top: var(--space-md);
}
.mt-lg {
  margin-top: var(--space-lg);
}
.text-secondary {
  color: var(--text-secondary);
}
.text-tertiary {
  color: var(--text-tertiary);
}
.text-center {
  text-align: center;
}
.w-full {
  width: 100%;
}

/* ---------------------------------------------------------------------------
   14. Responsivo — continua confortável em ecrãs maiores (desktop preview)
   --------------------------------------------------------------------------- */
@media (min-width: 540px) {
  #app {
    margin-top: var(--space-lg);
    margin-bottom: var(--space-lg);
    min-height: calc(100vh - 2 * var(--space-lg));
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-glass);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
    overflow: hidden;
  }
  body {
    background: #050705;
  }
  .bottom-nav__inner {
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  }
}

@media (max-width: 360px) {
  .screen {
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }
  .badge-grid {
    gap: var(--space-sm);
  }
}

/* ---------------------------------------------------------------------------
   15. Autenticação (login / criar conta)
   --------------------------------------------------------------------------- */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  background: var(--bg-gradient);
}

.auth-gate[hidden] {
  display: none !important;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  padding: var(--space-xl) var(--space-lg);
  animation: screenIn 0.4s var(--ease-smooth);
}

.auth-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.05);
  margin-bottom: var(--space-lg);
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-tertiary);
  transition: all 0.2s var(--ease-smooth);
}
.auth-tab.is-active {
  background: linear-gradient(135deg, var(--green-400), var(--green-600));
  color: #06210f;
}

.auth-form[hidden] {
  display: none !important;
}

.auth-field {
  display: block;
  margin-bottom: var(--space-md);
}
.auth-field span {
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.auth-field input {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass-strong);
  color: var(--text-primary);
  font-size: 0.92rem;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.auth-field input:focus {
  outline: none;
  border-color: var(--green-500);
  background: rgba(0, 230, 118, 0.06);
}
.auth-field input::placeholder {
  color: var(--text-tertiary);
}

.auth-message {
  min-height: 1.2em;
  margin-top: var(--space-md);
  font-size: 0.8rem;
  text-align: center;
  font-weight: 600;
}
.auth-message--error {
  color: var(--danger);
}
.auth-message--success {
  color: var(--green-400);
}

/* ---------------------------------------------------------------------------
   16. Upload de foto de perfil
   --------------------------------------------------------------------------- */
.avatar-upload-wrap {
  position: relative;
  width: 84px;
  height: 84px;
  margin: 0 auto var(--space-md);
}

.avatar-edit-btn {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--gold-400), var(--gold-600));
  border: 3px solid var(--bg-elevated-2);
  color: #2b1900;
}
.avatar-edit-btn .spinner {
  border-top-color: #2b1900;
  border-color: rgba(43, 25, 0, 0.3);
  border-top-width: 2.5px;
}

/* ---------------------------------------------------------------------------
   16. Feed — abas (Feed / Ranking), pesquisa de atletas, ranking/leaderboard
   --------------------------------------------------------------------------- */
.segmented-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-pill);
  margin-top: var(--space-md);
}
.segmented-tabs__item {
  flex: 1;
  padding: 9px 0;
  text-align: center;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-tertiary);
  transition: all 0.2s var(--ease-smooth);
}
.segmented-tabs__item.is-active {
  background: linear-gradient(135deg, var(--green-400), var(--green-600));
  color: #06210f;
  box-shadow: var(--shadow-glow-green);
}

.feed-tab-panel {
  animation: screenIn 0.3s var(--ease-smooth);
}

.athlete-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass-strong);
  color: var(--text-tertiary);
  margin-bottom: var(--space-md);
}
.athlete-search input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.85rem;
}
.athlete-search input:focus {
  outline: none;
}
.athlete-search input::placeholder {
  color: var(--text-tertiary);
}
.athlete-search__clear {
  display: grid;
  place-items: center;
  color: var(--text-tertiary);
}
.athlete-search__clear:hover {
  color: var(--text-primary);
}

.athlete-search-empty {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  padding: var(--space-md) var(--space-sm);
  text-align: center;
}

/* --- Ranking / Leaderboard ---
   Top 3 empilhado verticalmente (um em cima do outro) — não lado a lado.
   Nota: o contentor no HTML é um id (#leaderboard-podium), não uma classe —
   o seletor aqui tem de ser por id, senão o layout nunca se aplica. */
#leaderboard-podium {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: var(--space-lg);
}
.podium-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  position: relative;
}
.podium-row .avatar {
  width: 46px;
  height: 46px;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.podium-row__rank {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 800;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border-glass-strong);
  color: var(--text-secondary);
  flex-shrink: 0;
}
.podium-row__info {
  flex: 1;
  min-width: 0;
}
.podium-row__name {
  font-size: 0.88rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.podium-row__meta {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}
.podium-row__score {
  text-align: right;
  flex-shrink: 0;
}
.podium-row__score-value {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--green-400);
}
.podium-row__score-label {
  font-size: 0.6rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* 1º lugar — claramente o maior e mais luminoso dos três, no topo. */
.podium-row--gold {
  padding: calc(var(--space-md) + 4px);
  border-color: var(--gold-500);
  box-shadow: 0 6px 18px rgba(245, 166, 35, 0.24);
  background: linear-gradient(90deg, rgba(245, 166, 35, 0.14), var(--glass-bg) 65%);
}
.podium-row--gold .avatar {
  width: 56px;
  height: 56px;
  font-size: 1.05rem;
  box-shadow: 0 0 10px rgba(245, 166, 35, 0.45);
  border: 2px solid var(--gold-400);
}
.podium-row--gold .podium-row__name {
  font-size: 0.98rem;
}
.podium-row--gold .podium-row__score-value {
  color: var(--gold-300);
  font-size: 1.05rem;
}
.podium-row--gold .podium-row__rank {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--gold-400), var(--gold-600));
  border-color: transparent;
  color: #2b1900;
  box-shadow: 0 0 12px rgba(245, 166, 35, 0.5);
}
/* A coroa do 1º lugar vive DENTRO do círculo do rank (substitui o número),
   nunca a espreitar por fora do card — um elemento posicionado fora dos
   limites do .glass-card fica cortado, porque .glass-card tem
   overflow:hidden (é o que estava a "cortar o número"). */
.podium-row__rank .icon {
  width: 16px;
  height: 16px;
}

/* 2º e 3º lugares — mais discretos, claramente abaixo do 1º */
.podium-row--silver {
  opacity: 0.96;
}
.podium-row--silver .podium-row__rank {
  background: linear-gradient(135deg, #e4e9ef, #9aa5b1);
  border-color: transparent;
  color: #1c2126;
}
.podium-row--bronze {
  opacity: 0.92;
}
.podium-row--bronze .podium-row__rank {
  background: linear-gradient(135deg, #d8935a, #a1602f);
  border-color: transparent;
  color: #2b1600;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: 8px;
}
.leaderboard-row__position {
  width: 22px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-tertiary);
}
.leaderboard-row .avatar {
  width: 38px;
  height: 38px;
  font-size: 0.72rem;
}
.leaderboard-row__info {
  flex: 1;
  min-width: 0;
}
.leaderboard-row__name {
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.leaderboard-row__meta {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  margin-top: 1px;
}
.leaderboard-row__score {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--green-400);
}
.leaderboard-row.is-me {
  border-color: var(--green-500);
}
.leaderboard-row.is-me .leaderboard-row__name::after {
  content: " (tu)";
  color: var(--green-400);
  font-weight: 700;
}

.leaderboard-me-card {
  margin-top: var(--space-md);
}
