/* ── Page layout ─────────────────────────────────────────────────────── */

.page-content { flex-direction: column; }

/* ── Layer switcher (header buttons) ────────────────────────────────── */

.layer-controls { display: flex; gap: 0.4rem; }

.layer-btn {
  padding: 0.25rem 0.75rem;
  border: 1px solid #3a3a6a;
  border-radius: 4px;
  background: transparent;
  color: #a0a0c0;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}
.layer-btn:hover  { background: #2a2a4a; color: #e0e0ff; }
.layer-btn.active { background: #2a4a8a; border-color: #5a80c0; color: #fff; }

/* ── Map area (sidebar + map side by side) ───────────────────────────── */

#map-area {
  flex: 1;
  min-height: 0;
  display: flex;
}

/* ── Left sidebar ────────────────────────────────────────────────────── */

#sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-deep);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease;
  overflow: hidden;
}
#sidebar.collapsed { width: 40px; }

#sidebar-toggle {
  flex-shrink: 0;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  text-align: right;
  transition: color 0.15s;
}
#sidebar-toggle:hover { color: var(--accent); }
#sidebar.collapsed #sidebar-toggle { text-align: center; }

#sidebar-body {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 1;
  transition: opacity 0.15s ease;
}
#sidebar.collapsed #sidebar-body { opacity: 0; pointer-events: none; }

#sidebar-body h3,
#right-sidebar-body h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6060a0;
  margin-bottom: 0.75rem;
}

/* ── Right filter sidebar ────────────────────────────────────────────── */

#right-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-deep);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease;
  overflow: hidden;
}
#right-sidebar.collapsed { width: 40px; }

#right-sidebar-toggle {
  flex-shrink: 0;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  text-align: left;
  transition: color 0.15s;
}
#right-sidebar-toggle:hover { color: var(--accent); }
#right-sidebar.collapsed #right-sidebar-toggle { text-align: center; }

#right-sidebar-body {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 1;
  transition: opacity 0.15s ease;
}
#right-sidebar.collapsed #right-sidebar-body { opacity: 0; pointer-events: none; }

/* ── Label filter buttons ─────────────────────────────────────────────── */

#label-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.label-filter-all-row { display: flex; }

.label-filter-category {
  border: 1px solid #2a2a4a;
  border-radius: 5px;
  padding: 0.5rem 0.6rem;
  background: rgba(255, 255, 255, 0.02);
}

.label-filter-category-name {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6060a0;
  margin-bottom: 0.4rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid #2a2a4a;
}

.label-filter-category-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.label-filter-category-uncategorized .label-filter-category-name { color: #4a4a7a; }

.label-filter-item {
  padding: 0.2rem 0.45rem;
  font-size: 0.72rem;
  border: 1px solid #2a2a4a;
  border-radius: 3px;
  background: transparent;
  color: #7070a0;
  cursor: pointer;
  text-align: left;
  transition: all 0.12s;
  user-select: none;
  white-space: nowrap;
}
.label-filter-item:hover  { border-color: #5a6a9a; color: #b0b0d0; }
.label-filter-item.active { border-color: var(--accent-dim); background: #1a2a4a; color: var(--accent); }

.label-filter-all { font-weight: 600; width: 100%; }
.label-filter-all.active { background: #12223a; border-color: var(--accent); }

/* ── Sidebar event list ───────────────────────────────────────────────── */

@keyframes sidebar-enter {
  0%   { opacity: 0; transform: translateY(-4px); background: transparent; }
  20%  { opacity: 1; transform: translateY(0);    background: rgba(255, 140, 60, 0.28); }
  100% { opacity: 1; transform: translateY(0);    background: transparent; }
}

.sidebar-event {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  opacity: 1;
  transition: opacity 0.3s ease;
  border-radius: 4px;
}
.sidebar-event.entering   { animation: sidebar-enter 1.4s ease-out both; }
.sidebar-event:last-child  { border-bottom: none; }
.sidebar-event.removing    { opacity: 0; pointer-events: none; }
.sidebar-event.selected    { background: rgba(160, 196, 255, 0.08); padding-left: 0.4rem; }
.sidebar-event.selected .sidebar-event-name { color: #d0e4ff; }

.sidebar-event-name {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 0.15rem;
}

.sidebar-event-date {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.sidebar-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Suggest new event button ─────────────────────────────────────────── */

#suggest-new-btn {
  display: block;
  margin-bottom: 0.75rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  border: 1px solid #2a4a3a;
  border-radius: 4px;
  background: #0a1a10;
  color: #70c090;
  text-decoration: none;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}
#suggest-new-btn:hover { background: #1a3a20; border-color: #3a7a4a; }

/* ── Map container ───────────────────────────────────────────────────── */

#map {
  flex: 1;
  min-height: 0;
}

/* ── Timeline panel ──────────────────────────────────────────────────── */

#timeline-panel {
  flex-shrink: 0;
  background: var(--bg-deep);
  border-top: 1px solid var(--border);
  padding: 0.75rem 1.5rem 1.75rem;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
}

.timeline-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6060a0;
}

#year-display {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
  min-width: 140px;
  text-align: right;
}

/* ── Play button ─────────────────────────────────────────────────────── */

#play-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-right: 0.5rem;
  margin-bottom: 2rem;
  opacity: 0.75;
  transition: opacity 0.15s;
}
#play-btn:hover   { opacity: 1; }
#play-btn.playing { color: #c08080; }

.slider-row { display: flex; align-items: center; }

.slider-wrapper {
  flex: 1;
  position: relative;
  padding-bottom: 2rem;
}

/* ── Main timeline range input ───────────────────────────────────────── */

#timeline-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, #2a4a8a var(--pct, 0%), #2a2a4a var(--pct, 0%));
  outline: none;
  cursor: pointer;
}
#timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-deep);
  box-shadow: 0 0 6px rgba(160, 196, 255, 0.6);
  cursor: grab;
  transition: transform 0.1s;
}
#timeline-slider::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.2); }
#timeline-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-deep);
  cursor: grab;
}

/* ── Tick marks below the slider ─────────────────────────────────────── */

.tick-marks {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  pointer-events: none;
}

.tick {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transform: translateX(-50%);
}

.tick-line { width: 1px; height: 6px; background: #3a3a6a; }
.tick-text { font-size: 0.78rem; color: #7070b0; white-space: nowrap; }

/* ── Leaflet popup: dark theme override ──────────────────────────────── */

.leaflet-popup-content-wrapper {
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  color: #e0e0e0;
  padding: 0;
}
.leaflet-popup-content {
  margin: 0;
  min-width: 220px;
  max-width: 300px;
}
.leaflet-popup-tip { background: #1a1a2e; }
.leaflet-popup-close-button {
  color: #7070a0 !important;
  font-size: 18px !important;
  top: 6px !important;
  right: 8px !important;
}
.leaflet-popup-close-button:hover { color: #e0e0e0 !important; }

/* ── Popup content layout ────────────────────────────────────────────── */

.popup-inner  { padding: 0.85rem 1rem; }

.popup-type {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #7070a0;
  margin-bottom: 0.2rem;
}

.popup-name {
  font-size: 1rem;
  font-weight: 600;
  color: #a0c4ff;
  margin-bottom: 0.25rem;
  line-height: 1.2;
}

.popup-date {
  font-size: 0.78rem;
  color: #7070b0;
  margin-bottom: 0.5rem;
}

.popup-desc {
  font-size: 0.82rem;
  color: #c0c0d0;
  line-height: 1.45;
  margin-bottom: 0.5rem;
  border-top: 1px solid #2a2a4a;
  padding-top: 0.5rem;
}

.popup-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.4rem;
}

.popup-label {
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  background: #2a2a4a;
  color: #a0a0c0;
  border: 1px solid #3a3a6a;
}

/* ── Admin / suggest edit buttons in popup ───────────────────────────── */

.popup-actions {
  margin-top: 0.5rem;
  padding-top: 0.45rem;
  border-top: 1px solid #2a2a4a;
  display: flex;
  justify-content: flex-end;
}

.popup-edit-btn {
  font-size: 0.7rem;
  color: #6060a0;
  text-decoration: none;
  padding: 0.18rem 0.55rem;
  border: 1px solid #2a2a4a;
  border-radius: 3px;
  transition: all 0.12s;
}
.popup-edit-btn:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: #1a2a4a;
}

.popup-suggest-btn { color: #507050; border-color: #1a3a20; }
.popup-suggest-btn:hover { color: #70c090; border-color: #2a6a30; background: #0a2a10; }

/* ── Event window config popover ─────────────────────────────────────── */

.timeline-label-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.config-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #5050a0;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  font-size: 1.1rem;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
}
.config-btn:hover,
.config-btn.open { color: #a0a0d0; border-color: #3a3a6a; }

.config-popover {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: #12122a;
  border: 1px solid #2a2a4a;
  border-radius: 7px;
  padding: 1rem 1.1rem;
  width: 280px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  z-index: 1000;
}
.config-popover.open { display: block; }

.config-popover h4 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6060a0;
  margin-bottom: 0.75rem;
}

.window-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.window-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: #2a2a4a;
  outline: none;
  cursor: pointer;
}
.window-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #12122a;
  cursor: grab;
}
.window-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #12122a;
  cursor: grab;
}
.window-slider:disabled { opacity: 0.3; cursor: not-allowed; }
.window-slider:disabled::-webkit-slider-thumb { cursor: not-allowed; }

.window-value {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 70px;
  text-align: right;
  white-space: nowrap;
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.preset-chip {
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  border: 1px solid #2a2a4a;
  border-radius: 3px;
  background: transparent;
  color: #7070a0;
  cursor: pointer;
  transition: all 0.12s;
}
.preset-chip:hover  { border-color: #5a6a9a; color: #b0b0d0; }
.preset-chip.active { border-color: var(--accent-dim); background: #1a2a4a; color: var(--accent); }
.preset-chip[data-val="adaptive"].active { background: #0f2a1a; border-color: #3a8a5a; color: #70d090; }

/* ── Era range buttons ───────────────────────────────────────────────── */

.era-controls { display: flex; gap: 0.3rem; }

.era-btn {
  padding: 0.2rem 0.6rem;
  border: 1px solid #3a3a6a;
  border-radius: 4px;
  background: transparent;
  color: #7070a0;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.era-btn:hover  { background: #2a2a4a; color: #c0c0e0; border-color: #5a5a8a; }
.era-btn.active { background: #1a2a4a; color: var(--accent); border-color: var(--accent-dim); }

/* ── Hover tooltips on map markers ───────────────────────────────────── */

.map-tip {
  background: #12122a;
  border: 1px solid #3a3a6a;
  color: #e0e0e0;
  font-size: 0.78rem;
  white-space: nowrap;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  line-height: 1.45;
}
.map-tip::before { border-top-color: #3a3a6a !important; }
.map-tip::after  { border-top-color: #12122a !important; }

.tip-name { color: #a0c4ff; font-weight: 600; }
.tip-date { color: #6060a0; font-size: 0.72rem; }

/* ── Year toast (large year overlay while dragging) ──────────────────── */

#year-toast {
  position: absolute;
  top: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 10, 30, 0.82);
  border: 1px solid #2a2a6a;
  border-radius: 6px;
  padding: 0.45rem 1.1rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.06em;
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.15s ease-in;
}
#year-toast.visible { opacity: 1; }
#year-toast.fading  { opacity: 0; transition: opacity 0.6s ease-out; }

/* ── Toggle rows (Use Icons + Map View filter) ───────────────────────── */

#icons-toggle-row {
  padding: 0.6rem 0 0.9rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.9rem;
}

#map-view-toggle-row {
  padding: 0.5rem 0 0.8rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.6rem;
}

.icons-toggle-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
}
.icons-toggle-label input { display: none; }

.icons-toggle-track {
  width: 30px;
  height: 16px;
  border-radius: 8px;
  background: #2a2a4a;
  border: 1px solid #3a3a6a;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}
.icons-toggle-label input:checked ~ .icons-toggle-track {
  background: #1a3a6a;
  border-color: var(--accent-dim);
}

.icons-toggle-thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #5a5a8a;
  transition: transform 0.2s, background 0.2s;
}
.icons-toggle-label input:checked ~ .icons-toggle-track .icons-toggle-thumb {
  transform: translateX(14px);
  background: var(--accent);
}

.icons-toggle-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  transition: color 0.15s;
}
.icons-toggle-label:has(input:checked) .icons-toggle-text { color: var(--accent); }

/* ── Map context menu ────────────────────────────────────────────────── */

#map-context-menu {
  position: fixed;
  z-index: 9999;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  min-width: 170px;
  display: none;
}
#map-context-menu.open { display: block; }
#map-context-menu a {
  display: block;
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
#map-context-menu a:hover { background: rgba(255, 255, 255, 0.06); color: var(--accent); }

/* ── Search bar ──────────────────────────────────────────────────────── */

.search-wrapper { position: relative; }

#event-search {
  width: 210px;
  padding: 0.25rem 0.75rem 0.25rem 2rem;
  background: #1a1a2e;
  border: 1px solid #3a3a6a;
  border-radius: 4px;
  color: #e0e0e0;
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.15s;
}
#event-search:focus { border-color: var(--accent-dim); }
#event-search::placeholder { color: #5050a0; }

.search-icon {
  position: absolute;
  left: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  color: #5050a0;
  font-size: 0.75rem;
  pointer-events: none;
}

#search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 340px;
  background: #12122a;
  border: 1px solid #2a2a4a;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  z-index: 2000;
  max-height: 320px;
  overflow-y: auto;
}
#search-dropdown.open { display: block; }

.search-result {
  padding: 0.55rem 0.8rem;
  cursor: pointer;
  border-bottom: 1px solid #1e1e3a;
  transition: background 0.1s;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover,
.search-result.focused { background: #1e2a4a; }

.search-result-name {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 500;
  line-height: 1.3;
}
.search-result-name mark {
  background: #2a4a8a;
  color: #c0d8ff;
  border-radius: 2px;
  padding: 0 1px;
}

.search-result-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.search-result-snippet {
  font-size: 0.7rem;
  color: #5060a0;
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-snippet mark {
  background: #1a3a6a;
  color: #8090c0;
  border-radius: 2px;
  padding: 0 1px;
}

/* ── Event icon markers ───────────────────────────────────────────────── */

.event-icon-marker {
  background: none !important;
  border: none !important;
}
.event-icon-marker img {
  display: block;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.9));
  transition: transform 0.12s, filter 0.12s;
}
.event-icon-marker:hover img {
  transform: scale(1.2);
  filter: drop-shadow(0 2px 8px rgba(160, 196, 255, 0.6));
}
