/* ==========================================================================
   LA Move HQ — styles
   Clean, modern, light theme, blue accent. No frameworks.
   ========================================================================== */

:root {
  --accent: #1d4ed8;
  --accent-dark: #1e40af;
  --accent-soft: #eff4ff;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e2e5ea;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --topbar-h: 52px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

.hidden { display: none !important; }

/* ============================ LOGIN ============================ */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(29, 78, 216, 0.18), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(147, 51, 234, 0.12), transparent 55%),
    linear-gradient(160deg, #f8fafc, #eef1f6);
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow), 0 20px 60px rgba(15, 23, 42, 0.12);
  padding: 36px 32px 32px;
  text-align: center;
}

.login-logo { font-size: 34px; line-height: 1; margin-bottom: 8px; }

.login-title {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.login-subtitle {
  margin: 0 0 24px;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
}

.login-card form { text-align: left; }

.login-error {
  min-height: 18px;
  margin: 6px 0 10px;
  font-size: 13px;
  color: var(--danger);
  font-weight: 500;
}

/* ============================ TOP BAR ============================ */

.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: relative;
  z-index: 1100;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.05);
}

.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }

.topbar-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--accent);
  white-space: nowrap;
}

.topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }

.user-chip {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1px solid #cdddfb;
  border-radius: 999px;
  padding: 5px 12px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================ LAYERS PANEL ============================ */

.layers-panel {
  position: absolute;
  top: calc(var(--topbar-h) + 10px);
  left: 10px;
  bottom: 10px;
  z-index: 1000;
  width: 292px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.layers-panel.closed {
  transform: translateX(calc(-100% - 20px));
  opacity: 0;
  pointer-events: none;
}

.panel-inner {
  overflow-y: auto;
  padding: 14px 14px 16px;
  -webkit-overflow-scrolling: touch;
}

.panel-section { display: flex; flex-direction: column; gap: 4px; }

.panel-heading {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* Toggle switch row */
.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease;
}

.switch-row:hover { background: #f4f6fa; }

.switch-row input.switch { position: absolute; opacity: 0; pointer-events: none; }

.switch-ui {
  position: relative;
  flex: 0 0 38px;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #d3d8e0;
  transition: background 0.18s ease;
}

.switch-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s ease;
}

.switch-row input.switch:checked + .switch-ui { background: var(--accent); }
.switch-row input.switch:checked + .switch-ui::after { transform: translateX(16px); }

.switch-row input.switch:focus-visible + .switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }

.switch-row.disabled { opacity: 0.55; cursor: not-allowed; }
.switch-row.disabled:hover { background: transparent; }

.switch-label { font-size: 14px; font-weight: 500; }

/* Sub-controls (field selector, legends, buttons) */
.sub-controls {
  padding: 2px 6px 8px 54px;
  display: none;
  flex-direction: column;
  gap: 8px;
}

.sub-controls.open { display: flex; }

.select-input {
  width: 100%;
  font: inherit;
  font-size: 13px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  outline: none;
}

.select-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12); }

/* Segmented control (heat vs dots) */
.seg-control {
  display: inline-flex;
  background: #eef1f5;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
  width: fit-content;
}

.seg-btn {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.seg-btn.active { background: var(--card); color: var(--accent); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12); }

/* Legends */
.legend { display: flex; flex-direction: column; gap: 3px; }

.legend-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  margin: 2px 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.legend-row { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text); }

.legend-item { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.legend-note {
  margin: 4px 0 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
}

.panel-note {
  margin: 14px 6px 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}

.panel-note code { background: #f1f3f7; border-radius: 4px; padding: 1px 4px; font-size: 11px; }

/* Panel action buttons */
.panel-actions { display: flex; gap: 8px; margin-bottom: 6px; }
.panel-actions .btn { flex: 1; }

/* ============================ MAP ============================ */

#map {
  flex: 1;
  min-height: 0;
  width: 100%;
  background: #e8ebef;
}

/* Popups */
.leaflet-popup-content-wrapper {
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.16);
}

.leaflet-popup-content { margin: 12px 14px; line-height: 1.45; }

.popup { min-width: 230px; max-width: 300px; font-size: 13px; }

.popup h3 {
  margin: 0 0 2px;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.3;
}

.popup .popup-sub {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
}

.popup .popup-price {
  font-size: 15px;
  font-weight: 700;
  margin: 4px 0;
}

.popup .popup-row { margin: 3px 0; font-size: 12.5px; }
.popup .popup-row b { font-weight: 600; }

.popup .popup-status {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 999px;
  padding: 2px 9px;
  margin: 2px 0;
}

.popup .avail-line { font-size: 12px; margin: 6px 0 2px; }
.avail-yes { color: #15803d; font-weight: 600; }
.avail-no { color: var(--danger); font-weight: 600; }
.avail-unknown { color: var(--muted); }

.popup .popup-link {
  display: inline-block;
  margin: 6px 0 2px;
  color: var(--accent);
  font-weight: 600;
  word-break: break-all;
}

.popup details {
  margin: 8px 0;
  background: #f6f8fb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 9px;
}

.popup details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 12.5px;
}

.popup details p {
  margin: 6px 0 2px;
  font-size: 12.5px;
  color: #374151;
}

/* Notes inside popup */
.popup-notes { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px; }

.popup-notes h4 {
  margin: 0 0 6px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.note-list { display: flex; flex-direction: column; gap: 6px; max-height: 140px; overflow-y: auto; }

.note-item {
  background: #f6f8fb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 12.5px;
}

.note-item .note-body { margin: 0 0 3px; white-space: pre-wrap; }

.note-item .note-meta { font-size: 11px; color: var(--muted); }

.note-form { display: flex; gap: 6px; margin-top: 8px; }

.note-form input {
  flex: 1;
  font: inherit;
  font-size: 12.5px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}

.note-form input:focus { border-color: var(--accent); }

.note-form .btn { padding: 6px 12px; font-size: 12.5px; }

.popup-actions { display: flex; gap: 8px; margin-top: 10px; }
.popup-actions .btn { flex: 1; }

/* ============================ BUTTONS / INPUTS ============================ */

.btn {
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background 0.12s ease, box-shadow 0.12s ease, transform 0.05s ease;
}

.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }

.btn-secondary {
  background: #eef1f5;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #e4e8ee; }

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f1f3f7; color: var(--text); }

.btn-danger { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  font-size: 15px;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover { background: #f1f3f7; }

.text-input, textarea.text-input {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12); }
textarea.text-input { resize: vertical; }

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 12px 0 5px;
}

/* ============================ MODAL ============================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
  margin: auto 0;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 { margin: 0; font-size: 17px; font-weight: 700; }

.modal-form { padding: 6px 20px 20px; overflow-y: auto; }

.form-row { display: flex; gap: 12px; }
.form-row > div { flex: 1; min-width: 0; }
.form-row-4 > div { flex: 1 1 0; }

.geo-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.geo-status { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.geo-status.ok { color: #15803d; }
.geo-status.err { color: var(--danger); }

.pin-hint {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1px dashed #9dbaf5;
  border-radius: 8px;
  padding: 8px 10px;
}

.program-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid #cdddfb;
  border-radius: 999px;
  padding: 2px 8px;
  margin: 1px 0;
}

/* Floating banner shown while "click map to set pin" is active */
.pin-banner {
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2100;
  background: var(--accent-dark);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 10px;
  padding: 11px 18px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.3);
  pointer-events: none;
  animation: toast-in 0.18s ease;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ============================ TOAST ============================ */

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2500;
  background: #1f2430;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  border-radius: 999px;
  padding: 10px 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  max-width: min(90vw, 480px);
  text-align: center;
  animation: toast-in 0.18s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================ MOBILE ============================ */

@media (max-width: 720px) {
  .layers-panel {
    width: min(320px, calc(100vw - 24px));
    top: calc(var(--topbar-h) + 6px);
    bottom: auto;
    max-height: calc(100vh - var(--topbar-h) - 12px);
    border-radius: 12px;
  }

  .layers-panel.closed {
    transform: translateX(calc(-100% - 30px));
  }

  .topbar-title { font-size: 15px; }
  .user-chip { max-width: 130px; }
  .form-row { flex-direction: column; gap: 0; }
  .modal-overlay { padding: 12px 10px; }
  .modal-card { max-height: calc(100vh - 24px); }
}
