/* =====================================================================
   PolyWater — Cal Poly palette
   Green #154734 · Gold #C69214
   ===================================================================== */

:root {
  --green:      #154734;
  --green-dark: #0C2A1F;
  --green-mid:  #1E6349;
  --green-soft: #2C7A5B;
  --gold:       #C69214;
  --gold-light: #E5B93C;
  --cream:      #FAF7EF;
  --ink:        #12211B;
  --muted:      #6B7F76;
  --line:       #E2E8E4;

  --s-green:   #1FA85A;
  --s-yellow:  #E0A21A;
  --s-red:     #D64545;
  --s-broken:  #6B7280;
  --s-unknown: #A9B8B1;

  --topbar-h: 66px;
  --shadow-sm: 0 2px 8px rgba(12, 42, 31, .12);
  --shadow-md: 0 10px 30px rgba(12, 42, 31, .22);
  --radius: 14px;
}

* { box-sizing: border-box; }

/* Must come before any display rules: `hidden` has to win over display:flex. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- top */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topbar-h);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: linear-gradient(140deg, var(--green-mid), var(--green-dark));
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark { width: 36px; height: 36px; flex: none; }
.brand-text { min-width: 0; }
.brand-text h1 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -.4px;
  line-height: 1.1;
  white-space: nowrap;
}
.brand-text h1 span { color: var(--gold-light); }
.brand-text p {
  margin: 2px 0 0;
  font-size: 12px;
  color: #C5DCD1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

/* ------------------------------------------------------------- buttons */
.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease, background .15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }

.btn-gold { background: var(--gold-light); color: var(--green-dark); }
.btn-gold:hover { filter: brightness(1.06); }
.btn-gold:disabled { opacity: .55; cursor: not-allowed; }

.btn-ghost {
  background: rgba(255,255,255,.12);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn-ghost:hover { background: rgba(255,255,255,.2); }

.btn-block { width: 100%; padding: 13px; font-size: 15px; margin-top: 4px; }

.btn-outline {
  background: transparent;
  color: var(--green);
  border: 1.5px solid var(--line);
}
.btn-outline:hover { border-color: var(--green-soft); }

.link-btn {
  background: none; border: 0; padding: 0;
  color: var(--gold-light); font: inherit; font-weight: 600;
  text-decoration: underline; cursor: pointer;
}

.dot-live {
  width: 8px; height: 8px; border-radius: 50%;
  background: #4ADE80; display: inline-block;
  box-shadow: 0 0 0 0 rgba(74,222,128,.7);
  animation: pulse 2.2s infinite;
}
@keyframes pulse {
  70%  { box-shadow: 0 0 0 7px rgba(74,222,128,0); }
  100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
}

/* ---------------------------------------------------------------- map */
#map {
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  /* Campus view has no tiles — this warm paper ground is the basemap. */
  background: #F2EFE5;
}
body.streets-on #map { background: #DFE7E2; }
.leaflet-container { font: inherit; }

/* Building footprints ------------------------------------------------ */
.bldg-tip {
  background: var(--green-dark);
  color: #fff;
  border: 0;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 9px;
  box-shadow: var(--shadow-sm);
}
.bldg-tip::before { display: none; }

.bldg-label {
  font-size: 9px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: .1px;
  color: #4A6357;
  text-align: center;
  text-shadow: 0 0 3px #F2EFE5, 0 1px 0 #F2EFE5, 0 -1px 0 #F2EFE5,
               1px 0 0 #F2EFE5, -1px 0 0 #F2EFE5;
  pointer-events: none;
  white-space: normal;
  margin-left: -46px !important;
  display: none;
}
.bldg-label.is-major { display: block; font-size: 10px; font-weight: 700; color: #33513F; }
body.labels-minor .bldg-label { display: block; }

/* Soft lift so buildings sit above the ground plane. */
.leaflet-pane.pw-buildings { filter: drop-shadow(0 1px 1.5px rgba(24, 48, 36, .18)); }
.leaflet-pane.pw-buildings path { transition: fill .18s ease; }
body.streets-on .bldg-label { display: none; }

/* Basemap toggle ----------------------------------------------------- */
.basemap-toggle {
  position: fixed;
  top: calc(var(--topbar-h) + 14px);
  left: 14px;
  z-index: 700;
  display: flex;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(6px);
  border-radius: 999px;
  padding: 3px;
  box-shadow: var(--shadow-sm);
}
.basemap-toggle button {
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.basemap-toggle button.is-on { background: var(--green); color: #fff; }

/* Droplet markers */
.pw-pin {
  width: 34px; height: 43px;
  display: grid; place-items: center;
  filter: drop-shadow(0 3px 4px rgba(12,42,31,.35));
  cursor: pointer;
  transition: transform .12s ease;
}
.pw-pin:hover { transform: translateY(-3px) scale(1.08); }
.pw-pin svg { width: 100%; height: 100%; }
.pw-pin.is-active { transform: scale(1.22); z-index: 900 !important; }

/* ------------------------------------------------------------- legend */
.legend {
  position: fixed;
  left: 14px;
  bottom: 34px;
  z-index: 700;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(6px);
  border-radius: var(--radius);
  padding: 11px 14px;
  box-shadow: var(--shadow-sm);
  font-size: 12.5px;
}
.legend-title {
  display: block;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 7px;
  font-size: 11px;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.legend ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.legend li { display: flex; align-items: center; gap: 8px; color: #33463E; }
.swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.s-green  .swatch, .swatch.s-green   { background: var(--s-green); }
.s-yellow .swatch, .swatch.s-yellow  { background: var(--s-yellow); }
.s-red    .swatch, .swatch.s-red     { background: var(--s-red); }
.s-broken .swatch, .swatch.s-broken  { background: var(--s-broken); }
.swatch.s-unknown { background: var(--s-unknown); }

/* ---------------------------------------------------------------- FAB */
.fab {
  position: fixed;
  right: 16px;
  bottom: 34px;
  z-index: 700;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 13px 20px 13px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--gold-light);
  color: var(--green-dark);
  font: inherit;
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform .1s ease, filter .15s ease;
}
.fab:hover { filter: brightness(1.06); }
.fab:active { transform: scale(.96); }
.fab-plus { font-size: 21px; line-height: 1; margin-top: -2px; }
.fab.is-armed { background: var(--green); color: #fff; }

.add-banner {
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  background: var(--green-dark);
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow-md);
}
.map-adding { cursor: crosshair !important; }

/* -------------------------------------------------------------- sheet */
.sheet {
  position: fixed;
  z-index: 800;
  right: 16px;
  top: calc(var(--topbar-h) + 16px);
  width: 370px;
  max-height: calc(100vh - var(--topbar-h) - 100px);
  overflow-y: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  padding: 20px 20px 22px;
  animation: sheetIn .18s ease;
}
@keyframes sheetIn { from { opacity: 0; transform: translateY(-8px); } }

.sheet-close {
  position: absolute;
  top: 12px; right: 14px;
  background: none; border: 0;
  font-size: 26px; line-height: 1;
  color: var(--muted); cursor: pointer;
}
.sheet-close:hover { color: var(--ink); }

.sheet h2 {
  margin: 0 28px 3px 0;
  font-size: 19px;
  letter-spacing: -.3px;
  color: var(--green-dark);
}
.sheet .building { margin: 0; color: var(--muted); font-size: 13.5px; }
.sheet .detail  { margin: 8px 0 0; font-size: 13.5px; color: #46584F; }

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 4px;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
}
.status-chip small { font-weight: 500; opacity: .85; }
.chip-green  { background: var(--s-green); }
.chip-yellow { background: var(--s-yellow); }
.chip-red    { background: var(--s-red); }
.chip-broken { background: var(--s-broken); }
.chip-unknown{ background: var(--s-unknown); }

.sheet-photo {
  width: 100%;
  border-radius: 12px;
  margin: 14px 0 0;
  display: block;
  border: 1px solid var(--line);
}

.sheet-actions { display: flex; gap: 8px; margin: 16px 0 4px; }
.sheet-actions .btn { flex: 1; padding: 11px; }

.history-title {
  margin: 20px 0 8px;
  font-size: 11px;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.history li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
  color: #46584F;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}
.history li:last-child { border-bottom: 0; }
.history .h-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; flex: none; }
.history .h-when { color: var(--muted); font-size: 12px; }
.history .h-note { display: block; margin-top: 2px; }
.history a { color: var(--green-soft); }
.empty { font-size: 13px; color: var(--muted); margin: 6px 0 0; }

/* ------------------------------------------------------------- modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(12, 42, 31, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }

.modal-card {
  position: relative;
  background: #fff;
  border-radius: 20px;
  padding: 26px 26px 28px;
  width: min(430px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  animation: cardIn .18s ease;
}
@keyframes cardIn { from { transform: translateY(14px); opacity: 0; } }

.modal-close {
  position: absolute;
  top: 14px; right: 16px;
  background: none; border: 0;
  font-size: 27px; line-height: 1;
  color: var(--muted); cursor: pointer;
}
.modal-card h2 {
  margin: 0 0 4px;
  font-size: 21px;
  color: var(--green-dark);
  letter-spacing: -.3px;
}
.modal-sub { margin: 0 0 18px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }

.field { display: block; margin: 14px 0; }
.field > span {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 6px;
}
.field > span small { font-weight: 500; color: var(--muted); }
.field input[type="text"],
.field input[type="email"] {
  width: 100%;
  font: inherit;
  font-size: 15px;
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: #FCFDFC;
}
.field input:focus {
  outline: none;
  border-color: var(--green-soft);
  box-shadow: 0 0 0 3px rgba(44,122,91,.13);
}
.field input[type="file"] { font-size: 13px; width: 100%; }

.status-picker { border: 0; padding: 0; margin: 0 0 6px; }
.status-picker legend {
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
  padding: 0;
  margin-bottom: 9px;
}
.status-opt {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.status-opt:hover { background: #F7FAF8; }
.status-opt input { accent-color: var(--green); width: 17px; height: 17px; flex: none; }
.status-body { display: flex; flex-direction: column; }
.status-body strong { font-size: 14.5px; }
.status-body small { color: var(--muted); font-size: 12.5px; }
.status-opt.s-green:has(input:checked)  { border-color: var(--s-green);  background: #EFFAF3; }
.status-opt.s-yellow:has(input:checked) { border-color: var(--s-yellow); background: #FEF8EA; }
.status-opt.s-red:has(input:checked)    { border-color: var(--s-red);    background: #FDF0F0; }
.status-opt.s-broken:has(input:checked) { border-color: var(--s-broken); background: #F4F5F6; }

.photo-preview {
  width: 100%;
  border-radius: 12px;
  margin-top: -4px;
  border: 1px solid var(--line);
}

.auth-msg {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 11px;
  background: #EFFAF3;
  color: #14663B;
  font-size: 13.5px;
  line-height: 1.5;
}
.auth-msg.is-error { background: #FDF0F0; color: #8C2020; }

/* -------------------------------------------------------------- toast */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1500;
  background: var(--green-dark);
  color: #fff;
  padding: 13px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: cardIn .18s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.is-error { background: #8C2020; }

/* --------------------------------------------------------- responsive */
@media (max-width: 720px) {
  .brand-text p { display: none; }
  .brand-text h1 { font-size: 19px; }
  #locateBtn .btn-label { display: none; }

  .sheet {
    right: 0; left: 0;
    top: auto;
    bottom: 0;
    width: auto;
    max-height: 72vh;
    border-radius: 20px 20px 0 0;
    animation: sheetUp .2s ease;
  }
  @keyframes sheetUp { from { transform: translateY(30px); opacity: 0; } }

  .legend { display: none; }
  .fab { bottom: 26px; right: 12px; padding: 12px 17px 12px 14px; }
  body:has(.sheet:not([hidden])) .fab { display: none; }
  .fab-label { display: none; }
  .fab-plus { font-size: 24px; margin: 0; }
}
