/* Misma paleta que la app Android (ver Color.kt): violeta como acento único,
   el resto neutro -- para que el mapa y los pines sean lo que llama la
   atención, mismo espíritu que Life360. */
:root {
  --violet: #5B4CF0;
  --violet-container: #E7E3FF;
  --coral: #FF6B5C;
  --green: #2ECC71;
  --surface: #FAFAFC;
  --surface-container: #FFFFFF;
  --ink: #1B1B23;
  --ink-dim: #6B6B78;
  --border: rgba(27, 27, 35, 0.10);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --violet: #7C6FFF;
    --violet-container: #3A2E8F;
    --surface: #121218;
    --surface-container: #1D1D26;
    --ink: #ECECF2;
    --ink-dim: #A7A7B4;
    --border: rgba(236, 236, 242, 0.10);
  }
}
:root[data-theme="dark"] {
  --violet: #7C6FFF;
  --violet-container: #3A2E8F;
  --surface: #121218;
  --surface-container: #1D1D26;
  --ink: #ECECF2;
  --ink-dim: #A7A7B4;
  --border: rgba(236, 236, 242, 0.10);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--surface);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input { font-family: inherit; }

#app { display: flex; flex-direction: column; height: 100dvh; }

.view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.view.active { display: flex; }

/* Fondo animado "red de nodos" (mismo efecto que la home de iotaustral.com.ar,
   ver js/bg-net.js) -- sólo visible detrás de login/signup, BgNet.show()/hide()
   lo prende y apaga desde showView(). El mask-image lo atenúa justo donde va
   la tarjeta para no pelear con el texto, y lo deja más visible en los bordes. */
#bg-net {
  position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0;
  pointer-events: none; display: none;
  -webkit-mask-image: radial-gradient(65% 60% at 50% 42%, rgba(0,0,0,.35), black 75%);
          mask-image: radial-gradient(65% 60% at 50% 42%, rgba(0,0,0,.35), black 75%);
}
@media (prefers-reduced-motion: reduce) { #bg-net { opacity: .5; } }

/* ---------- Login / Signup ---------- */
#view-login, #view-signup {
  align-items: center;
  justify-content: center;
  padding: 28px;
  padding-top: calc(28px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  position: relative;
  z-index: 1;
}
.auth-card { width: 100%; max-width: 360px; }
.auth-logo {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--violet); display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px; font-size: 34px;
}
.auth-title { text-align: center; font-size: 24px; font-weight: 700; margin: 0 0 4px; }
.auth-subtitle { text-align: center; color: var(--ink-dim); margin: 0 0 28px; font-size: 15px; }
.field {
  width: 100%; padding: 14px 16px; margin-bottom: 12px;
  border: 1.5px solid var(--border); border-radius: 14px;
  background: var(--surface-container); color: var(--ink); font-size: 16px;
}
.field:focus { outline: none; border-color: var(--violet); }
.btn {
  width: 100%; padding: 15px; border-radius: 16px; border: none;
  font-size: 16px; font-weight: 700; cursor: pointer;
}
.btn-primary { background: var(--violet); color: #fff; margin-top: 6px; }
.btn-primary:disabled { opacity: .6; }
.btn-outline { background: transparent; color: var(--ink); border: 1.5px solid var(--border); }
.btn-text { background: none; border: none; color: var(--violet); font-weight: 600; font-size: 14px; padding: 10px; width: 100%; cursor: pointer; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--ink-dim); font-size: 13px; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.msg { font-size: 14px; margin: 4px 0 10px; min-height: 18px; }
.msg.err { color: var(--coral); }
.msg.ok { color: var(--green); }

/* ---------- Mapa ---------- */
#view-map { position: relative; }
#gmap { position: absolute; inset: 0; }
.range-bar {
  position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); left: 12px; right: 12px;
  z-index: 500; display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px;
}
.range-chip {
  flex: 0 0 auto; padding: 9px 16px; border-radius: 999px; border: none;
  background: var(--surface-container); color: var(--ink); font-size: 14px; font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,.15); cursor: pointer;
}
.range-chip.active { background: var(--violet); color: #fff; }
.map-card {
  position: absolute; left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  z-index: 500; background: var(--surface-container); border-radius: 20px; padding: 18px;
  box-shadow: 0 4px 20px rgba(0,0,0,.18);
}
.map-card h3 { margin: 0 0 4px; font-size: 17px; }
.map-card .state-line { font-size: 14px; font-weight: 600; margin: 2px 0; }
.map-card .sub-line { font-size: 14px; color: var(--ink-dim); margin: 2px 0; }
/* Pin del mapa tipo gota invertida (calcado de currentPositionIcon en la app
   Android): círculo con la foto arriba + punta abajo marcando la coordenada
   exacta. El overlay de Google Maps (ver AvatarPinOverlay en app.js) ancla
   la punta, no el centro del círculo -- un círculo solo no señala un pixel
   preciso. */
.dema-pin { position: relative; width: 56px; height: 88px; }
.dema-pin-head {
  position: absolute; top: 0; left: 0; width: 56px; height: 56px;
  border-radius: 50%; overflow: hidden; box-sizing: border-box;
  border: 5px solid; background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.dema-pin-head img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dema-pin-tip {
  /* el triángulo de borde CSS sólo "crece" hacia abajo desde `top` la
     altura de border-top -- con 44px+24px el borde inferior quedaba en
     68px, no en los 88px del contenedor/iconAnchor, así que el pin
     flotaba ~20px separado de la coordenada real (reportado en la
     práctica 2026-09-17). 48+40=88, ahora coincide con iconAnchor [28,88]. */
  position: absolute; top: 48px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 40px solid;
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
  display: flex; border-top: 1px solid var(--border); background: var(--surface-container);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 0 8px; background: none; border: none; color: var(--ink-dim);
  font-size: 11px; font-weight: 600; cursor: pointer;
}
.nav-btn.active { color: var(--violet); }
.nav-btn .ic { font-size: 21px; }

/* ---------- Compartir / Facturación / Perfil ---------- */
.page {
  flex: 1; overflow-y: auto; padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top, 0px));
}
.page h2 { margin: 0 0 18px; font-size: 22px; }
.card {
  background: var(--surface-container); border-radius: 18px; padding: 18px;
  margin-bottom: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.06);
}
.card-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.pill { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill-ok { background: rgba(46,204,113,.15); color: var(--green); }
.pill-warn { background: rgba(255,107,92,.15); color: var(--coral); }
.pill-muted { background: var(--border); color: var(--ink-dim); }
.link-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.link-row:last-child { border-bottom: none; }
.link-row .label { flex: 1; min-width: 0; }
.link-row .label b { display: block; font-size: 15px; }
.link-row .label span { display: block; font-size: 12px; color: var(--ink-dim); word-break: break-all; }
.icon-btn { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--ink-dim); padding: 6px; }
.icon-btn.danger { color: var(--coral); }
.theme-row { display: flex; gap: 8px; margin-top: 8px; }
.theme-opt {
  flex: 1; padding: 10px; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--surface-container); color: var(--ink); font-size: 14px; cursor: pointer;
}
.theme-opt.active { border-color: var(--violet); color: var(--violet); font-weight: 700; }

.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .7s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

[hidden] { display: none !important; }
