/* Map Layers — layers button + panel on the main incident map (index.php) */

/* Tokens are scoped to the wrapper so they don't collide with main.css. The web app is
   dark-only today; add a light set here if/when a light theme ships. */
.ml {
  display: contents;
  --ml-background: var(--navy-page, #1A2239);
  --ml-surface: var(--navy-surface, #232840);
  --ml-border: var(--border-default, #2E3352);
  --ml-text-primary: #FFFFFF;
  --ml-text-secondary: #D0CDCE;
  --ml-text-subtle: rgba(255, 255, 255, .5);
  --ml-text-muted: #5C6078;
  --ml-divider-subtle: rgba(255, 255, 255, .15);
  --ml-icon-wrap-bg: rgba(255, 255, 255, .13);
  --ml-chip-bg: var(--navy-card, #2A2F4A);
  --ml-border-faint: rgba(255, 255, 255, .18);
  --ml-danger: var(--accent-red, #EA4B4B);
  --ml-primary: var(--brand-primary, #F55A21);
}

.map-container {
  position: relative;
}

/* ===== Layers button ===== */
.ml-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 6;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ml-chip-bg);
  border: 1px solid var(--ml-border-faint);
  color: var(--ml-text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.ml-btn:hover {
  background: var(--navy-card-light, #303556);
}

.ml-btn:focus-visible,
.ml-close:focus-visible,
.ml-expand:focus-visible,
.ml-switch:focus-visible {
  outline: 2px solid var(--ml-primary);
  outline-offset: 2px;
}

.ml-btn svg {
  width: 18px;
  height: 18px;
}

.ml-btn-dot {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--ml-danger);
  border: 2px solid var(--ml-background);
}

/* Hidden while the panel is open — the panel's X closes it */
.map-container.ml-open .ml-btn {
  display: none;
}

/* ===== Panel container ===== */
.ml-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  width: 360px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--ml-surface);
  border-left: 1px solid var(--ml-border);
  border-radius: 0 var(--radius-xl, 16px) var(--radius-xl, 16px) 0;
  overflow: hidden;
  color: var(--ml-text-primary);
}

.ml-backdrop {
  display: none;
}

.ml-panel[hidden],
.ml-backdrop[hidden] {
  display: none !important;
}

@media (max-width: 699px) {
  .ml-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.55);
  }

  .ml-panel {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2001;
    width: auto;
    max-height: 85vh;
    border-left: 0;
    border-top: 1px solid var(--ml-border);
    border-radius: 24px 24px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ===== Header ===== */
.ml-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px 8px;
  border-bottom: 1px solid var(--ml-border);
}

.ml-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 20px;
  color: var(--ml-text-primary);
}

.ml-close {
  width: 36px;
  height: 36px;
  margin-right: -9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  border-radius: 50%;
  padding: 0;
  color: var(--ml-text-muted);
  cursor: pointer;
}

.ml-close:hover {
  color: var(--ml-text-secondary);
}

.ml-close svg {
  width: 18px;
  height: 18px;
}

/* ===== Body / sections ===== */
.ml-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 8px;
}

.ml-section-label {
  margin: 12px 0 0;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ml-text-subtle);
}

.ml-item {
  position: relative;
}

/* Divider between rows in a section; never above a section label */
.ml-item + .ml-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 16px;
  right: 16px;
  height: 1px;
  background: var(--ml-divider-subtle);
}

/* ===== Row ===== */
.ml-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
}

.ml-row.is-clickable {
  cursor: pointer;
}

.ml-row.is-clickable:hover {
  background: rgba(255, 255, 255, 0.04);
}

.ml-row-text {
  flex: 1 1 auto;
  min-width: 0;
}

.ml-row-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 6px;
  row-gap: 2px;
  font-size: 15px;
  font-weight: 500;
  line-height: 19px;
  color: var(--ml-text-primary);
}

.ml-row-desc {
  margin-top: 1px;
  font-size: 12px;
  font-weight: 400;
  line-height: 16px;
  color: var(--ml-text-subtle);
}

.ml-row.is-locked .ml-row-title {
  color: var(--ml-divider-subtle);
}

.ml-row.is-soon {
  opacity: 0.45;
}

.ml-pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--ml-icon-wrap-bg);
  color: var(--ml-text-muted);
  font-size: 10px;
  font-weight: 500;
  line-height: 14px;
}

/* Incidents row: text area is its own expand/collapse button */
.ml-expand {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 8px;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.ml-expand .ml-row-title,
.ml-expand .ml-row-desc {
  display: block;
}

.ml-chevron {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  color: var(--ml-text-muted);
  transition: transform 0.15s ease;
}

.ml-expand[aria-expanded="true"] .ml-chevron {
  transform: rotate(90deg);
}

/* Sub-rows */
.ml-subrow {
  padding: 5px 16px 5px 40px;
}

.ml-subrow .ml-row-title {
  font-size: 14px;
  font-weight: 400;
  color: var(--ml-text-secondary);
}

.ml-subrow.is-locked .ml-row-title {
  color: var(--ml-divider-subtle);
}

/* ===== Toggle ===== */
.ml-switch {
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(60, 60, 67, 0.3);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.ml-switch[aria-checked="true"] {
  background: #34C759;
}

.ml-switch:disabled {
  cursor: default;
}

.ml-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 28px;
  height: 20px;
  border-radius: 999px;
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}

.ml-switch[aria-checked="true"] .ml-switch-thumb {
  transform: translateX(16px);
}

@media (prefers-reduced-motion: reduce) {
  .ml-switch,
  .ml-switch-thumb,
  .ml-chevron {
    transition: none;
  }
}

/* ===== Property Ownership (js/parcels.js) ===== */
.ml-hint {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--ml-chip-bg);
  border: 1px solid var(--ml-border-faint);
  color: var(--ml-text-secondary);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.ml-hint[hidden] {
  display: none;
}

/* Parcels and hydrants hints can show together — stack them */
.ml-hint:not([hidden]) ~ .ml-hint:not([hidden]) {
  top: 52px;
}

.parcel-popup {
  width: 300px;
  max-width: calc(100vw - 48px);
  background: #232840;
  border: 1px solid #2E3352;
  border-radius: 12px;
  padding: 14px 16px;
  color: #FFFFFF;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  font-size: 13px;
  line-height: 18px;
  /* Always short enough to fit on the map, even the 60vh mobile one */
  max-height: min(440px, 50vh);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.parcel-popup a {
  color: #E8612D;
  font-weight: 600;
}

.pp-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 20px;
  padding-right: 12px;
}

.pp-owner {
  margin-top: 4px;
  color: #F5A623;
  font-weight: 600;
}

.pp-sub,
.pp-loading,
.pp-msg {
  color: #D0CDCE;
}

.pp-sub {
  margin-top: 2px;
  font-size: 12px;
  opacity: .7;
}

.pp-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin: 12px 0 0;
}

.pp-stats dt {
  font-size: 11px;
  color: rgba(255, 255, 255, .5);
}

.pp-stats dd {
  margin: 0;
  color: #D0CDCE;
  overflow-wrap: anywhere;
}

.pp-mail {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, .1);
  color: #D0CDCE;
}

.pp-mail span {
  display: block;
  font-size: 11px;
  color: rgba(255, 255, 255, .5);
}

.pp-units {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  border-top: 1px solid rgba(255, 255, 255, .1);
}

.pp-units li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.pp-unit-addr {
  font-weight: 500;
}

.pp-unit-owner {
  color: #F5A623;
}

.pp-unit-meta {
  font-size: 11px;
  color: rgba(255, 255, 255, .5);
}

.pp-attrib {
  margin-top: 14px;
  text-align: center;
  font-size: 10px;
  line-height: 14px;
  color: rgba(255, 255, 255, .4);
}

/* ===== Fire Hydrants (js/hydrants.js) and LADWP Outages (js/outages.js) — reuse the property card ===== */
.hydrant-popup,
.outage-popup {
  /* Crews copy these values */
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}

.pp-stats .pp-stat-wide {
  grid-column: 1 / -1;
}
