/* ═══════════════════════════════════════════════════════════════
   Route Page — full-viewport GPX map with mobile bottom sheet
   Task-209 | events/css/route-page.css
═══════════════════════════════════════════════════════════════ */

/* ── Navbar: no body scroll on this page, always show glass state ── */
.events-page .navbar {
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: var(--shadow-md);
  height: calc(var(--navbar-height) - 10px);
}

/* ── Wrapper — remove default events-page padding ── */
.events-page .rp-wrapper {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 70px); /* navbar glass height: var(--navbar-height) - 10px = 80px - 10px */
  overflow: hidden;
}

/* ── Topbar ── */
.rp-topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  height: 56px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: relative;
  z-index: 10;
}

.rp-back-link {
  display: flex;
  align-items: center;
  gap: .4rem;
  color: #374151;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.rp-back-link:hover { color: #1d4ed8; }
.rp-back-label {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Route tabs (inline in topbar) ── */
.rp-route-tabs {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
}

.rp-route-tab {
  display: inline-flex;
  align-items: center;
  padding: .3rem .9rem;
  border-radius: 8px;
  background: #f3f4f6;
  color: #374151;
  text-decoration: none;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.rp-route-tab--active {
  background: var(--tab-color, #e74c3c);
  color: #fff;
}
.rp-route-tab:hover:not(.rp-route-tab--active) {
  background: #e5e7eb;
  color: #111827;
  text-decoration: none;
}

/* ── Single-route badge (no tabs) ── */
.rp-route-badge {
  display: inline-flex;
  align-items: center;
  padding: .25rem .75rem;
  border-radius: 999px;
  background: var(--badge-color, #e74c3c);
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .04em;
  flex-shrink: 0;
}

.rp-topbar-stats {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

.rp-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 6px;
  background: #f3f4f6;
  color: #374151;
  font-size: .78rem;
  font-weight: 500;
  white-space: nowrap;
}
.rp-stat-chip i { font-size: .8rem; }

/* ── Split layout ── */
.rp-layout {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* ── Map column ── */
.rp-map-col {
  flex: 0 0 55%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.rp-map-container {
  flex: 1 1 auto;
  min-height: 0;
  background: #e8edf2;
  position: relative;
}

.rp-map-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e8edf2;
  z-index: 1;
}

.rp-elevation-strip {
  flex: 0 0 auto;
  height: 100px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  overflow: hidden;
  transition: height .25s ease;
}
.rp-elevation-strip.rp-elev--collapsed { height: 0; }

/* ── POI panel ── */
.rp-poi-panel {
  flex: 0 0 45%;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #e5e7eb;
  background: #fff;
  min-height: 0;
  overflow: hidden;
}

.rp-sheet-handle { display: none; }

.rp-poi-panel-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ── Route switcher ── */
.rp-route-switcher {
  display: flex;
  gap: .5rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  flex-wrap: wrap;
}

.rp-route-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: .35rem .75rem;
  border-radius: 8px;
  border: 2px solid var(--pill-color, #e74c3c);
  color: var(--pill-color, #e74c3c);
  background: #fff;
  text-decoration: none;
  font-size: .78rem;
  font-weight: 600;
  line-height: 1.2;
  transition: background .12s, color .12s;
}
.rp-route-pill:hover {
  background: var(--pill-color, #e74c3c);
  color: #fff;
}
.rp-route-pill--active {
  background: var(--pill-color, #e74c3c);
  color: #fff;
}
.rp-pill-distance { font-size: .82rem; font-weight: 700; }
.rp-pill-km { font-size: .72rem; opacity: .85; }

/* ── Category filter chips ── */
.rp-filter-chips {
  display: flex;
  gap: .4rem;
  padding: .6rem 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid #f1f5f9;
}

.rp-chip {
  padding: .25rem .7rem;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  font-size: .75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .1s, border-color .1s, color .1s;
}
.rp-chip:hover { background: #f3f4f6; }
.rp-chip--active {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #fff;
}

/* ── POI timeline ── */
.rp-poi-list {
  padding: .5rem 0;
}

.rp-poi-item {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  padding: .5rem 1rem;
  transition: background .1s;
  cursor: pointer;
}
.rp-poi-item:hover { background: #f9fafb; }
.rp-poi-item.rp-poi--hidden { display: none; }

.rp-poi-km {
  flex: 0 0 38px;
  font-size: .72rem;
  color: #9ca3af;
  font-weight: 600;
  padding-top: .2rem;
  text-align: right;
}

.rp-poi-track {
  flex: 0 0 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.rp-poi-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e5e7eb;
  color: #374151;
  font-size: .75rem;
  flex-shrink: 0;
}
.rp-poi-dot--turnaround      { background: #ede9fe; color: #7c3aed; }
.rp-poi-dot--water_station   { background: #dbeafe; color: #1d4ed8; }
.rp-poi-dot--gallery         { background: #f1f5f9; color: #475569; }
.rp-poi-dot--route_info      { background: #d1fae5; color: #059669; }
.rp-poi-dot--sign            { background: #fef3c7; color: #b45309; }
.rp-poi-dot--incrocio        { background: #fef2f2; color: #ef4444; }
.rp-poi-dot--medical         { background: #fce7f3; color: #db2777; }
.rp-poi-dot--volunteer_post  { background: #e0f2fe; color: #0284c7; }
.rp-poi-dot--access_point    { background: #d1fae5; color: #059669; }
.rp-poi-dot--tbc             { background: #f3f4f6; color: #6b7280; }

.rp-poi-line {
  width: 2px;
  flex: 1 1 auto;
  min-height: 8px;
  background: #e5e7eb;
  margin-top: 2px;
}

.rp-poi-content {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: .1rem;
}

.rp-poi-name {
  font-size: .83rem;
  font-weight: 600;
  color: #111827;
  line-height: 1.3;
}

.rp-poi-desc {
  font-size: .75rem;
  color: #6b7280;
  margin-top: .15rem;
  line-height: 1.4;
}

/* ── Empty state ── */
.rp-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
  color: #9ca3af;
  text-align: center;
  font-size: .85rem;
}
.rp-empty-state i { font-size: 2rem; margin-bottom: .5rem; }

/* ── Action buttons ── */
.rp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .75rem 1rem;
  border-top: 1px solid #f1f5f9;
  border-bottom: 1px solid #f1f5f9;
}

.rp-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .9rem;
  border-radius: 8px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  text-decoration: none;
}
.rp-btn--outline {
  background: #fff;
  border: 1px solid #d1d5db;
  color: #374151;
}
.rp-btn--outline:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
  color: #111827;
}

/* ── Info Utili ── */
.rp-info-utili {
  padding: .75rem 1rem 1.25rem;
}
.rp-info-utili__title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #9ca3af;
  margin: 0 0 .5rem;
}
.rp-info-utili__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.rp-info-utili__list li {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  font-size: .8rem;
  color: #374151;
  line-height: 1.4;
}
.rp-info-utili__list li i {
  color: #059669;
  flex-shrink: 0;
  margin-top: .1rem;
}

/* ═══════════════════════════════════════════════════════════════
   Mobile — bottom sheet
═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .events-page .rp-wrapper {
    height: 100svh; /* safe-area-aware on iOS */
    overflow: visible; /* allow position:fixed bottom-sheet to escape wrapper bounds */
  }

  .rp-back-label { display: none; }
  .rp-stat-chip--hide-mobile { display: none; }

  .rp-layout {
    flex-direction: column;
    position: relative;
    overflow: visible;
  }

  .rp-map-col {
    flex: 0 0 62svh;
    width: 100%;
  }

  .rp-elevation-strip { display: none; }

  /* Panel becomes a fixed bottom sheet */
  .rp-poi-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    border-left: none;
    border-top: 1px solid #e5e7eb;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, .12);
    max-height: 82svh;
    transform: translateY(calc(100% - 52px)); /* collapsed: show handle only */
    transition: transform .32s cubic-bezier(.32, .72, 0, 1);
    z-index: 1100; /* above all Leaflet panes (max 700) and Bootstrap modals (1050) */
  }

  .rp-poi-panel.rp-sheet--open {
    transform: translateY(0);
  }

  .rp-sheet-handle {
    display: flex;
    align-items: center;
    height: 52px;
    padding: 0 1rem;
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
    -webkit-user-select: none;
    gap: .5rem;
  }

  .rp-sheet-handle-bar {
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: #d1d5db;
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
  }

  .rp-sheet-handle-label {
    font-size: .83rem;
    font-weight: 600;
    color: #374151;
    flex: 1 1 auto;
    margin-top: .25rem;
  }

  .rp-sheet-chevron {
    color: #9ca3af;
    transition: transform .25s;
    margin-top: .25rem;
  }

  .rp-poi-panel.rp-sheet--open .rp-sheet-chevron {
    transform: rotate(180deg);
  }

  .rp-poi-panel-body {
    overflow-y: auto;
    max-height: calc(82svh - 52px);
  }
}

/* ── Narrow mobile refinements ── */
@media (max-width: 480px) {
  .rp-topbar { padding: 0 .75rem; }
  .rp-poi-item { padding: .5rem .75rem; }
  .rp-actions { padding: .75rem .75rem; }
  .rp-info-utili { padding: .75rem .75rem 1rem; }
}

/* ── Wide screens ── */
@media (min-width: 1200px) {
  .rp-map-col { flex: 0 0 60%; }
  .rp-poi-panel { flex: 0 0 40%; }
}
