/* =========================================================
   BJJ Mental Map · estilos
   Tema oscuro con acentos de neón.
   ========================================================= */

:root {
  --bg: #0b0f1a;
  --bg-2: #111827;
  --bg-3: #1a2235;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e5ecf5;
  --muted: #8b97ab;
  --accent: #00f5d4;
  --accent-2: #ff2e88;
  --danger: #ff4d4d;
  --radius: 14px;
  --panel-w: 360px;
  --topbar-h: 56px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
}

* { box-sizing: border-box; }

/* El atributo hidden siempre gana, aunque el elemento tenga display:flex */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Botones ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: #222c44; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent);
  color: #06241f;
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 0 18px rgba(0, 245, 212, 0.35);
}
.btn.primary:hover { background: #4dffe6; }
.btn.danger { color: var(--danger); border-color: rgba(255, 77, 77, 0.35); }
.btn.danger:hover { background: rgba(255, 77, 77, 0.12); }
.btn.ghost { background: transparent; }
.btn.full { width: 100%; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.tool.active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 14px rgba(0, 245, 212, 0.4);
}

/* ---------- Logo ---------- */
.logo { display: flex; align-items: center; gap: 10px; }
.logo h1 { font-size: 22px; margin: 0; }
.logo-text { font-weight: 700; letter-spacing: .3px; }
.logo-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent), 0 0 28px var(--accent-2);
}

/* ---------- Login ---------- */
.login-body {
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(600px 400px at 20% 10%, rgba(0, 245, 212, 0.12), transparent 60%),
    radial-gradient(500px 400px at 85% 90%, rgba(255, 46, 136, 0.14), transparent 60%),
    var(--bg);
  overflow: auto;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.login-card .muted { margin: 8px 0 20px; }
.tabs { display: flex; gap: 6px; margin-bottom: 18px; background: var(--bg); padding: 4px; border-radius: 10px; }
.tab {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  padding: 8px; border-radius: 8px; cursor: pointer;
}
.tab.active { background: var(--bg-3); color: var(--text); }
form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
input[type="text"], input[type="password"], input[type="url"], input[type="email"], select, textarea {
  display: block; width: 100%; margin-top: 6px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; color: var(--text); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 245, 212, 0.15); }
.error { color: var(--danger); font-size: 13px; margin: 0 0 12px; }
.legal-links { text-align: center; font-size: 12px; color: var(--muted); margin: 18px 0 0; }
.legal-links a { color: var(--muted); text-decoration: none; }
.legal-links a:hover { color: var(--text); }
.zona-peligro { border: 1px solid rgba(255, 77, 77, 0.35); border-radius: 12px; padding: 12px; margin-top: 10px; }
.muted { color: var(--muted); font-size: 14px; }

/* Caja de aviso (link de desarrollo, contraseña temporal) */
.temporal { background: rgba(0,245,212,.1); border: 1px solid rgba(0,245,212,.4); color: var(--accent); padding: 10px 12px; border-radius: 10px; margin: 10px 0; font-size: 13px; word-break: break-all; }
.temporal a { color: var(--accent); }

/* Faixas: franja de color para mostrar la graduación */
.faixa { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.faixa-barra { width: 34px; height: 10px; border-radius: 2px; border: 1px solid rgba(255,255,255,.25); position: relative; background: var(--fc, #ddd); }
.faixa-barra::after { content: ""; position: absolute; right: 4px; top: 0; bottom: 0; width: 9px; background: #111; }
.faixa-barra[data-faixa="Preta"]::after { background: #d9534f; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); cursor: pointer; }
.check input { width: auto; margin: 0; }

/* ---------- Barra superior ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: rgba(11, 15, 26, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  z-index: 40;   /* por encima del panel lateral, para que los menús desplegables no queden tapados */
}
.topbar-izq { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; position: relative; }
.selector-mapa { position: relative; min-width: 0; }
.selector-mapa .btn { max-width: 46vw; display: flex; align-items: center; gap: 6px; font-weight: 600; }
.selector-mapa #nombre-mapa { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selector-mapa .caret { color: var(--muted); }
.menu-izq { left: 0; right: auto; }
.menu .separador { height: 1px; background: var(--line); margin: 4px 0; }
.menu button.activo { color: var(--accent); }
.menu button .sub { display: block; font-size: 11px; color: var(--muted); }
.estado { font-size: 12px; color: var(--muted); }
.estado.guardando { color: #ffe600; }
.estado.error { color: var(--danger); }
.menu {
  position: absolute; top: 44px; right: 0;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 6px; min-width: 220px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  display: flex; flex-direction: column; gap: 2px;
}
.menu button {
  text-align: left; background: transparent; border: 0; padding: 10px 12px;
  border-radius: 8px; cursor: pointer; color: var(--text);
}
.menu button:hover { background: var(--bg-3); }

/* ---------- Lienzo ---------- */
.lienzo {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  touch-action: none;           /* nosotros manejamos el gesto, no el navegador */
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.lienzo.arrastrando { cursor: grabbing; }
.lienzo.modo-seleccionar { cursor: crosshair; }
.caja-seleccion { fill: rgba(0, 245, 212, 0.08); stroke: var(--accent); stroke-width: 1; stroke-dasharray: 6 4; pointer-events: none; }
.lienzo.conectando { cursor: crosshair; }

/* Burbujas */
.nodo { cursor: pointer; }
.nodo text {
  fill: #ffffff; font-weight: 600; font-size: 13px; text-anchor: middle;
  pointer-events: none; paint-order: stroke; stroke: rgba(0, 0, 0, 0.45); stroke-width: 3px;
}
.nodo .halo { opacity: .28; }
.nodo.seleccionado .halo { opacity: .55; }
.nodo.seleccionado .borde { stroke-width: 4; }
.nodo.origen-conexion .borde { stroke-dasharray: 6 5; animation: girar 1.2s linear infinite; }
@keyframes girar { to { stroke-dashoffset: -22; } }

/* Filtro por etiqueta: lo que no coincide se atenúa */
.nodo.atenuado { opacity: 0.14; }
.flecha.atenuado { opacity: 0.08; }
.nodo, .flecha { transition: opacity .2s; }

/* Flechas */
.flecha path.linea { fill: none; stroke-width: 2.2; opacity: .9; }
.flecha path.area { fill: none; stroke: transparent; stroke-width: 18; cursor: pointer; }
.flecha .etiqueta-fondo { fill: var(--bg-2); stroke: var(--line); rx: 8; cursor: pointer; }
.flecha .etiqueta { fill: var(--text); font-size: 11.5px; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.flecha.seleccionada path.linea { stroke-width: 4; }
.flecha.seleccionada .etiqueta-fondo { stroke: var(--accent); }

/* ---------- Banda de mapa compartido ---------- */
.banda {
  position: fixed; left: 0; right: 0; top: var(--topbar-h);
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 14px;
  background: rgba(179, 136, 255, 0.12); border-bottom: 1px solid rgba(179, 136, 255, 0.4);
  color: #d9c8ff; font-size: 13px; z-index: 19; backdrop-filter: blur(8px);
}
.banda-acciones { display: flex; gap: 8px; }
.banda a.btn { text-decoration: none; display: inline-block; }

/* ---------- Compartir ---------- */
.link-box {
  display: flex; gap: 6px; align-items: center;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 6px 6px 6px 12px;
}
.link-box code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--accent); }
.ok-msg { color: var(--accent); font-size: 13px; min-height: 18px; margin: 6px 0 0; }

/* ---------- Aviso ---------- */
.aviso {
  position: fixed; left: 50%; top: calc(var(--topbar-h) + 12px); transform: translateX(-50%);
  background: rgba(0, 245, 212, 0.12); border: 1px solid rgba(0, 245, 212, 0.5);
  color: var(--accent); padding: 8px 14px; border-radius: 999px; font-size: 13px;
  z-index: 25; backdrop-filter: blur(8px); white-space: nowrap;
}

/* ---------- Barra de herramientas ---------- */
.toolbar {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; gap: 8px;
  background: rgba(17, 24, 39, 0.9); border: 1px solid var(--line);
  padding: 8px; border-radius: 16px; backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  z-index: 20;
}
.toolbar .btn { white-space: nowrap; }

/* ---------- Panel lateral ---------- */
.panel {
  position: fixed; top: var(--topbar-h); right: 0; bottom: 0;
  width: var(--panel-w); max-width: 100%;
  background: rgba(17, 24, 39, 0.96);
  border-left: 1px solid var(--line);
  backdrop-filter: blur(10px);
  padding: 18px 18px 90px;
  overflow-y: auto;
  z-index: 30;
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.4);
}
.panel-handle { display: none; }
.panel-close {
  position: absolute; top: 10px; right: 12px;
  border: 0; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer;
}
.panel h2 { margin: 4px 0 14px; font-size: 18px; padding-right: 28px; }
.panel h3 { margin: 20px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.panel label { margin-bottom: 10px; }
.panel .fila { display: flex; gap: 8px; align-items: center; }
.panel .fila > * { flex: 1; }
.panel .fila > .btn { flex: 0 0 auto; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer;
  box-shadow: 0 0 10px var(--c);
  background: var(--c);
}
.swatch.active { border-color: #fff; }
.swatch-custom { width: 28px; height: 28px; padding: 0; border: 1px dashed var(--muted); border-radius: 50%; background: transparent; cursor: pointer; }

.lista { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.lista li {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
}
.lista li .texto { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista li a { color: var(--accent); text-decoration: none; }
.lista li a:hover { text-decoration: underline; }
.lista li .sub { color: var(--muted); font-size: 12px; display: block; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 6px;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); }
.chip {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--bg-3); color: var(--muted); margin-left: 6px; vertical-align: middle;
}
.vacio { color: var(--muted); font-size: 13px; padding: 6px 0; }

/* Etiquetas */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 2px;
  background: rgba(0, 245, 212, 0.1); border: 1px solid rgba(0, 245, 212, 0.35);
  border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 12px; color: var(--accent);
}
.tag-chip button { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 2px 4px; border-radius: 999px; }
.tag-chip button:hover { background: rgba(0, 245, 212, 0.15); }
.tag-chip.grande { font-size: 14px; padding: 6px 12px; }
.tag-chip.activo { background: var(--accent); color: #06241f; border-color: transparent; box-shadow: 0 0 14px rgba(0, 245, 212, 0.45); }
.tag-chip .cuenta { opacity: .7; font-size: 11px; margin-left: 4px; }
.radios label { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--text); margin-bottom: 8px; cursor: pointer; }
.radios input { width: auto; margin: 0; }
.form-inline { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.acciones { display: flex; gap: 8px; margin-top: 22px; flex-wrap: wrap; }

/* ---------- Celular ---------- */
@media (max-width: 760px) {
  :root { --panel-w: 100%; }
  .logo-text { display: none; }
  .panel {
    top: auto; left: 0; right: 0; bottom: 0;
    height: 62vh;
    border-left: 0; border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    padding-top: 10px;
  }
  .panel-handle {
    display: block; width: 44px; height: 4px; border-radius: 2px;
    background: var(--muted); margin: 0 auto 10px; opacity: .6;
  }
  .toolbar { bottom: calc(10px + env(safe-area-inset-bottom)); }
  .banda { font-size: 12px; }
  .toolbar { gap: 4px; padding: 6px; max-width: calc(100vw - 16px); flex-wrap: wrap; justify-content: center; }
  .toolbar .btn { padding: 8px 9px; font-size: 13px; }
}
