/**
 * Guia Vibe — Estilos do Módulo de Trilhas Offline
 * ==================================================
 * Design system: Dark Navy + Glassmorphism (consistente com app.css)
 * Variáveis de cor: utiliza as tokens de CSS definidas em app.css
 */

/* ── Layout da página de trilha ────────────────────────────────── */

.trilha-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height para mobile */
  background: var(--bg-color, #0f172a);
  overflow: hidden;
  position: relative;
}

/* ── Header ─────────────────────────────────────────────────────── */

.trilha-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  z-index: 500;
  flex-shrink: 0;
}

.trilha-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: none;
  cursor: pointer;
  color: var(--text-color, #e2e8f0);
  flex-shrink: 0;
  transition: background 0.2s;
}
.trilha-back-btn:hover { background: rgba(255,255,255,0.16); }
.trilha-back-btn svg { width: 20px; height: 20px; }

.trilha-header-info { flex: 1; min-width: 0; }

.trilha-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-color, #e2e8f0);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.trilha-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.trilha-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(6, 182, 212, 0.15);
  color: #06b6d4;
  border: 1px solid rgba(6, 182, 212, 0.3);
  white-space: nowrap;
}
.trilha-badge--facil    { background: rgba(16,185,129,0.15); color:#10b981; border-color:rgba(16,185,129,0.3); }
.trilha-badge--moderada { background: rgba(245,158,11,0.15); color:#f59e0b; border-color:rgba(245,158,11,0.3); }
.trilha-badge--dificil  { background: rgba(239,68,68,0.15);  color:#ef4444; border-color:rgba(239,68,68,0.3); }

.trilha-cache-btn {
  font-size: 1.25rem;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.trilha-cache-btn:hover { transform: scale(1.15); }
.trilha-cache-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Mapa ────────────────────────────────────────────────────────── */

.trilha-map-container {
  flex: 1;
  position: relative;
  min-height: 0; /* Permite o flex encolher */
}

/* Skeleton loader */
.trilha-map-skeleton {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #1e293b;
  color: rgba(255,255,255,0.4);
  font-size: 0.875rem;
  gap: 1rem;
  z-index: 10;
}

.skeleton-pulse {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(90deg, #334155 25%, #475569 50%, #334155 75%);
  background-size: 200% 100%;
  animation: skeletonPulse 1.4s infinite;
}

@keyframes skeletonPulse {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Garante que o Leaflet preencha o container */
#trilha-map .leaflet-container {
  width: 100% !important;
  height: 100% !important;
  background: #1e293b;
}

/* ── Painel de informações flutuante ─────────────────────────────── */

.trilha-info-panel {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 10px 16px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 32px;
  z-index: 800;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  white-space: nowrap;
}

.trilha-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-color, #e2e8f0);
}

.trilha-stat-icon { font-size: 0.9rem; }

.trilha-gps-btn {
  font-size: 1.1rem;
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
}
.trilha-gps-btn:hover  { background: rgba(59, 130, 246, 0.35); transform: scale(1.1); }
.trilha-gps-btn.active { background: rgba(59, 130, 246, 0.5); }

/* ── Marcador de posição do usuário (ponto azul) ─────────────────── */

.trilha-user-dot {
  width: 20px;
  height: 20px;
  background: #3b82f6;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(59,130,246,0.3), 0 2px 8px rgba(0,0,0,0.4);
  animation: gpsPulse 2s infinite;
}

@keyframes gpsPulse {
  0%   { box-shadow: 0 0 0 4px rgba(59,130,246,0.3), 0 2px 8px rgba(0,0,0,0.4); }
  50%  { box-shadow: 0 0 0 8px rgba(59,130,246,0.1), 0 2px 8px rgba(0,0,0,0.4); }
  100% { box-shadow: 0 0 0 4px rgba(59,130,246,0.3), 0 2px 8px rgba(0,0,0,0.4); }
}

/* ── Ícone dos POIs ──────────────────────────────────────────────── */

.trilha-poi-icon {
  font-size: 1.5rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
  cursor: pointer;
  transition: transform 0.15s;
}
.trilha-poi-icon:hover { transform: scale(1.2); }

/* ── Popup dos POIs ──────────────────────────────────────────────── */

.leaflet-popup-content-wrapper.trilha-leaflet-popup,
.trilha-leaflet-popup .leaflet-popup-content-wrapper {
  background: #1e293b;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  color: #e2e8f0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.trilha-leaflet-popup .leaflet-popup-tip {
  background: #1e293b;
}

.trilha-popup {
  font-family: inherit;
}

.trilha-popup strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: #06b6d4;
  margin-bottom: 4px;
}

.trilha-popup p {
  font-size: 0.8rem;
  color: rgba(226,232,240,0.8);
  margin: 0;
  line-height: 1.4;
}

/* ── Tela de erro ────────────────────────────────────────────────── */

.trilha-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 0.75rem;
  color: rgba(226,232,240,0.7);
  text-align: center;
  padding: 2rem;
}

.trilha-error span { font-size: 2.5rem; }
.trilha-error p    { font-size: 0.9rem; max-width: 280px; }

/* ── Responsividade ──────────────────────────────────────────────── */

@media (min-width: 768px) {
  .trilha-info-panel {
    gap: 1.5rem;
    padding: 12px 24px;
  }
  .trilha-stat { font-size: 0.85rem; }
}
