/* Map-specific variables */
:root {
--control-radius: 10px;
--control-height: 44px;
}

.map-page {
position: relative;
width: 100%;
min-height: calc(100vh - 80px);
  display: flex;
  justify-content: center;
  background: #0b2f6a;
  color: var(--text);
  padding: 32px 24px;
  overflow: hidden;
}

.map-page::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #0b2f6a 0%, #0d4c8a 55%, #1ea8e0 100%);
  opacity: 0.9;
  z-index: 0;
}

.map-page::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at top,
    rgba(255, 255, 255, 0.2),
    transparent 55%
  );
  z-index: 0;
}
.map-container {
  width: 100%;
  max-width: 1280px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
  display: flex;
  overflow: hidden;
  min-height: calc(100vh - 160px);
  position: relative;
  z-index: 1;
}
.map-sidebar {
  width: 320px;
  max-width: 360px;
  background: var(--sidebar);
  border-right: 1px solid var(--panel-border);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.map-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
}
.map-header .title {
  font-size: 20px;
  margin: 0;
  color: var(--text);
}
.map-header .subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.controls-container {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  margin: 0;
}
.location-search {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.location-search label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.location-search .input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.location-search input {
  width: 100%;
  padding: 10px 38px 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  font-size: 14px;
  background: #ffffff;
  color: var(--text);
}
.location-search input:disabled {
  background: #edf5fb;
  cursor: not-allowed;
}
.location-search .clear-btn {
  position: absolute;
  right: 10px;
  height: 24px;
  width: 24px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
}
.location-search .clear-btn:hover {
  color: var(--primary);
}
.location-search .hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.search-feedback {
  margin: 0;
  font-size: 12px;
  color: var(--primary-2);
}
.search-feedback.is-warning {
  color: var(--danger);
}
.segmented {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--control-radius);
  overflow: hidden;
  width: 100%;
}
/* Keep segmented compact in even row and prevent wrapping */
.controls-row-even > .segmented {
  width: auto;
  flex: 0 0 auto;
  min-width: max-content;
  margin-left: 16px;
}
/* In the inline toolbar, keep segmented controls compact; spacing handled by container */
.timeline-tools .segmented { width: auto; margin-left: 0; }
/* In the sidebar, restore full-width Heatmap/Marker tabswitcher */
.map-sidebar .map-controls .control-group {
  width: 100%;
  flex: 1 1 100%;
}
.segmented button {
  padding: 6px 12px;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-right: 1px solid var(--panel-border);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.2px;
  transition: color 0.2s ease, background 0.2s ease;
  flex: 1 1 0;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.segmented button:last-child {
  border-right: 0;
}
.segmented button.active,
.segmented button.is-active {
  background: var(--primary);
  color: #ffffff;
}
.segmented button.is-muted {
  opacity: 0.5;
  pointer-events: none;
}
.timeline {
  background: var(--panel);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.timeline-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.timeline-date {
  font-weight: 600;
  color: var(--text);
}
.timeline-ctrls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}
#reset.btn {
  border-width: 2px;
  grid-column: 1 / -1;
}
.btn {
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}
.btn.secondary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn:disabled {
  opacity: 0.6;
  cursor: default;
}
.calendar-heatmap {
  position: relative;
  /* Responsive sizing variables */
  --cal-cell: 24px; /* day cell size */
  --cal-gap: 6px; /* gap between cells */
  --cal-label: 36px; /* weekday label column width */
}
/* Loading skeleton state */
.calendar-heatmap.is-loading .calendar-scroll,
.calendar-heatmap.is-loading .calendar-months,
.calendar-heatmap.is-loading .calendar-body {
  display: none;
}
/* Hide empty-state text during loading */
.calendar-heatmap.is-loading .calendar-empty {
  display: none !important;
}
.calendar-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.calendar-empty {
  display: none;
  font-size: 13px;
  color: var(--muted);
  padding: 12px 0 0;
}
.calendar-heatmap.show-empty .calendar-empty {
  display: block;
}
.calendar-heatmap.show-empty .calendar-body,
.calendar-heatmap.show-empty .calendar-months,
.calendar-heatmap.show-empty .calendar-scroll {
  display: none;
}
/* Calendar skeleton layout to preview final structure */
.calendar-skeleton {
  display: none;
  padding-top: var(--cal-gap);
}
.calendar-heatmap.is-loading .calendar-skeleton {
  display: block;
}
.calendar-skeleton .calendar-skel-months {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--cal-cell);
  gap: var(--cal-gap);
  margin-left: calc(var(--cal-label) + var(--cal-gap) + 2px);
  margin-bottom: 12px;
  min-width: max-content;
}
.calendar-skeleton .calendar-skel-month-cell {
  height: 10px;
  border-radius: 4px;
  background: #eef3f8;
}
.calendar-skeleton .calendar-skel-body {
  display: flex;
  align-items: flex-start;
  column-gap: var(--cal-gap);
  min-width: max-content;
}
.calendar-skeleton .calendar-skel-weekdays {
  display: grid;
  grid-template-rows: repeat(7, var(--cal-cell));
  gap: var(--cal-gap);
}
.calendar-skeleton .calendar-skel-weekday-line {
  width: var(--cal-label);
  height: var(--cal-cell);
  border-radius: 4px;
  background: #eef3f8;
}
.calendar-skeleton .calendar-skel-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--cal-cell);
  grid-template-rows: repeat(7, var(--cal-cell));
  gap: var(--cal-gap);
  min-width: max-content;
}
.calendar-skeleton .calendar-skel-cell {
  width: var(--cal-cell);
  height: var(--cal-cell);
  border-radius: 4px;
  background: #eef3f8;
}
.calendar-months {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--cal-cell);
  gap: var(--cal-gap);
  margin-left: calc(var(--cal-label) + var(--cal-gap) + 2px);
  margin-bottom: 12px;
  font-size: 11px;
  color: var(--muted);
  min-width: max-content;
}
.calendar-months span {
  line-height: 1;
}
.calendar-body {
  display: flex;
  align-items: flex-start;
  column-gap: var(--cal-gap);
  min-width: max-content;
}
.calendar-legend {
  margin-top: 20px;
  margin-left: 36px;
  display: inline-flex;
  flex-direction: column;
  gap: 8px;
}
.calendar-weekdays {
  display: grid;
  grid-template-rows: repeat(7, var(--cal-cell));
  gap: var(--cal-gap);
  font-size: 11px;
  color: var(--muted);
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--panel);
  border-right: 1px solid var(--panel-border);
}
.calendar-weekdays span {
  line-height: var(--cal-cell);
  width: var(--cal-label);
  text-align: left;
}
.calendar-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--cal-cell);
  grid-template-rows: repeat(7, var(--cal-cell));
  gap: var(--cal-gap);
  min-width: max-content;
}
.calendar-cell {
  width: var(--cal-cell);
  height: var(--cal-cell);
  border-radius: 4px;
  border: 0;
  padding: 0;
  background: #ffffff;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: #1b1b1b;
  touch-action: manipulation;
}
.calendar-cell.level-0 {
  background: #2ecc71;
}
.calendar-cell.level-1 {
  background: #a3d977;
}
.calendar-cell.level-2 {
  background: #ffd166;
}
.calendar-cell.level-3 {
  background: #f29e4c;
}
.calendar-cell.level-4 {
  background: #d62828;
  color: #ffffff;
}
.calendar-cell.is-active {
  outline: 2px solid #c1121f;
  transform: scale(1.15);
  box-shadow: 0 2px 6px rgba(193, 18, 31, 0.35);
}
.calendar-cell.is-outside {
  opacity: 0.4;
  cursor: default;
}
.calendar-cell:focus-visible {
  outline: 2px solid #c1121f;
  outline-offset: 2px;
}
.calendar-tooltip {
  position: absolute;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  padding: 6px 8px;
  font-size: 12px;
  pointer-events: none;
  display: none;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  transform: translate(-50%, -120%);
}
.map-area {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  gap: 24px;
  padding-bottom: 24px;
}
/* Dedicated controls panel */
.map-controls {
  background: var(--sidebar);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 12px 16px;
  box-sizing: border-box;
  overflow: hidden;
}
.map-controls .controls-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px 16px;
  align-items: center;
  justify-content: space-evenly;
}
.map-controls .control-group {
  display: flex;
  align-items: center;
  gap: 12px;
  width: auto;
  min-width: 0;
  flex: 0 0 auto;
}
.map-controls .controls-actions .btn {
  white-space: nowrap;
  width: auto;
}
.timeline-tools {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: nowrap;
}
.timeline-range {
  display: block;
  min-width: 0;
  width: auto;
}
.timeline-range label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.timeline-range select {
  padding: 6px 40px 6px 12px;
  border-radius: var(--control-radius);
  border: 1px solid var(--panel-border);
  font-size: 13px;
  color: var(--text);
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8"><path fill="%23556375" d="M1.41.59 6 5.17 10.59.59 12 2l-6 6-6-6z"/></svg>')
      no-repeat right 12px center/12px auto,
    #ffffff;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  width: auto;
  max-width: none;
  min-width: 96px;
  box-sizing: border-box;
  display: block;
}
.timeline-range select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.timeline-range select:disabled {
  opacity: 0.6;
  cursor: default;
}
/* period buttons removed; using dropdown instead */
.map-stage {
  flex: 1 1 auto;
  min-height: 520px;
  position: relative;
  border-left: 1px solid var(--panel-border);
  background: #dcecf8;
}
.map-stage #map {
  width: 100%;
  height: 100%;
}
/* Map loading overlay (static skeleton) */
.map-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 600;
  display: none;
  background: #f5f7fb;
  border-left: 1px solid var(--panel-border);
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.map-loading-overlay.is-visible {
  display: flex;
}
.skeleton-box {
  background: #e9eff6;
  border-radius: 8px;
}
.skeleton-line {
  height: 12px;
  width: 160px;
  background: #e9eff6;
  border-radius: 6px;
  margin: 6px auto 0;
}
.map-loading-inner {
  width: min(420px, 90%);
  text-align: center;
}
.map-loading-hero {
  height: 120px;
  width: 100%;
}
/* Progress bar */
.progress-container {
  margin-top: 16px;
}
.progress-track {
  height: 10px;
  background: #dfe7f2;
  border-radius: 8px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(
    45deg,
    #1ea8e0 0,
    #1ea8e0 12px,
    #0d4c8a 12px,
    #0d4c8a 24px
  );
  animation: progress-stripes 1s linear infinite;
  transition: width 0.2s ease;
}
@keyframes progress-stripes {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 48px 0;
  }
}
.progress-label {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.map-selected-date {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  z-index: 500;
}
.map-legend {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  padding: 12px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  font-size: 12px;
  color: var(--text);
  width: 100%;
  max-width: 100%;
}
.map-legend-title {
  font-weight: 700;
  font-size: 11px;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-legend-gradient {
  height: 14px;
  border-radius: 4px;
  width: 100%;
}
.map-legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
/* Google Places Autocomplete dropdown styling (keep branding visible) */
/* Elevate new Places UI components so their dropdown isn't obscured */
gmp-place-autocomplete,
gmpx-place-autocomplete {
  display: block;
  position: relative;
  z-index: 10010;
}
.pac-container,
.pac-item,
.pac-item span,
.pac-item-query {
  font-family: "Gotham", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}
.pac-container {
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 10000; /* ensure above Leaflet panes */
}
/* Lightweight custom suggestions dropdown (fallback) */
.place-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 10010;
  margin-top: 4px;
  max-height: 280px;
  overflow-y: auto;
}
.place-suggestion {
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text);
}
.place-suggestion:hover {
  background: var(--sidebar);
}
.place-suggestion .main {
  font-weight: 600;
}
.place-suggestion .secondary {
  color: var(--muted);
  font-size: 12px;
}
.pac-item {
  padding: 8px 12px;
  color: var(--text);
}
.pac-item:hover {
  background: var(--sidebar);
}
.pac-item .pac-item-query {
  color: var(--text);
  font-weight: 600;
}
/* Do not hide or obscure the required Google branding */
.pac-logo {
  padding: 6px 8px;
}
.leaflet-container {
  background: #dcecf8;
}

/* Trip highlight: day-of-trip labels */
.trip-day-label {
  background: none;
  border: none;
}
.trip-day-label span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #1a73e8;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

/* Trip info box */
.trip-info-box {
  background: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  font-size: 13px;
  max-width: 280px;
  max-height: 320px;
  overflow-y: auto;
}
.trip-info-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.trip-info-header b {
  line-height: 1.3;
}
.trip-close-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
.trip-close-btn:hover {
  color: #333;
}
.trip-itinerary {
  list-style: none;
  margin: 0;
  padding: 0;
}
.trip-itinerary li {
  padding: 3px 0;
  border-top: 1px solid #f0f0f0;
  font-size: 12px;
  line-height: 1.4;
}
.trip-day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1a73e8;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  margin-right: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}
.leaflet-heatmap-layer {
  pointer-events: none;
  opacity: 0.9;
  mix-blend-mode: normal;
}
.leaflet-control-container .leaflet-top.leaflet-left {
  top: auto;
  bottom: 16px;
  left: auto;
  right: 16px;
}
.leaflet-popup-content-wrapper,
.leaflet-tooltip {
  border-radius: 6px;
}
.leaflet-popup-content-wrapper {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--panel-border);
}
.leaflet-popup-tip {
  background: #ffffff;
}
.no-data-message {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
  justify-content: center;
  padding: 48px;
  color: var(--muted);
}
.map-area .no-data-message {
  align-items: center;
  text-align: center;
  color: var(--muted);
}
.sidebar-note {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}
.project-description {
  color: var(--text);
  font-size: 12px;
  line-height: 1.6;
}
.project-accordion {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.project-full[hidden] {
  display: none;
}
.accordion-toggle {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  align-self: flex-start;
}
.project-description p {
  margin: 16px 0 0;
}
.project-description p:first-child {
  margin-top: 0;
}
@media (max-width: 992px) {
  .map-page {
    /* Drop horizontal gutter so .map-container goes edge-to-edge on mobile;
       keep vertical padding for breathing room above/below. */
    padding: 24px 0;
  }
  .map-container {
    flex-direction: column;
    min-height: auto;
    /* Edge-to-edge: drop the 1px border + side rounding that would otherwise
       leave a hairline of page-blue at the screen edges. */
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }
  /* Reorder layout on mobile: map area (with heatmap) first, sidebar second */
  .map-area {
    order: 1;
  }
  .map-sidebar {
    order: 2;
  }
  .map-sidebar {
    width: 100%;
    /* Desktop sets max-width: 360px — clear it on mobile so the sidebar
       fills the full screen width instead of leaving whitespace on the
       right when stacked. */
    max-width: none;
    border-right: 0;
    border-bottom: 1px solid var(--panel-border);
    flex-direction: column;
  }
  .map-area {
    gap: 16px;
    padding-bottom: 16px;
  }
  .map-controls {
    padding: 10px 12px;
  }
  .map-controls .controls-row {
    gap: 10px 12px;
  }
  .map-controls .control-group {
    flex: 1 1 100%;
    justify-content: space-between;
  }
  .map-stage {
    border-left: 0;
    min-height: 420px;
  }
  .calendar-legend {
    margin-left: 0;
  }
}
@media (max-width: 600px) {
  .calendar-heatmap {
    --cal-cell: 18px;
    --cal-gap: 4px;
    --cal-label: 28px;
  }
  .calendar-months {
    font-size: 10px;
  }
  .calendar-weekdays {
    font-size: 10px;
  }
  .timeline-top {
    flex-direction: column;
    align-items: flex-start;
  }
  .map-controls .control-group {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .map-controls .controls-actions .timeline-ctrls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
  }
  .map-controls .controls-actions .btn {
    flex: 1 1 auto;
    width: 100%;
  }
  .timeline-tools {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    flex-wrap: nowrap;
  }
  .timeline-tools .segmented { margin-left: 0; }
  .controls-row.controls-row-even > .segmented { margin-left: 0; }
  .timeline-ctrls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
  }
  .timeline-range {
    width: 100%;
    justify-content: space-between;
  }
  .timeline-range select {
    width: 100%;
  }
  .timeline-range select {
    width: 100%;
    min-width: 0;
  }
  .map-stage {
    min-height: 360px;
  }
  /* Let the inline toolbar wrap nicely on small screens */
  .controls-row.controls-row-even {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px 12px;
  }
  .controls-row.controls-row-even > .segmented { width: 100%; }
  .controls-row.controls-row-even > .btn { flex: 1 1 auto; }
}
