/* Redlands Property App (POC) */
:root{
  --bg: #0b0f14;
  --panel: rgba(15, 20, 28, 0.92);
  --text: #e9eef5;
  --muted: rgba(233, 238, 245, 0.72);
  --stroke: rgba(135, 206, 235, 0.65); /* skyblue @ 60% */
  --fill: rgba(169, 176, 199, 0.65);   /* white @ 88% */
  --sel-fill: rgba(255, 215, 0, 0.22);
  --sel-stroke: rgba(20, 20, 20, 0.95);
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --radius: 12px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

*{ box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-family: var(--font); background: #0b0f14; color: var(--text); }

.value-inputs{
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 10px;
  align-items: center;
}

@media (max-width: 740px){
  .value-inputs{
    grid-template-columns: 1fr;
  }
}

.app-header{
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 16px;
  background: linear-gradient(to bottom, rgba(11,15,20,0.96), rgba(11,15,20,0.86));
  border-bottom: 1px solid rgba(255,255,255,0.08);
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.title{
  font-size: 18px;
  letter-spacing: 0.2px;
  font-weight: 650;
}

#hamburgerBtn { cursor: pointer !important; pointer-events: auto !important; }

.hamburger{
  width: 42px;
  height: 36px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  cursor: pointer;
  display: grid;
  place-content: center;
  gap: 5px;
}
.hamburger span{
  display: block;
  width: 18px;
  height: 2px;
  background: rgba(255,255,255,0.9);
  border-radius: 999px;
}

.filter-panel{
  position: fixed;
  top: 56px;

  /* align with hamburger edge (header has 14px right padding) */
  right: 14px;
  left: auto;

  /* <= 20% viewport width, <= 400px, with a sensible minimum */
  width: min(400px, 20vw);
  min-width: 320px;

  transform: translateY(-120%);
  transition: transform 220ms ease, opacity 220ms ease;
  opacity: 0;
  z-index: 999;
  pointer-events: none; /* prevent “invisible” panel capturing clicks */
}

.filter-panel.open{
  transform: translateY(0%);
  opacity: 1;
  pointer-events: auto;
}

/* Filter panel internals: spacing + consistent control sizing */
.filter-inner{
  display: grid;
  gap: 12px;

  /* THIS is the missing “card” that makes the panel visible */
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}


.panel-block{
  padding: 12px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.1); /* was 0.04 */
  border: 1px solid rgba(255,255,255,0.10);
}

.search-stack,
.value-stack{
  display: grid;
  gap: 10px;
}

.filter-control{
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  outline: none;
  font-size: 14px;
}

.filter-control::placeholder{
  color: rgba(233,238,245,0.45);
}


/* ---- Mobile: panel slides over map full-screen ---- */
@media (max-width: 740px){
  .filter-panel{
    top: 56px;
    left: 0;
    right: 0;
    width: 100%;
    min-width: 0;
    height: calc(100% - 56px);

    transform: translateX(105%);
    opacity: 1;                 /* keep opaque; we animate via translate */
    transition: transform 220ms ease;

    border-radius: 0;
    pointer-events: none;
    overflow: auto;
  }

  .filter-panel.open{
    transform: translateX(0%);
    pointer-events: auto;
  }

  .filter-inner{
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    min-height: 100%;
  }
}

.panel-block{
  padding: 10px 10px;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
}

.block-title{
  font-weight: 800;
  font-size: 12px;
  color: rgba(233,238,245,0.85);
  margin-bottom: 10px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.divider{
  border: none;
  height: 1px;
  margin: 12px 2px;
  background: linear-gradient(to right,
    rgba(255,255,255,0.06),
    rgba(255,255,255,0.18),
    rgba(255,255,255,0.06)
  );
}

/* Search row tighter (mode + input + button) */
.filter-row.search-row{
  grid-template-columns: 140px 1fr auto;
}

/* Value inputs grid already present; keep this for desktop */
.value-inputs{
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 10px;
  align-items: center;
}

@media (max-width: 740px){
  .value-inputs{ grid-template-columns: 1fr; }
}


.filter-row.value-row{
  grid-template-columns: 1fr;
  gap: 10px;
}

.divider{
  border: none;
  height: 1px;
  margin: 2px 2px;
  background: linear-gradient(to right,
    rgba(255,255,255,0.06),
    rgba(255,255,255,0.18),
    rgba(255,255,255,0.06)
  );
}

.filter-label{
  color: rgba(233,238,245,0.70);
  font-weight: 750;
  font-size: 12px;
  letter-spacing: 0.2px;
  margin: 0 0 8px 2px;
  text-transform: uppercase;
}


.filter-control{
  width: 100%;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  outline: none;
}

.btn-row{
  display: grid;
  gap: 10px;
}

.btn-row.two{
  grid-template-columns: 1fr 1fr;
}

.btn{
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
  font-weight: 750;
}

.btn.secondary{
  background: rgba(135,206,235,0.10);
  border-color: rgba(135,206,235,0.25);
}

.btn.ghost{
  background: transparent;
  border-color: rgba(255,255,255,0.10);
  color: rgba(233,238,245,0.72);
}

.btn:hover{ background: rgba(255,255,255,0.10); }

.btn.secondary:hover{ background: rgba(135,206,235,0.16); }

.btn.ghost:hover{ background: rgba(255,255,255,0.06); color: var(--text); }

.filter-row.small{
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-top: 10px;
}

.status{
  color: rgba(233,238,245,0.72);
  font-size: 12px;
}

.hint{
  color: rgba(233,238,245,0.48);
  font-size: 12px;
}


.main{
  position: fixed;
  top: 56px;
  left: 0; right: 0; bottom: 0;
}

#map{
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

/* Keep Leaflet UI behind header/panels */
.leaflet-top, .leaflet-bottom{ z-index: 10; }

/* Legend */
.legend{
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 400;
  width: 240px;
  background: rgba(15,20,28,0.88);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.legend-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.legend-title{
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}
.legend-toggle{
  width: 30px; height: 26px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
}
.legend-body{ padding: 10px 12px 12px 12px; }

.leg-item{
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
  color: var(--muted);
  font-size: 13px;
}

.swatch{
  width: 18px;
  height: 14px;
  border-radius: 4px;
  border: 2px solid transparent;
  display: inline-block;
}
.swatch.parcel{
  background: var(--fill);
  border-color: var(--stroke);
}
.swatch.selected{
  background: var(--sel-fill);
  border-color: var(--sel-stroke);
}
.leg-note{
  margin-top: 10px;
  font-size: 11px;
  color: rgba(233,238,245,0.52);
  line-height: 1.35;
}

/* Sources button */
.sources-btn{
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 400;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(15,20,28,0.78);
  color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.sources-btn:hover{ background: rgba(15,20,28,0.92); }

/* Modal */
.modal{
  position: absolute;
  inset: 0;
  z-index: 900;
  display: none;
  background: rgba(0,0,0,0.35);
}
.modal.open{ display: grid; place-items: center; }
.modal-card{
  width: min(720px, calc(100% - 28px));
  background: rgba(15,20,28,0.95);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-head{
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.modal-title{ font-weight: 800; }
.modal-close{
  width: 34px; height: 30px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
}
.modal-body{
  padding: 14px 14px 16px 14px;
  color: var(--muted);
  line-height: 1.45;
}
.modal-body p{ margin: 8px 0; }
.modal-body .made-with{ margin-top: 12px; color: rgba(233,238,245,0.78); }
.modal-body .smallprint{ font-size: 12px; color: rgba(233,238,245,0.55); }

/* Loading overlay */
.loading{
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 600;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(15,20,28,0.90);
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.loading.show{ display: flex; }
.spinner{
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.22);
  border-top-color: rgba(255,255,255,0.85);
  animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Popup styling: readable, white 88% alpha ---- */
.leaflet-popup-content-wrapper{
  border-radius: 16px;
  background: rgba(255,255,255,0.88);
  color: rgba(12,14,18,0.92);
  border: 1px solid rgba(0,0,0,0.10);
  box-shadow: 0 16px 50px rgba(0,0,0,0.28);
}

.leaflet-popup-tip{
  background: rgba(255,255,255,0.88);
  box-shadow: 0 10px 22px rgba(0,0,0,0.18);
}

.leaflet-popup-content{
  margin: 14px 16px;
}

.popup{
  max-width: 340px;
  font-family: var(--font);
  user-select: text; /* allow copy/paste inside */
}

.popup-title{
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.2px;
  margin-bottom: 10px;
  color: rgba(12,14,18,0.92);
}

.popup-line{
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

.popup-line:last-child{
  border-bottom: none;
}

.popup .k{
  min-width: 108px;
  font-size: 13px;
  font-weight: 800;
  color: rgba(12,14,18,0.68);
}

.popup .v{
  font-size: 14px;
  font-weight: 650;
  color: rgba(12,14,18,0.92);
  overflow-wrap: anywhere; /* wrap long owner names / addresses */
  line-height: 1.25;
}


/* Responsive tweaks */
@media (max-width: 740px){
  .btn-row.two{
    grid-template-columns: 1fr;
  }
}
