/* --------------------------------------------------------------------------
 * Leaflet base
 * ----------------------------------------------------------------------- */

.leaflet-container {
  font: inherit;
}

/* Map container */
.gtl-map {
  width: 100%;
  height: 480px;       /* target map height */
  position: relative;
  flex: 1 1 auto;
}

/* --------------------------------------------------------------------------
 * Legend & Filters
 * ----------------------------------------------------------------------- */

.gtl-legend,
.gtl-filters {
  position: absolute;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  font-size: 14px;
  line-height: 1.25;
}

.gtl-legend {
  bottom: 12px;
  left: 12px;
  max-width: 320px;
}

.gtl-filters {
  top: 12px;
  left: 12px;
  max-width: 340px;
}

.gtl-legend h4,
.gtl-filters h4 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
}

.gtl-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.gtl-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid #ccc;
}

.gtl-legend a {
  text-decoration: none;
  color: #111827;
}

.gtl-legend a:hover {
  text-decoration: underline;
}

/* active legend row */
.gtl-legend-item.is-active .gtl-legend-swatch {
  outline: 2px solid #111827;
}

/* Route filters (chip) */
.gtl-filters .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  margin: 0 6px 6px 0;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
}

.gtl-filters .chip input {
  margin: 0;
}

/* --------------------------------------------------------------------------
 * POI (text icons)
 * ----------------------------------------------------------------------- */

.gtl-poi {
  font-size: 14px;
  line-height: 14px;
  text-align: center;
}

.gtl-poi-bar {
  color: #d97706;
} /* orange */

.gtl-poi-fontana {
  color: #0ea5e9;
} /* light blue */

.gtl-poi-museo {
  color: #7c3aed;
} /* purple */

.gtl-poi-struttura {
  color: #16a34a;
} /* green */

/* --------------------------------------------------------------------------
 * Elevation profile
 * ----------------------------------------------------------------------- */

.gtl-profile {
  width: 100%;
  height: 180px;
  margin-top: 8px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.gtl-profile canvas {
  width: 100% !important;
  height: 160px !important;
}

.gtl-profile-picker {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 6px 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  font-size: 14px;
}

/* hand cursor on clickable polylines */
.leaflet-interactive.gtl-route {
  cursor: pointer;
}

/* --------------------------------------------------------------------------
 * Floating card (legacy layout if used elsewhere)
 * ----------------------------------------------------------------------- */

.gtl-route-card {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1001;
  width: 320px;
  max-width: calc(100% - 24px);
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.gtl-route-card header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
}

.gtl-route-card .swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.gtl-route-card h4 {
  margin: 0;
  font-size: 15px;
  line-height: 1.2;
  color: #111827;
}

.gtl-route-card .body {
  padding: 10px 14px;
  color: #374151;
  font-size: 14px;
}

.gtl-route-card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 6px 0 8px;
  color: #111827;
}

.gtl-route-card .meta span {
  background: #f3f4f6;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 12px;
}

.gtl-route-card .excerpt {
  margin: 6px 0 10px;
  color: #4b5563;
  font-size: 13px;
}

.gtl-route-card .cats {
  color: #6b7280;
  font-size: 12px;
}

.gtl-route-card .footer {
  padding: 12px 14px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  gap: 8px;
}

.gtl-route-card .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  text-decoration: none;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #111827;
}

.gtl-route-card .btn.primary {
  background: #111827;
  color: #fff;
  border-color: #111827;
}

/* Close */
.gtl-route-card .close {
  margin-left: auto;
  cursor: pointer;
  color: #6b7280;
  font-size: 18px;
  line-height: 1;
}

.gtl-route-card .close:hover {
  color: #111827;
}

/* Mobile: card below the map */
@media (max-width: 768px) {
  .gtl-route-card {
    top: auto;
    bottom: 12px;
    right: 12px;
    left: 12px;
    width: auto;
  }
}

/* --------------------------------------------------------------------------
 * Layout wrapper map and map column
 * ----------------------------------------------------------------------- */

.gtl-map-wrap {
  display: flex;
  align-items: stretch;   /* same height for map and sidebar */
  gap: 16px;
}

/* column containing the map */
.gtl-map-col {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

/* map expands within the column */
.gtl-map-col .gtl-map {
  flex: 1 1 auto;
}

/* --------------------------------------------------------------------------
 * POI filter panel (Leaflet control)
 * ----------------------------------------------------------------------- */

.leaflet-control.gtl-poi-filters {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
  min-width: 220px;
  max-width: 340px;
}

.gtl-poi-filters h4 {
  margin: 0 0 6px;
  font-size: 14px;
  color: #111827;
}

.gtl-poi-filters .row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.gtl-poi-filters .row img {
  width: 16px;
  height: 16px;
}

.gtl-poi-filters .row label {
  font-size: 13px;
  color: #111827;
  cursor: pointer;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.gtl-poi-filters .count {
  color: #6b7280;
  font-size: 12px;
}

.leaflet-control.gtl-poi-filters .gtl-poi-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  background: #ffffff;
  cursor: pointer;
  font-family: inherit;
  color: #111827;
}

.leaflet-control.gtl-poi-filters .gtl-poi-toggle-label {
  color: #111827;
  font-weight: 600;
  font-size: 14px;
}

.leaflet-control.gtl-poi-filters .gtl-poi-toggle-icon {
  font-size: 11px;
  color: #111827;
}

.gtl-poi-filters.is-collapsed .gtl-poi-panel {
  display: none;
}

.gtl-poi-filters.is-collapsed .gtl-poi-toggle-icon {
  transform: rotate(-90deg);
}

/* --------------------------------------------------------------------------
 * Sidebar (gtl-sidecard) always visible with internal scroll
 * ----------------------------------------------------------------------- */

.gtl-sidecard {
  width: 320px;
  max-width: 40%;
  min-width: 280px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  box-sizing: border-box;

  display: flex;
  flex-direction: column;
  overflow: hidden; /* prevent scrolling on the container; only .body scrolls */
}


/* Header fixed to the top */
.gtl-sidecard > header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  flex: 0 0 auto;
}

.gtl-sidecard .swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.gtl-sidecard h4 {
  margin: 0;
  font-size: 15px;
  line-height: 1.2;
  color: #111827;
}

/* Scrollable body (list or detail) */
.gtl-sidecard > .body {
  padding: 10px 14px;
  color: #374151;
  font-size: 14px;
  flex: 1 1 auto;
  min-height: 0;        /* required for inner scrolling with flex */
  overflow-y: auto;     /* scroll happens here */
}

.gtl-sidecard > .body::-webkit-scrollbar {
  width: 8px;
}
.gtl-sidecard > .body::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}
.gtl-sidecard > .body::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Meta / badge */
.gtl-sidecard .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 6px 0 8px;
  color: #111827;
}

.gtl-sidecard .meta span {
  background: #f3f4f6;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 12px;
}

.gtl-sidecard .excerpt {
  margin: 6px 0 10px;
  color: #4b5563;
  font-size: 13px;
}

.gtl-sidecard .cats {
  color: #6b7280;
  font-size: 12px;
  padding: 0 0.5rem 0.5rem;
}

/* Footer fixed to the bottom (when present in the detail view) */
.gtl-sidecard > .footer {
  padding: 12px 14px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.gtl-sidecard .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  text-decoration: none;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #111827;
}

.gtl-sidecard .btn.primary {
  background: var(--accent, #0a58ca);
  color: #fff;
}

/* Close */
.gtl-sidecard .close {
  margin-left: auto;
  cursor: pointer;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.gtl-sidecard .close:hover {
  color: #111827;
}

/* Track list in the sidebar */
.gtl-sidecard .gtl-route-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.gtl-sidecard .gtl-route-row-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;

  padding: 0.15rem 0.25rem;
  text-align: left;

  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.gtl-sidecard .gtl-route-row-btn:hover {
  background: #f3f4f6;
}

.gtl-sidecard .gtl-route-row-btn:focus-visible {
  outline: 2px solid #0a58ca;
  outline-offset: 2px;
}

.gtl-sidecard .gtl-route-row .swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

.gtl-sidecard .gtl-route-row .title {
  flex: 1 1 auto;
}

.gtl-sidecard .gtl-route-row .meta {
  font-size: 0.8rem;
  color: #6b7280;
}

/* --------------------------------------------------------------------------
 * Responsive
 * ----------------------------------------------------------------------- */

@media (max-width: 900px) {
  .gtl-map-wrap {
    flex-direction: column;
  }

  .gtl-sidecard {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-top: 12px;
  }
}

/* --------------------------------------------------------------------------
 * Other text elements
 * ----------------------------------------------------------------------- */

.start {
  padding: 0 0.5rem 0.5rem;
}

.end {
  padding: 0 0.5rem 0.5rem;
}

.gtl-poi-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.gtl-poi-item {
  margin: 0 0 0.5rem;
}

.gtl-poi-title {
  font-weight: 600;
  text-decoration: none;
}

.gtl-poi-distance {
  opacity: 0.75;
  margin-left: 0.25rem;
}

.gtl-poi-type,
.gtl-poi-addr {
  font-size: 0.9em;
  opacity: 0.85;
}

/* "Open in Maps" button in POI popups */

.gtl-download-gpx {
  display: block;
  margin-top: 0.75rem;
}

.gtl-download-gpx .gtl-btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-weight: 600;
  background: var(--accent, #0a58ca);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  line-height: 1;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.gtl-download-gpx .gtl-btn:hover,
.gtl-download-gpx .gtl-btn:focus-visible {
  background-color: color-mix(in srgb, var(--accent, #0a58ca) 80%, black 20%);
  transform: translateY(-1px);
}


/* === GTL Maps - Final sidebar scroll fix === */

/* generic wrapper */
.gtl-map-wrap {
  position: relative;
}

/* reserved space for sidebar + gap ONLY if there is an active sidecard */
.gtl-map-wrap.gtl-has-sidecard .gtl-map-col {
  margin-right: 336px; /* 320 (sidebar) + 16px gap */
}

/* map: height set here (applies to all) */
.gtl-map {
  width: 100%;
  height: 480px;
  min-height: 0;
}

/* base style for sidebar (applies when it exists) */
.gtl-sidecard {
  width: 320px;
  max-width: 40%;
  min-width: 330px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  box-sizing: border-box;
}

/* absolute sidebar, same height as the map + gap on the right,
   but ONLY in wrappers with active sidecard */
.gtl-map-wrap.gtl-has-sidecard .gtl-sidecard {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex !important;
  flex-direction: column;
  overflow: hidden;
}

/* Fixed header */
.gtl-map-wrap .gtl-sidecard > header {
  flex: 0 0 auto;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e5e7eb;
}

/* Scrollable body (list or detail) */
.gtl-map-wrap .gtl-sidecard > .body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0.75rem 1rem;
}

/* === GTL Maps – Layout mobile: sidecard below the map === */
@media (max-width: 900px) {
  .gtl-map-wrap {
    position: static;
  }

  .gtl-map-wrap .gtl-map-col {
    margin-right: 0 !important;
  }

  .gtl-map-wrap .gtl-sidecard {
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-top: 12px;
    height: auto;
  }

  .gtl-map {
    height: 360px;
  }
}

