/* ChrisomLab Pins — look & feel inspirado en posadev.org (rosa vibrante, papel crema,
   tipografía pixel/retro y sombras duras "neobrutalist"). Cambia --accent para la marca. */
:root {
  --accent: #ff0a55;
  --accent-dk: #c20842;
  --accent-ink: #fffaf0;
  --accent-soft: rgba(255, 10, 85, 0.12);
  --bg: #fef6e8;
  --surface: #fffaf0;
  --ink: #0a0a0a;
  --muted: #6f6a5c;
  --line: #e3d7ba;
  --danger: #c0392b;
  --ok: #0e5c3a;
  --radius: 12px;
  --radius-sm: 6px;
  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --font: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Pixelify Sans", var(--font);
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --surface: #1c1b18;
    --ink: #fdf3e3;
    --muted: #b6ad99;
    --line: rgba(253, 243, 227, 0.18);
    --ok: #3fae7d;
    --accent-soft: rgba(255, 10, 85, 0.22);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
}

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

button, input { font: inherit; }

/* ---------- Barra superior ---------- */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--ink);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  text-decoration: none;
}

.brand img { width: 26px; height: 26px; }
.brand small { font-weight: 400; color: var(--muted); font-family: var(--font); }

.session { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.session .email { color: var(--muted); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Botones (estilo "retro-btn": borde grueso + sombra dura) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--ink);
  background: linear-gradient(135deg, var(--accent-dk), var(--accent));
  color: var(--accent-ink);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .08s ease, box-shadow .08s ease, opacity .15s ease;
}
.btn:hover:not(:disabled) { transform: translate(3px, 3px); box-shadow: none; }
.btn:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: var(--surface); color: var(--ink); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: var(--danger); box-shadow: 3px 3px 0 var(--danger); }
.btn.danger:hover:not(:disabled) { box-shadow: none; }
.btn.small { padding: 6px 13px; font-size: 12px; }
.btn.block { width: 100%; }

/* ---------- Mapa + panel ---------- */
#map { position: fixed; inset: 0; }

.panel {
  position: fixed;
  z-index: 5;
  top: 72px;
  left: 16px;
  width: min(360px, calc(100vw - 32px));
  padding: 20px;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel h1 { margin: 0 0 6px; font-family: var(--font-display); font-weight: 600; font-size: 19px; line-height: 1.3; }
.panel p { margin: 0 0 14px; color: var(--muted); }
.panel .divider { height: 2px; background: var(--line); margin: 16px 0; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 4px; }
.stat {
  padding: 10px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.stat b { display: block; font-family: var(--font-mono); font-weight: 600; font-size: 19px; line-height: 1.1; }
.stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.current-pin {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 2px dashed var(--line);
  border-radius: var(--radius-sm);
}
.current-pin .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--ink); flex: none; }
.current-pin.empty .dot { background: var(--line); border-color: var(--line); }

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

.msg { font-size: 14px; margin: 10px 0 0; min-height: 1.5em; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--danger); }

@media (max-width: 640px) {
  .panel { top: auto; bottom: 12px; left: 12px; width: calc(100vw - 24px); padding: 16px; }
  .panel h1 { font-size: 16px; }
  .brand small { display: none; }
}

/* ---------- Autocompletado ---------- */
.ac { position: relative; }
.ac label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.ac input, .field input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  outline: none;
}
.ac input:focus, .field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.ac-list {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  max-height: 280px;
  overflow-y: auto;
}
.ac-list[hidden] { display: none; }
.ac-list li { padding: 8px 10px; border-radius: 4px; cursor: pointer; }
.ac-list li small { display: block; color: var(--muted); font-size: 12px; }
.ac-list li[aria-selected="true"], .ac-list li:hover { background: var(--accent-soft); }
.ac-list li.empty { color: var(--muted); cursor: default; background: none; }

/* Controles de zoom debajo de la barra superior */
.maplibregl-ctrl-top-right { top: 56px; }

/* ---------- Popups de MapLibre ---------- */
.maplibregl-popup-content {
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 10px 14px;
  font: 14px/1.4 var(--font);
}
.maplibregl-popup-tip { border-top-color: var(--surface) !important; border-bottom-color: var(--surface) !important; }
.popup b { display: block; font-family: var(--font-display); font-weight: 600; }
.popup span { color: var(--muted); font-size: 13px; }

/* ---------- Páginas de contenido (login, admin) ---------- */
.page { max-width: 1080px; margin: 0 auto; padding: 88px 16px 40px; }

.card {
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-card { max-width: 420px; margin: 8vh auto 0; }
.login-card h1 { margin: 0 0 6px; font-family: var(--font-display); font-weight: 600; font-size: 21px; }
.login-card p { color: var(--muted); margin: 0 0 18px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.notice { padding: 12px 14px; border: 2px solid currentColor; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }
.notice.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.notice.err { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }

/* ---------- Admin ---------- */
.admin-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.admin-head h1 { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 22px; }
.admin-head .stats { margin: 0; min-width: 300px; }
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.toolbar input { flex: 1; padding: 9px 12px; border: 2px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); }

.table-wrap { overflow-x: auto; border: 2px solid var(--ink); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; font-family: var(--font-mono); }
tr:last-child td { border-bottom: none; }
td.actions-cell { white-space: nowrap; text-align: right; }
td.actions-cell .btn { margin-left: 4px; }
.tag { display: inline-block; padding: 2px 9px; border: 1.5px solid var(--danger); border-radius: 999px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.muted { color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; font-size: 14px; color: var(--muted); }
.pager div { display: flex; gap: 6px; }
section + section { margin-top: 32px; }
section h2 { font-family: var(--font-display); font-weight: 600; font-size: 16px; margin: 0 0 10px; }

dialog {
  width: min(440px, calc(100vw - 32px));
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 22px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h3 { margin: 0 0 6px; font-family: var(--font-display); font-weight: 600; }
dialog p { margin: 0 0 14px; color: var(--muted); }
dialog .actions { justify-content: flex-end; }
dialog .actions .btn:first-child { flex: none; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; margin: 4px 0 8px; }
