/* Ceibos Dialoga — Guayaquil Triste, mobile first */

:root {
  --bg: #f8fafc;
  --ink: #475569;
  --ink-strong: #334155;
  --muted: #94a3b8;
  --sky-wash: rgba(12, 74, 110, 0.4);
  --sky-soft: rgba(14, 116, 144, 0.12);
  --line: #e2e8f0;
  --sheet: #ffffff;
  --danger: #9f1239;
  --ok: #166534;
  --z-map: 1;
  --z-chrome: 20;
  --z-sheet: 40;
  --z-modal: 50;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
.brand {
  font-family: "Libre Baskerville", Georgia, serif;
  font-weight: 700;
  color: var(--ink-strong);
}

a {
  color: #0c4a6e;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.icon {
  width: 1.25rem;
  height: 1.25rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.icon-sm {
  width: 1rem;
  height: 1rem;
}

/* —— Map shell —— */
.map-app {
  position: relative;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  background: linear-gradient(165deg, #f8fafc 0%, #e2e8f0 45%, rgba(12, 74, 110, 0.18) 100%);
}

#map {
  position: absolute;
  inset: 0;
  z-index: var(--z-map);
}

.map-chrome {
  position: absolute;
  z-index: var(--z-chrome);
  pointer-events: none;
}

.map-chrome > * {
  pointer-events: auto;
}

.top-bar {
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.94) 0%, rgba(248, 250, 252, 0.55) 70%, transparent 100%);
}

.brand-block {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand {
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0;
}

.brand-sub {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.top-actions {
  display: flex;
  gap: 0.4rem;
}

.icon-btn,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink-strong);
  border-radius: 0.5rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.875rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.icon-btn {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
}

.btn {
  padding: 0.65rem 1rem;
  font-weight: 600;
}

.btn:hover,
.icon-btn:hover {
  background: #fff;
  border-color: #cbd5e1;
}

.btn-primary {
  background: rgba(12, 74, 110, 0.85);
  border-color: transparent;
  color: #f8fafc;
}

.btn-primary:hover {
  background: rgba(12, 74, 110, 0.95);
}

.btn-ghost {
  background: transparent;
}

.btn-block {
  width: 100%;
}

/* Zoom Leaflet: abajo a la izquierda, fuera del menú y del FAB */
.leaflet-bottom.leaflet-left {
  bottom: calc(5.25rem + var(--safe-bottom));
  left: 0.65rem;
  z-index: calc(var(--z-chrome) + 1);
}

.leaflet-control-zoom a {
  width: 2.25rem !important;
  height: 2.25rem !important;
  line-height: 2.25rem !important;
  color: var(--ink-strong) !important;
  background: rgba(255, 255, 255, 0.94) !important;
  border-color: var(--line) !important;
}

.fab {
  position: absolute;
  right: 1rem;
  bottom: calc(5.5rem + var(--safe-bottom));
  z-index: var(--z-chrome);
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 999px;
  border: none;
  background: rgba(12, 74, 110, 0.88);
  color: #f8fafc;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.fab .icon {
  width: 1.5rem;
  height: 1.5rem;
}

.layer-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-chrome);
  padding: 0.5rem 0.65rem calc(0.65rem + var(--safe-bottom));
  background: linear-gradient(0deg, rgba(248, 250, 252, 0.97) 40%, transparent 100%);
}

.layer-scroll {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.15rem;
  scrollbar-width: none;
}

.layer-scroll::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 252, 0.92);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.chip.active {
  background: rgba(12, 74, 110, 0.4);
  border-color: transparent;
  color: #f8fafc;
}

.chip .icon {
  width: 0.95rem;
  height: 0.95rem;
}

/* —— Sheets / modals —— */
.overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(15, 23, 42, 0.35);
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.overlay.open {
  display: flex;
}

.sheet {
  width: 100%;
  max-width: 32rem;
  max-height: min(88dvh, 40rem);
  overflow: auto;
  background: var(--sheet);
  border-radius: 1rem 1rem 0 0;
  padding: 0.85rem 1rem calc(1.25rem + var(--safe-bottom));
  box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.12);
  animation: sheet-up 0.28s ease;
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
    opacity: 0.6;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.sheet-handle {
  width: 2.5rem;
  height: 0.28rem;
  border-radius: 999px;
  background: #cbd5e1;
  margin: 0.15rem auto 0.85rem;
}

.sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.sheet-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.sheet-header p {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 0.75rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-strong);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.65rem 0.75rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink-strong);
  background: #fff;
}

textarea {
  min-height: 6.5rem;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(12, 74, 110, 0.25);
  border-color: #7dd3fc;
}

.hint {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}

.legal-box {
  background: var(--sky-soft);
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  padding: 0.75rem 0.85rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--ink);
}

.alert {
  border-radius: 0.5rem;
  padding: 0.65rem 0.75rem;
  font-size: 0.85rem;
  display: none;
}

.alert.show {
  display: block;
}

.alert-error {
  background: #fff1f2;
  color: var(--danger);
  border: 1px solid #fecdd3;
}

.alert-ok {
  background: #f0fdf4;
  color: var(--ok);
  border: 1px solid #bbf7d0;
}

.alert-warn {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
}

/* Leaflet tweaks */
.leaflet-control-attribution {
  font-size: 0.65rem !important;
  background: rgba(248, 250, 252, 0.8) !important;
}

.leaflet-popup-content-wrapper {
  border-radius: 0.65rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.leaflet-popup-content {
  margin: 0.65rem 0.75rem;
  font-size: 0.85rem;
  color: var(--ink-strong);
}

.marker-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid #f8fafc;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.35);
  background: rgba(12, 74, 110, 0.75);
}

.marker-dot[data-cat="robos"] { background: #881337; }
.marker-dot[data-cat="abuso"] { background: #9a3412; }
.marker-dot[data-cat="arboles"] { background: #3f6212; }
.marker-dot[data-cat="rejas"] { background: #1e3a5f; }
.marker-dot[data-cat="locales"] { background: #713f12; }
.marker-dot[data-cat="animales"] { background: #4c1d95; }

/* —— Content pages —— */
.page {
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 80% 50% at 10% 0%, rgba(12, 74, 110, 0.12), transparent 55%),
    linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

.page-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem;
  max-width: 44rem;
  margin: 0 auto;
}

.page-nav .brand {
  font-size: 1.05rem;
}

.page-main {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0.5rem 1.1rem 3rem;
}

.page-main h1 {
  font-size: clamp(1.6rem, 5vw, 2.1rem);
  margin: 0 0 0.75rem;
  line-height: 1.25;
}

.lead {
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--ink);
  margin: 0 0 1.75rem;
}

.prose-section {
  margin-bottom: 1.75rem;
}

.prose-section h2 {
  font-size: 1.15rem;
  margin: 0 0 0.5rem;
}

.prose-section p {
  margin: 0;
  line-height: 1.55;
  font-size: 0.95rem;
}

.prose-list {
  margin: 0.5rem 0 0;
  padding-left: 1.15rem;
  line-height: 1.55;
  font-size: 0.95rem;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 2rem;
}

/* Admin */
.admin-shell {
  max-width: 56rem;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}

.admin-login,
.admin-panel {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 1.1rem;
}

.password-box {
  margin-bottom: 1rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: #fff;
}

.password-box h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-family: inherit;
}

.admin-map-wrap {
  height: min(55vh, 28rem);
  border-radius: 0.55rem;
  overflow: hidden;
  border: 1px solid var(--line);
  margin: 0.65rem 0;
  position: relative;
  z-index: 1;
}

#adminCoverageMap {
  width: 100%;
  height: 100%;
  background: #e2e8f0;
}

.zone-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.stat {
  background: var(--sky-soft);
  border-radius: 0.5rem;
  padding: 0.7rem;
}

.stat strong {
  display: block;
  font-size: 1.25rem;
  color: var(--ink-strong);
}

.stat span {
  font-size: 0.72rem;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.tab {
  flex: 1;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 0.5rem;
  padding: 0.55rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink);
}

.tab.active {
  background: rgba(12, 74, 110, 0.4);
  color: #f8fafc;
  border-color: transparent;
}

.list {
  display: grid;
  gap: 0.65rem;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  padding: 0.75rem;
  background: #fff;
}

.list-item h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 700;
}

.list-item p {
  margin: 0 0 0.55rem;
  font-size: 0.85rem;
  line-height: 1.4;
}

.list-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.55rem;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.btn-sm {
  padding: 0.4rem 0.65rem;
  font-size: 0.78rem;
}

.btn-danger {
  color: var(--danger);
  border-color: #fecdd3;
  background: #fff1f2;
}

.hidden {
  display: none !important;
}

@media (min-width: 768px) {
  .overlay {
    align-items: center;
    padding: 1rem;
  }

  .sheet {
    border-radius: 0.85rem;
    max-height: 85vh;
  }

  .sheet-handle {
    display: none;
  }

  .fab {
    bottom: 6.5rem;
  }

  .stats-row {
    grid-template-columns: repeat(4, 1fr);
  }

  .layer-dock {
    left: auto;
    right: 1rem;
    bottom: 1rem;
    width: min(18rem, calc(100vw - 2rem));
    padding: 0.75rem;
    border-radius: 0.75rem;
    background: rgba(248, 250, 252, 0.94);
    border: 1px solid var(--line);
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
  }

  .layer-scroll {
    flex-direction: column;
    overflow: visible;
  }

  .chip {
    justify-content: flex-start;
  }
}
