/* Dashboard redesign — override layer, loaded after styles.css + routes-redesign.css */

:root {
  --dash-page-bg: #eef0f4;
  --dash-card: #ffffff;
  --dash-radius: 16px;
  --dash-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --dash-hairline: #e8eaf0;
  --dash-ink: #0f172a;
  --dash-muted: #64748b;
  --cond-green: #22a06b;
  --cond-amber: #f5a623;
  --cond-red: #e5484d;
  --cond-gray: #9aa3b2;
}

/* --- Attribution (OSM/CARTO legal requirement) --- */
.leaflet-control-attribution {
  font-size: 10px;
  color: var(--dash-muted);
  background: rgba(255, 255, 255, 0.75);
  padding: 1px 6px;
  border-radius: 6px 0 0 0;
}
.leaflet-control-attribution a {
  color: var(--dash-muted);
}

/* --- Condition-colored circular markers --- */
.marker-cond {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3.5px solid #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.marker-cond:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.45);
}

.marker-cond--green { background: var(--cond-green); }
.marker-cond--amber { background: var(--cond-amber); }
.marker-cond--red { background: var(--cond-red); }
.marker-cond--gray { background: var(--cond-gray); }

.marker-cond--pulse {
  animation: marker-cond-pulse 1.8s ease-in-out infinite;
}

@keyframes marker-cond-pulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(229, 72, 77, 0.5), 0 0 0 0 rgba(229, 72, 77, 0.55); }
  50% { box-shadow: 0 2px 8px rgba(229, 72, 77, 0.5), 0 0 0 8px rgba(229, 72, 77, 0); }
}

/* --- Numbered route markers: soften shadow to match new style --- */
.marker-number {
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.35);
}

/* --- Route line: animated white "flow" dots indicating direction --- */
.route-flow-line {
  stroke-dasharray: 2 16;
  stroke-linecap: round;
  animation: route-flow-move 1.2s linear infinite;
  pointer-events: none;
}

@keyframes route-flow-move {
  to { stroke-dashoffset: -18; }
}

@media (prefers-reduced-motion: reduce) {
  .route-flow-line { animation: none; }
}

/* --- Marker clusters: white circle, dark text, soft shadow --- */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-color: rgba(255, 255, 255, 0.9);
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background-color: #ffffff;
  color: var(--dash-ink);
  border: 1px solid var(--dash-hairline);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.18);
  font-weight: 600;
}

/* --- Map legend (condition color key) --- */
#map-legend {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 500;
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--dash-card);
  border-radius: 999px;
  box-shadow: var(--dash-shadow);
  padding: 8px 14px;
  font-size: 12px;
  color: var(--dash-muted);
}

#map-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

#map-legend .legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

#map-legend .legend-dot--green { background: var(--cond-green); }
#map-legend .legend-dot--amber { background: var(--cond-amber); }
#map-legend .legend-dot--red { background: var(--cond-red); }
#map-legend .legend-dot--gray { background: var(--cond-gray); }

/* ==========================================================
   Shell: page background, header/breadcrumb, view toggle,
   floating map controls, settings popover
   ========================================================== */
:root {
  --header-height: 64px;
}

body {
  background: var(--dash-page-bg);
}

#map {
  border-radius: var(--dash-radius);
  overflow: hidden;
  margin: 8px;
  width: calc(100% - 16px);
  height: calc(100% - 16px);
  box-shadow: var(--dash-shadow);
}

/* --- Header: flat breadcrumb bar instead of floating oval ---
   The header row spans the full width so the view-toggle (centered)
   and map-controls (right) can sit visually "in" it; pointer-events
   pass through the empty middle to whatever floats beneath. */
#app-header {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0 4px;
  pointer-events: none;
}

.header-content > * {
  pointer-events: auto;
}

.header-title {
  gap: 10px;
}

.header-logo-sm {
  height: 32px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

/* icon-192.png (square mark) replaces the wide wordmark below 769px,
   where the full lockup (5711x872) would eat most of the header width */
.header-logo-compact {
  display: none;
}

.crumb-block {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.crumb-overline {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dash-muted);
}

.crumb-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--dash-ink);
  display: flex;
  align-items: center;
  gap: 6px;
}

.crumb-title i {
  font-size: 10px;
  color: var(--dash-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions .nearby-btn,
.header-actions .notif-bell-btn {
  background: var(--dash-card);
  border: 1px solid var(--dash-hairline);
  box-shadow: var(--dash-shadow);
}

.account-chip {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--dash-ink);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

/* --- Map | List segmented toggle --- */
#view-toggle {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 700;
  display: flex;
  gap: 2px;
  background: var(--dash-card);
  border-radius: 999px;
  box-shadow: var(--dash-shadow);
  padding: 4px;
}

.view-toggle-btn {
  border: none;
  background: none;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--dash-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

.view-toggle-btn.is-active {
  background: var(--dash-ink);
  color: #fff;
}

/* --- Floating map control stack (zoom, recenter, settings) --- */
#map-controls {
  position: absolute;
  top: calc(var(--header-height) + 26px);
  right: 16px;
  z-index: 700;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-control-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: var(--dash-card);
  color: var(--dash-ink);
  box-shadow: var(--dash-shadow);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}

.map-control-btn:hover {
  background: var(--dash-page-bg);
}

.map-control-btn.is-active {
  background: var(--dash-ink);
  color: #fff;
}

/* --- Settings popover (holds relocated options: satellite, theme,
   hide panel, show-all-parks, edit coords, cotejo, admin) --- */
#map-settings-popover {
  position: absolute;
  top: calc(var(--header-height) + 26px + 3 * 52px);
  right: 68px;
  width: 250px;
  z-index: 900;
  background: var(--dash-card);
  border-radius: 14px;
  box-shadow: var(--dash-shadow);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#map-settings-popover.hidden {
  display: none;
}

#map-settings-popover button,
#map-settings-popover label {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--dash-ink);
  cursor: pointer;
  text-align: left;
}

#map-settings-popover button:hover,
#map-settings-popover label:hover {
  background: var(--dash-page-bg);
}

#map-settings-popover button i,
#map-settings-popover label i {
  width: 16px;
  text-align: center;
  color: var(--dash-muted);
  font-size: 14px;
}

#map-settings-popover .map-settings-divider {
  height: 1px;
  background: var(--dash-hairline);
  margin: 6px 4px;
}

/* Location row inside the settings popover (relocated from the sidebar) */
#map-settings-popover .location-settings-item .location-settings-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}

#map-settings-popover .location-settings-item .location-settings-status {
  font-size: 11px;
  font-weight: 500;
  color: var(--dash-muted);
}

#map-settings-popover .location-settings-item .location-settings-badge {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: var(--dash-ink);
  padding: 4px 12px;
  border-radius: 999px;
}

#map-settings-popover .location-settings-item.is-granted .location-settings-badge {
  background: var(--cond-green, #22a06b);
}

#map-settings-popover .location-settings-item:disabled {
  cursor: default;
}

#map-settings-popover label input[type="checkbox"] {
  margin: 0;
  accent-color: var(--dash-ink);
}

/* --- Top float bar + left panel: desktop-only positioning.
   Below 769px, styles.css already lays these out for mobile
   (icon-only pills, fixed sidebar-as-overlay); overriding them
   unconditionally here would fight that mobile-specific layout. */
@media (min-width: 769px) {
  #top-float-bar {
    top: calc(var(--header-height) + 26px);
    left: 16px;
    right: auto;
    width: var(--sidebar-width);
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  #top-float-bar #search-container,
  #top-float-bar .top-bar-section {
    flex: none;
    width: 100%;
  }

  /* --- Left dashboard panel: move from right to left --- */
  #sidebar {
    left: 16px;
    right: auto;
    top: calc(var(--header-height) + 26px + 112px);
  }

  /* --- Amenity filter: float on the right, left of the map controls.
     Selector must out-specify `#top-float-bar .top-bar-section`. --- */
  #top-float-bar #amenity-filter-section {
    position: fixed;
    top: calc(var(--header-height) + 26px);
    right: 76px;
    left: auto;
    width: 300px;
    z-index: 700;
  }
}

/* --- AI chat FAB: re-theme to match the light shell --- */
.ai-chat-fab {
  background: var(--dash-card);
  color: var(--dash-ink);
  box-shadow: var(--dash-shadow);
}

/* --- Sidebar cards: align with the dashboard's flat, borderless look --- */
.sidebar-section {
  border: none;
  border-radius: var(--dash-radius);
  box-shadow: var(--dash-shadow);
}

.sidebar-section:hover {
  border-color: transparent;
  box-shadow: var(--dash-shadow);
}

/* ==========================================================
   Dashboard stats card (hero gauge, condition chips, metric
   tiles, circunscripción chart)
   ========================================================== */
.dash-card {
  background: var(--dash-card);
  border-radius: var(--dash-radius);
  box-shadow: var(--dash-shadow);
  padding: 18px;
  margin-bottom: 14px;
}

.dash-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--dash-hairline);
}

#dash-hero-num {
  font-size: 40px;
  font-weight: 700;
  color: var(--dash-ink);
  line-height: 1;
}

.dash-hero-unit {
  font-size: 18px;
  font-weight: 600;
  color: var(--dash-muted);
  margin-left: 2px;
}

.dash-hero-label {
  font-size: 12px;
  color: var(--dash-muted);
  margin-top: 6px;
  max-width: 180px;
}

.dash-gauge {
  width: 10px;
  height: 64px;
  border-radius: 999px;
  background: var(--dash-hairline);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  flex-shrink: 0;
}

.dash-gauge-fill {
  width: 100%;
  height: 0%;
  background: var(--cond-green);
  border-radius: 999px;
  transition: height 0.4s ease;
}

.dash-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 16px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--dash-hairline);
}

.dash-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--dash-muted);
  background: var(--dash-page-bg);
  border-radius: 999px;
  padding: 5px 10px 5px 8px;
}

.dash-chip strong {
  color: var(--dash-ink);
}

.dash-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.dash-chip-dot--green { background: var(--cond-green); }
.dash-chip-dot--amber { background: var(--cond-amber); }
.dash-chip-dot--red { background: var(--cond-red); }
.dash-chip-dot--gray { background: var(--cond-gray); }

.dash-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.dash-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--dash-hairline);
}

.dash-tile:nth-last-child(-n+2) {
  border-bottom: none;
}

.dash-tile:nth-child(odd) {
  border-right: 1px solid var(--dash-hairline);
}

.dash-tile i {
  width: 18px;
  text-align: center;
  color: var(--dash-muted);
  font-size: 15px;
  flex-shrink: 0;
}

.dash-tile-info {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.dash-tile-info strong {
  font-size: 14px;
  color: var(--dash-ink);
}

.dash-tile-info span {
  font-size: 11px;
  color: var(--dash-muted);
}

.dash-chart-wrap {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--dash-hairline);
}

.dash-chart-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--dash-muted);
  margin-bottom: 8px;
}

/* ==========================================================
   List view (Mapa | Lista toggle)
   ========================================================== */
body.list-open #map,
body.list-open #map-legend,
body.list-open #map-controls,
body.list-open #top-float-bar,
body.list-open #sidebar {
  visibility: hidden;
}

body.list-open #list-view {
  display: flex !important;
}

#list-view {
  position: absolute;
  inset: 0;
  z-index: 400;
  background: var(--dash-page-bg);
  border-radius: var(--dash-radius);
  overflow: hidden;
  flex-direction: column;
  padding: calc(var(--header-height) + 26px) 16px 16px;
}

.list-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.list-search-box {
  flex: 1 1 260px;
  position: relative;
  display: flex;
  align-items: center;
  background: var(--dash-card);
  border-radius: 999px;
  box-shadow: var(--dash-shadow);
  height: 44px;
  padding: 0 16px 0 40px;
}

.list-search-box .search-icon {
  left: 16px;
  color: var(--dash-muted);
}

#list-search {
  width: 100%;
  border: none;
  background: none;
  outline: none;
  font-size: 13px;
  color: var(--dash-ink);
  font-family: inherit;
}

#list-sort {
  height: 44px;
  border: none;
  border-radius: 999px;
  background-color: var(--dash-card);
  /* Custom slate chevron (matches --dash-muted) — replaces the native OS arrow */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5' stroke='%2364748b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  box-shadow: var(--dash-shadow);
  padding: 0 38px 0 16px;
  font-size: 13px;
  color: var(--dash-ink);
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  outline: none;
}

#list-sort:hover {
  color: var(--dash-ink);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

#list-sort:focus-visible {
  box-shadow: var(--dash-shadow), 0 0 0 2px rgba(15, 23, 42, 0.25);
}

.list-cond-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.list-cond-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 44px;
  border: none;
  border-radius: 999px;
  background: var(--dash-card);
  box-shadow: var(--dash-shadow);
  padding: 0 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--dash-muted);
  cursor: pointer;
}

.list-cond-chip.is-active {
  background: var(--dash-ink);
  color: #fff;
}

.list-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  align-content: start;
  padding-bottom: 16px;
}

.list-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--dash-muted);
  font-size: 13px;
  padding: 40px 0;
}

.list-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--dash-card);
  border-radius: 14px;
  box-shadow: var(--dash-shadow);
  padding: 10px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.list-card:hover {
  transform: translateY(-2px);
}

.list-card-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--dash-page-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dash-muted);
  font-size: 20px;
}

.list-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.list-card-dot {
  position: absolute;
  bottom: 3px;
  right: 3px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid #fff;
}

.list-card-dot--green { background: var(--cond-green); }
.list-card-dot--amber { background: var(--cond-amber); }
.list-card-dot--red { background: var(--cond-red); }
.list-card-dot--gray { background: var(--cond-gray); }

.list-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.list-card-body strong {
  font-size: 13px;
  color: var(--dash-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-card-meta {
  font-size: 11px;
  color: var(--dash-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.list-card-badge {
  font-size: 10px;
  color: var(--dash-muted);
  background: var(--dash-page-bg);
  border-radius: 999px;
  padding: 2px 7px;
  white-space: nowrap;
}

.list-card-area {
  font-size: 11px;
  color: var(--dash-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

/* ==========================================================
   Mobile (<=768px): breadcrumb truncation, view-toggle and
   map-controls repositioned below the search/filter row so
   nothing collides in the crowded top band.
   ========================================================== */
@media (max-width: 768px) {
  :root {
    /* Bottom edge of the search/filter row (top-float-bar) — the first
       clear band below the header where floating controls can start. */
    --mobile-topbar-bottom: calc(max(12px, env(safe-area-inset-top)) + var(--header-height) + 12px + var(--topbar-pill-height));
    --mobile-view-toggle-h: 38px;
  }

  .header-logo-wide {
    display: none;
  }

  .header-logo-compact {
    display: block;
    height: 30px;
  }

  .crumb-overline {
    display: none;
  }

  .crumb-title {
    font-size: 13px;
    max-width: 34vw;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .crumb-title strong {
    display: none;
  }

  #view-toggle {
    top: calc(var(--mobile-topbar-bottom) + 10px);
    padding: 3px;
  }

  .view-toggle-btn {
    padding: 6px 14px;
    font-size: 12px;
  }

  #map-controls {
    top: calc(var(--mobile-topbar-bottom) + 10px + var(--mobile-view-toggle-h) + 10px);
    right: 12px;
    gap: 6px;
  }

  #map-zoom-in,
  #map-zoom-out {
    display: none;
  }

  .map-control-btn {
    width: 40px;
    height: 40px;
  }

  #map-settings-popover {
    top: calc(var(--mobile-topbar-bottom) + 10px + var(--mobile-view-toggle-h) + 58px);
    right: 60px;
    width: 220px;
  }

  .list-grid {
    grid-template-columns: 1fr;
  }

  #list-view {
    padding-top: calc(var(--mobile-topbar-bottom) + 10px + var(--mobile-view-toggle-h) + 12px);
  }
}
