/* ═══════════════════════════════════════════════════════════════════════════
   sidebar.css — the left drawer's layout and contents
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Floating sidebar: the map stretches full-viewport behind it ── */
#sidebar {
  width: 340px;
  background: var(--bg-sidebar);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;

  /* Floating window look */
  position: fixed;
  top: 12px;
  left: 12px;
  bottom: 12px;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.45), 0 2px 8px rgba(0,0,0,0.25);
  z-index: 500;
  border: none;

  /* Clip scrollbar and children inside the rounded corners */
  isolation: isolate;
}
#sidebar::-webkit-scrollbar { width: 6px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ───── Header ───── */
.sidebar-header {
  padding: 1.5rem 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border-soft);
  position: relative;
}
.sidebar-header .brand { display: flex; align-items: baseline; gap: 0.5rem; }
.sidebar-header h1 {
  font-family: var(--serif); font-weight: 400;
  font-size: 1.5rem; letter-spacing: -0.01em;
}
.sidebar-header h1 em { font-style: italic; color: var(--accent); font-weight: 500; }
.sidebar-header .tagline {
  font-family: var(--serif); font-style: italic;
  font-size: 0.85rem; color: var(--text-muted);
  margin-top: 0.25rem;
}

/* "server connected" / "offline" pill in the header */
.backend-pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  margin-top: 0.6rem; padding: 0.18rem 0.55rem;
  border-radius: 100px; background: var(--bg-sidebar-elev);
  color: var(--text-secondary); font-size: 0.7rem; font-weight: 500;
  border: 1px solid var(--border);
}
.backend-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); }
.backend-pill.connected .dot { background: var(--success); }
.backend-pill.connected      { color: #86efac; border-color: #166534; }
.backend-pill.error .dot     { background: #f87171; }
.backend-pill.error          { color: #fca5a5; border-color: #7f1d1d; }

/* "saving…" / "saved" badge — sits in the header top-right */
.save-status {
  position: absolute; top: 1.5rem; right: 1.5rem;
  font-size: 0.7rem; color: var(--text-muted);
  font-family: var(--serif); font-style: italic;
  transition: opacity 0.3s;
}

/* ───── Sections ───── */
/* Every section is now a <details> element */
.sidebar-section {
  border-bottom: 1px solid var(--border-soft);
}

/* The <summary> acts as the clickable section header */
.sidebar-section > summary {
  list-style: none;
  outline: none;
  padding: 1rem 1.5rem;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.12s;
}
.sidebar-section > summary::-webkit-details-marker { display: none; }
.sidebar-section > summary:hover { background: rgba(255,255,255,0.03); }

/* Chevron indicator on the right of each summary */
.sidebar-section > summary::after {
  content: '›';
  font-size: 1rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
  margin-left: 0.5rem;
  line-height: 1;
}
.sidebar-section[open] > summary::after {
  transform: rotate(90deg);
}

/* Section body (everything inside <details> except <summary>) */
.sidebar-section-body {
  padding: 0 1.5rem 1.25rem;
}

.section-label {
  font-family: var(--serif); font-style: italic; font-weight: 400;
  font-size: 0.85rem; color: var(--text-secondary);
  margin-bottom: 0.85rem; letter-spacing: 0.01em;
  display: flex; align-items: center; justify-content: space-between;
  /* When used as the summary content, no bottom margin */
}
.sidebar-section > summary .section-label {
  margin-bottom: 0;
  pointer-events: none; /* summary handles the click */
}
.section-label .count {
  font-style: normal; font-family: var(--sans);
  font-size: 0.7rem; color: var(--text-muted);
  background: var(--bg-sidebar-elev);
  padding: 0.1rem 0.45rem; border-radius: 100px;
  font-variant-numeric: tabular-nums;
}

/* Legacy accordion-inner (used inside nested <details> like fuel calc) */
.accordion-inner { margin-top: 0.5rem; }

/* ───── Server info section (bottom, muted) ───── */
.sidebar-section.server-info-section > summary .section-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ───── Trip switcher ───── */
.trip-switcher { display: flex; gap: 0.4rem; align-items: stretch; }
.trip-switcher select.input { flex: 1; min-width: 0; padding-right: 0.5rem; }
.trip-switcher .trip-icon-btn {
  background: var(--bg-sidebar-elev); border: 1px solid var(--border);
  color: var(--text-secondary); width: 34px; flex-shrink: 0;
  border-radius: 6px; cursor: pointer; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.trip-switcher .trip-icon-btn:hover {
  color: var(--text-primary); background: var(--bg-sidebar-elev-2);
}
.trip-switcher .trip-icon-btn svg { width: 14px; height: 14px; }

.trip-meta {
  font-family: var(--serif); font-style: italic;
  font-size: 0.72rem; color: var(--text-muted);
  margin-top: 0.55rem; padding-left: 0.1rem;
  font-variant-numeric: tabular-nums;
}

/* ───── Categories ───── */
.category-list { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.85rem; }
.category-row {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.55rem 0.7rem; border-radius: 6px;
  background: var(--bg-sidebar-elev); border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.category-row:hover { background: var(--bg-sidebar-elev-2); }
.category-row.is-hidden { opacity: 0.45; }
.cat-dot {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--bg-sidebar);
}
.cat-name {
  flex: 1; font-size: 0.875rem; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cat-count {
  font-size: 0.7rem; color: var(--text-muted);
  padding: 0.1rem 0.4rem; background: var(--bg-sidebar); border-radius: 3px;
  font-variant-numeric: tabular-nums;
}

/* ───── Display toggles ───── */
.display-toggles { display: flex; flex-direction: column; gap: 0.45rem; }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.55rem 0.7rem; gap: 0.6rem;
  background: var(--bg-sidebar-elev);
  border: 1px solid transparent; border-radius: 6px;
  cursor: pointer; transition: background 0.12s, border-color 0.12s;
}
.toggle-row:hover { background: var(--bg-sidebar-elev-2); }
.toggle-row .toggle-text  { flex: 1; min-width: 0; }
.toggle-row .toggle-label { font-size: 0.82rem; color: var(--text-primary); font-weight: 500; }
.toggle-row .toggle-meta {
  font-size: 0.68rem; color: var(--text-muted);
  font-family: var(--serif); font-style: italic;
  display: block; margin-top: 2px; line-height: 1.3;
}

/* ───── Pin list ───── */
.pin-list {
  display: flex; flex-direction: column; gap: 6px;
  /* Fill whatever vertical space the sidebar has left after the sections
     above (trip picker, categories, display toggles).  The sidebar itself
     is the scrollable container so there is no need for a tight max-height
     here — letting it flex-grow gives users full access to their pin list
     without a cramped 280px window.  A modest min-height keeps the list
     from collapsing to zero on very short viewports. */
  flex: 1;
  min-height: 120px;
  overflow-y: auto; overflow-x: hidden;
  padding-right: 4px;
}
.pin-list::-webkit-scrollbar { width: 5px; }
.pin-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.pin-row {
  display: flex;
  align-items: stretch;
  border-radius: 8px;
  background: var(--bg-sidebar-elev);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: background 0.14s;
}
.pin-row:hover   { background: var(--bg-sidebar-elev-2); }
.pin-row.is-hovered { background: var(--bg-sidebar-elev-2); }
.pin-row.is-hidden  { opacity: 0.45; }
.pin-row.is-hidden .pin-stripe { background: var(--text-muted); box-shadow: none; }

.pin-row.is-favourite {
  background:
    linear-gradient(90deg, rgba(251,191,36,.12), rgba(251,191,36,.025) 65%, transparent 100%),
    var(--bg-sidebar-elev);
}
.pin-row.is-favourite:hover {
  background:
    linear-gradient(90deg, rgba(251,191,36,.16), rgba(251,191,36,.04) 65%, transparent 100%),
    var(--bg-sidebar-elev-2);
}

/* Left category stripe — 4px wide, full row height. The "instant ID" cue. */
.pin-stripe {
  width: 4px;
  flex-shrink: 0;
  background: var(--cat, var(--text-muted));
  box-shadow: 0 0 8px -2px var(--cat, transparent);
}
.pin-row.is-favourite .pin-stripe {
  box-shadow: 0 0 10px -1px var(--cat, transparent);
}
.pin-row.is-sightseeing .pin-stripe {
  background: repeating-linear-gradient(180deg, var(--text-muted) 0 4px, transparent 4px 8px);
  box-shadow: none;
}

.pin-body {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.55rem 0.7rem 0.55rem 0.65rem;
  min-width: 0;
}

.pin-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pin-name {
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.pin-row.is-sightseeing .pin-name {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 14px;
  color: var(--text-secondary);
}
.pin-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.pin-cat {
  font-family: var(--serif);
  font-style: italic;
  font-size: 11.5px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.pin-price {
  font-family: var(--serif);
  font-size: 11.5px;
  color: var(--text-primary);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.pin-price.free { color: var(--success); }
.pin-row.is-favourite .pin-price { color: #fde68a; }
.meta-dot {
  width: 2.5px; height: 2.5px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.7;
  flex-shrink: 0;
  align-self: center;
}

/* Right-side badges */
.pin-badges {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.pin-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 100px;
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.pin-badge-fav {
  background: rgba(251,191,36,.18);
  color: #fcd34d;
  font-size: 11px;
  padding: 2px 5px;
}
.pin-badge-fav::before {
  content: '★';
  font-size: 11px;
  line-height: 1;
}
.pin-badge-com {
  background: rgba(14,165,233,.16);
  color: #7dd3fc;
}
.pin-badge-com::before {
  content: '';
  width: 9px; height: 9px;
  display: inline-block;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z'/></svg>") center/contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z'/></svg>") center/contain no-repeat;
}

/* Vote tally — split pill with up + down halves */
.pin-votes {
  display: inline-flex;
  align-items: stretch;
  border-radius: 100px;
  overflow: hidden;
  background: var(--bg-sidebar);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.pin-votes .v {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  color: var(--text-muted);
}
.pin-votes .v::before {
  content: '';
  width: 7px; height: 7px;
  background: currentColor;
  flex-shrink: 0;
  -webkit-mask-position: center;
          mask-position: center;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-size: contain;
          mask-size: contain;
}
.pin-votes .v.up   { color: #4ade80; }
.pin-votes .v.down { color: #f87171; }
.pin-votes .v.zero { color: var(--text-muted); opacity: 0.55; }
.pin-votes .v.up::before {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'><path d='M12 4l8 10h-5v6h-6v-6H4z'/></svg>");
          mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'><path d='M12 4l8 10h-5v6h-6v-6H4z'/></svg>");
}
.pin-votes .v.down::before {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'><path d='M12 20l-8-10h5V4h6v6h5z'/></svg>");
          mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'><path d='M12 20l-8-10h5V4h6v6h5z'/></svg>");
}

/* Arrow */
.pin-row .arrow {
  color: var(--text-muted);
  font-size: 14px;
  margin-left: 4px;
  flex-shrink: 0;
  opacity: 0.55;
  transition: transform 0.15s, opacity 0.15s, color 0.15s;
}
.pin-row:hover .arrow,
.pin-row.is-hovered .arrow {
  opacity: 1;
  color: var(--accent);
  transform: translateX(2px);
}

/* Group headers in the pin list (visible only when "Group by category" is on) */
.pin-group-header {
  font-size: 0.75rem; color: var(--text-secondary); font-weight: 600;
  margin: 0.6rem 0 0.2rem 0.2rem;
}
.pin-group-header.is-sightseeing { font-style: italic; }

/* Sort / group toggle buttons */
.pin-toolbar { display: flex; gap: 0.4rem; margin-bottom: 0.5rem; }
.pin-toolbar .btn { flex: 1; font-variant-numeric: tabular-nums; }
.pin-toolbar .btn .arrow { display: inline-block; width: 0.7em; text-align: center; }

/* ───── Cache panel ───── */
.cache-stats {
  background: var(--bg-sidebar-elev);
  padding: 0.6rem 0.75rem; border-radius: 6px;
  margin-bottom: 0.6rem;
  font-size: 0.78rem; color: var(--text-secondary);
}
.cache-stats .row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.15rem 0; font-variant-numeric: tabular-nums;
}
.cache-stats .row .label { color: var(--text-muted); font-size: 0.72rem; }
.cache-stats .row .value { font-weight: 500; }

/* ═══ FB-35: Edit mode — drag-and-drop pin/category reordering ══════════ */

/* Drag handle (⠿ braille dots used as a grip icon) */
.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  flex-shrink: 0;
  cursor: grab;
  color: var(--text-muted);
  font-size: 13px;
  opacity: 0.55;
  transition: opacity 0.12s;
  user-select: none;
}
.drag-handle:hover { opacity: 1; }
.drag-handle:active { cursor: grabbing; }

/* Handle on category group headers */
.drag-handle--cat {
  display: inline-flex;
  width: auto;
  margin-right: 0.3rem;
  font-size: 12px;
}

/* Category header in edit mode */
.pin-group-header--edit {
  display: flex;
  align-items: center;
  cursor: grab;
  padding: 0.35rem 0.25rem 0.2rem;
  border-radius: 4px;
  transition: background 0.12s;
}
.pin-group-header--edit:hover { background: rgba(255,255,255,0.05); }
.pin-group-header--edit:active { cursor: grabbing; }
.pin-group-header--edit.is-dragging { opacity: 0.35; }

/* Pin rows dragging */
.pin-row.is-dragging { opacity: 0.3; }

/* Drop indicators — thin accent lines */
.drag-over-before { box-shadow: inset 0 2px 0 0 var(--accent); }
.drag-over-after  { box-shadow: inset 0 -2px 0 0 var(--accent); }
.drag-over-cat    {
  background: rgba(var(--accent-rgb, 251,191,36), 0.12) !important;
  outline: 1px dashed var(--accent);
  outline-offset: -1px;
}

/* Edit mode active state on the Edit button */
.edit-mode-active {
  background: var(--accent) !important;
  color: #000 !important;
  border-color: var(--accent) !important;
}

/* Hint text shown at top of list in edit mode */
.edit-mode-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--serif);
  font-style: italic;
  text-align: center;
  padding: 0.3rem 0 0.5rem;
  opacity: 0.8;
}

/* Empty category drop zone shown in edit mode */
.edit-cat-empty-drop {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--serif);
  font-style: italic;
  text-align: center;
  padding: 0.4rem;
  border: 1px dashed var(--border);
  border-radius: 6px;
  margin-bottom: 4px;
  transition: background 0.12s, border-color 0.12s;
}
.edit-cat-empty-drop.drag-over-cat {
  border-color: var(--accent);
  background: rgba(251,191,36,.08);
  color: var(--accent);
}
