/* ============================================================
   MAPA DEL DELITO — PARTIDO DE LA COSTA
   ============================================================ */

:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e6e8ec;
  --muted: #9aa3b2;
  --accent: #3b82f6;
  --ok: #2fae66;
  --warn: #e0a13a;
  --danger: #d64545;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

/* ---------------- layout mapa público ---------------- */

.app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
}

header.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

header.bar h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 600;
}

header.bar .spacer { flex: 1; }

.controls {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

#cat-filters { display: flex; gap: 10px; flex-wrap: wrap; }

.mdd-chk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.mdd-chk .dot {
  width: 11px; height: 11px; border-radius: 50%;
  display: inline-block;
}

select, input[type="datetime-local"], textarea {
  background-color: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  line-height: 1.25;
}
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  height: 36px;
  padding: 0 32px 0 12px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5' fill='none' stroke='%239aa3b2' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 12px) center;
  background-size: 12px 12px;
}
select::-ms-expand { display: none; }
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.map-wrap { position: relative; }
#map, #admin-map { position: absolute; inset: 0; }

/* ---------------- panel de lista de reportes ---------------- */

#count { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 2px; }
#count:hover { color: var(--text); }

#list-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 340px;
  max-width: 85vw;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 24px rgba(0,0,0,.35);
  z-index: 1100;   /* por encima de los controles de Leaflet */
  display: flex;
  flex-direction: column;
}
.lp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.lp-head strong { font-size: 14px; }
#lp-close {
  background: transparent; border: 0; color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
}
#lp-list {
  overflow-y: auto;
  padding: 10px 12px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.lp-group {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font: inherit; font-weight: 600; font-size: 13px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 2px;
}
.lp-group::before { content: "▾ "; color: var(--muted); margin-right: 6px; }
.lp-group.collapsed::before { content: "▸ "; }
.lp-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }
.lp-group-n {
  background: var(--line); color: var(--muted);
  font-size: 11px; font-weight: 600;
  padding: 1px 7px; border-radius: 999px;
}
.lp-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
}
.lp-card:hover { border-color: #3a414f; }
.lp-card .lp-addr { font-size: 12.5px; margin: 0 0 2px; color: var(--text); font-weight: 600; }
.lp-card .lp-when { color: var(--muted); font-size: 11.5px; margin: 2px 0 3px; }
.lp-card .lp-desc { font-size: 13px; line-height: 1.4; }
.lp-card .lp-note { color: #7b8494; font-size: 11px; font-style: italic; margin: 6px 0 0; }
.lp-empty { color: var(--muted); font-size: 13px; padding: 10px 4px; }

@media (max-width: 720px) {
  #list-panel {
    width: 100%; max-width: none;
    top: auto; height: 62vh;
    border-left: 0; border-top: 1px solid var(--line);
    border-radius: 14px 14px 0 0;
  }
}
#admin-map { position: relative; height: 320px; border-radius: var(--radius); }

footer.disclaimer {
  padding: 8px 14px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------------- botones ---------------- */

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}
.btn:hover { border-color: #3a414f; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #1a1a1a; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------------- pins ---------------- */

.mdd-pin span {
  display: block;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.5);
}

/* ---------------- popup ---------------- */

.mdd-popup { min-width: 180px; }
.mdd-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.mdd-popup .mdd-addr { margin: 6px 0 2px; color: #111; font-size: 12.5px; font-weight: 600; }
.mdd-popup .mdd-when { margin: 4px 0 2px; color: #444; font-size: 12px; }
.mdd-popup .mdd-desc { margin: 4px 0; color: #111; }
.mdd-popup .mdd-note { margin: 6px 0 0; color: #777; font-size: 11px; font-style: italic; }

/* Leaflet popup en tema claro (el contenido lo pide) */
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #fff; }

/* ---------------- hint de "poné el pin" ---------------- */

#place-hint {
  position: absolute;
  bottom: 18px; left: 50%;
  transform: translateX(-50%);
  z-index: 650;
  background: var(--accent);
  color: #fff;
  padding: 10px 12px 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  max-width: calc(100vw - 24px);
}
#place-hint button {
  background: #fff;
  border: 0;
  color: #1a1a1a;
  font-weight: 600;
  font-size: 14px;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  flex: none;
}
#place-hint button:hover { background: #e9edf5; }
body.placing #map { cursor: crosshair; }

/* ---------------- modales ---------------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow: auto;
  padding: 18px 18px 20px;
}
.modal-box h2 { margin: 0 0 12px; font-size: 17px; }
.modal-box label.field { display: block; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
.modal-box select, .modal-box textarea, .modal-box input[type="datetime-local"] { width: 100%; }
.modal-box textarea { min-height: 90px; resize: vertical; }

.row-between { display: flex; justify-content: space-between; align-items: center; }
.help { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.rules { font-size: 12px; color: var(--warn); margin: 10px 0; }
#f-charcount { font-size: 12px; color: var(--muted); }
#f-coords { font-size: 12px; color: var(--muted); margin: 8px 0; }

.check-line { display: flex; gap: 8px; align-items: flex-start; margin: 12px 0; font-size: 13px; }
.check-line input { margin-top: 3px; }

.hp { position: absolute; left: -9999px; opacity: 0; height: 0; }

#captcha-slot { margin: 12px 0 4px; min-height: 0; }
#captcha-slot:not(:empty) { min-height: 65px; }

.form-actions { display: flex; gap: 8px; margin-top: 14px; }

#form-errors .msg { margin: 6px 0; font-size: 13px; padding: 6px 8px; border-radius: 6px; }
.msg.err { background: rgba(214,69,69,.15); color: #ff9b9b; }
.msg.warn { background: rgba(224,161,58,.15); color: #ffce85; }

.close-x {
  float: right;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

/* ---------------- toast ---------------- */

#toast {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  background: #111;
  border: 1px solid var(--line);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  z-index: 1200;
  font-size: 13px;
}

/* ============================================================
   PANEL DE MODERACIÓN
   ============================================================ */

.admin {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}
.admin h1 { font-size: 18px; }

.login-card {
  max-width: 360px;
  margin: 60px auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.login-card input { width: 100%; margin: 6px 0 12px; }
#login-error { color: #ff9b9b; font-size: 13px; min-height: 18px; }

.panel-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-top .spacer { flex: 1; }
#mode-label { font-size: 12px; color: var(--muted); }

.tabs { display: flex; gap: 6px; margin: 14px 0; }
.tab {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}
.tab.active { color: var(--text); border-color: var(--accent); }

.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 800px) { .panel-grid { grid-template-columns: 1fr; } }

#report-list { display: flex; flex-direction: column; gap: 12px; max-height: 70vh; overflow: auto; }

.rcard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  user-select: none;
}
.rcard-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.rcard-status { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.rcard-status.s-approved { color: var(--ok); }
.rcard-status.s-rejected { color: var(--danger); }
.rcard-desc { margin: 6px 0; }
.rcard-meta { margin: 2px 0; font-size: 12px; color: var(--muted); }
.rcard-meta.mono, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.rcard-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.rcard-actions .btn { padding: 5px 10px; font-size: 13px; }
.btn.armed { outline: 2px solid #fff; outline-offset: 1px; }

.muted { color: var(--muted); }

.backlink { font-size: 13px; }

/* ---------------- herramientas de prueba (panel) ---------------- */

.tools-box {
  margin-top: 18px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.tools-box h3 { margin: 0 0 4px; font-size: 13px; }
.tools-box p { margin: 4px 0 10px; font-size: 12px; color: var(--muted); }
.tools-box .btn { padding: 6px 12px; font-size: 13px; margin-right: 6px; }

/* ============================================================
   BUSCADOR + "MI UBICACIÓN" (sobre el mapa)
   ============================================================ */

#map-tools {
  position: absolute;
  top: 10px;
  left: 52px;               /* al lado del control de zoom */
  right: 10px;
  max-width: 360px;
  z-index: 600;
}
.search-row { display: flex; gap: 6px; }
#addr-search {
  flex: 1;
  background: #fff;
  color: #111;
  border: 1px solid rgba(0,0,0,.25);
  border-radius: 8px;
  padding: 9px 11px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
#btn-geo {
  width: 40px;
  background: #fff;
  color: #333;
  border: 1px solid rgba(0,0,0,.25);
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
#btn-geo.loading { opacity: .5; }
#addr-results {
  list-style: none;
  margin: 4px 0 0;
  padding: 4px;
  background: #fff;
  color: #111;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  max-height: 240px;
  overflow: auto;
}
#addr-results li {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
#addr-results li:hover, #addr-results li.active { background: #eef2f7; }
#addr-results li.empty { color: #777; cursor: default; }

/* punto "estás acá" */
.you-are-here {
  width: 16px; height: 16px;
  background: #2563eb;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(37,99,235,.25);
}

/* pin de dirección buscada */
.search-pin {
  font-size: 24px;
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.4));
}

/* ============================================================
   RESPONSIVE — CELULAR
   ============================================================ */

.hide-narrow { display: inline; }
#filters-toggle { display: none; }

@media (max-width: 720px) {
  header.bar { gap: 8px; padding: 8px 10px; }
  header.bar h1 { font-size: 15px; }
  .hide-narrow { display: none; }

  #filters-toggle { display: inline-block; }

  header.bar { position: relative; z-index: 1100; }

  /* panel de filtros como desplegable */
  #filters-panel {
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    padding: 14px 14px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    z-index: 1101;
    box-shadow: 0 10px 24px rgba(0,0,0,.45);
  }
  #filters-panel:not(.open) { display: none; }

  #cat-filters { flex-direction: column; gap: 14px; }
  .mdd-chk { font-size: 15px; }
  .mdd-chk input { width: 18px; height: 18px; }

  /* buscador ocupa todo el ancho, debajo del header */
  #map-tools { left: 10px; right: 10px; max-width: none; top: 8px; }

  /* controles de Leaflet: por debajo del buscador y de los filtros */
  .leaflet-top.leaflet-left { top: 56px; }
  .leaflet-top, .leaflet-bottom { z-index: 500; }

  .modal { padding: 0; align-items: flex-end; }
  .modal-box {
    max-width: none;
    border-radius: 14px 14px 0 0;
    max-height: 92vh;
  }

  footer.disclaimer { font-size: 11.5px; }
  .foot-links { display: block; margin-top: 4px; }

  /* filtro de período: prolijo, alineado a la derecha */
  #filters-panel .mdd-period { width: 100%; justify-content: space-between; gap: 12px; }
  #filters-panel .mdd-period #date-range { min-width: 170px; }
}

/* ============================================================
   PÁGINAS DE TEXTO (cómo funciona / términos / privacidad)
   ============================================================ */

.doc {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 18px 80px;
}
.doc h1 { font-size: 22px; margin: 0 0 4px; }
.doc h2 { font-size: 17px; margin: 28px 0 8px; }
.doc h3 { font-size: 15px; margin: 18px 0 6px; }
.doc p, .doc li { color: var(--text); }
.doc .lead { color: var(--muted); margin-top: 0; }
.doc ul { padding-left: 20px; }
.doc li { margin: 5px 0; }
.doc .note {
  background: rgba(224,161,58,.12);
  border-left: 3px solid var(--warn);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13.5px;
  color: #ffce85;
  margin: 16px 0;
}
.doc .updated { font-size: 12px; color: var(--muted); }
.doc .back { display: inline-block; margin-bottom: 18px; font-size: 13px; }
.doc .cat-legend { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.doc .cat-legend .row { display: flex; gap: 10px; align-items: baseline; }
.doc .cat-legend .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; position: relative; top: 1px; }
