/* ============================================================
   Neural Frontier — styles/market-map.css
   Mapa de mercado. El panel reutiliza .ag-panel, .ag-head, .ag-title y
   .ag-meta de Análisis para verse igual que el resto de tableros. El color
   de cada recuadro lo pone js/market-map.js (es el dato); aquí solo va la
   estructura. Los huecos entre recuadros dejan ver el fondo de la página.
   ============================================================ */

.mm-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 6px 6px 8px;
  box-sizing: border-box;
}
.mm-panel { flex: 1; }

/* ---------- Cabecera: vista, periodo, leyenda, estado ---------- */
.mm-head {
  flex-wrap: wrap;
  justify-content: flex-start;
  row-gap: 6px;
}
.mm-meta { margin-left: auto; }

.mm-seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.mm-seg button {
  padding: 3px 9px;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--border);
  color: var(--text-secondary);
  font: inherit;
  font-size: 11px;
  font-weight: var(--fw-semibold);
  cursor: pointer;
}
.mm-seg button:last-child { border-right: 0; }
.mm-seg button:hover { color: var(--text-primary); }
.mm-seg button.active {
  color: var(--text-primary);
  background: var(--accent-subtle);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.mm-refresh { padding: 3px 10px; font-size: 11px; }

.mm-legend { display: inline-flex; gap: 1px; }
.mm-legend span {
  min-width: 30px;
  padding: 2px 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
}

/* ---------- Migas: al ver un solo sector ---------- */
.mm-crumb {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
}
.mm-crumb[hidden] { display: none; }
.mm-crumb button {
  padding: 0;
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}

/* ---------- Mapa ---------- */
.mm-body {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--bg-primary);
}
.mm-map { position: absolute; inset: 0; overflow: hidden; }

.mm-ghead {
  position: absolute;
  height: 16px;
  padding: 0 5px;
  box-sizing: border-box;
  font-size: 10px;
  font-weight: var(--fw-bold);
  line-height: 16px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mm-ghead--zoom { cursor: zoom-in; }
.mm-ghead--zoom:hover { color: var(--text-primary); }

.mm-tile {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-sizing: border-box;
  color: #fff;
  line-height: 1.1;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.mm-tile--link { cursor: pointer; }
.mm-tile.hover {
  z-index: 1;
  outline: 2px solid #fff;
  outline-offset: -2px;
  filter: brightness(1.12);
}
.mm-n { font-weight: var(--fw-bold); white-space: nowrap; }
.mm-v { font-family: var(--font-mono); white-space: nowrap; opacity: 0.92; }

/* ---------- Tabla (misma información, ordenada por variación) ---------- */
.mm-table-wrap { position: absolute; inset: 0; overflow: auto; }
.mm-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.mm-table th {
  position: sticky;
  top: 0;
  padding: 6px 10px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  font-weight: var(--fw-bold);
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}
.mm-table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  white-space: nowrap;
}
.mm-table .mm-num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.mm-up   { color: var(--positive) !important; }
.mm-down { color: var(--negative) !important; }
.mm-row-link { cursor: pointer; }
.mm-row-link:hover td { background: var(--accent-subtle); }
.mm-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 2px;
  vertical-align: middle;
}

/* ---------- Carga y error ---------- */
.mm-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  font-size: 12px;
  text-align: center;
  color: var(--text-secondary);
}
.mm-state[hidden] { display: none; }

/* ---------- Tooltip ---------- */
.mm-tip {
  position: absolute;
  z-index: 5;
  min-width: 180px;
  max-width: 260px;
  padding: 8px 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-hover);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
}
.mm-tip[hidden] { display: none; }
.mm-tip-title { font-size: 12px; font-weight: var(--fw-bold); color: var(--text-primary); }
.mm-tip-sub {
  margin-top: 1px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}
.mm-tip-pct {
  margin: 6px 0 4px;
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: var(--fw-bold);
}
.mm-tip-pct span {
  margin-left: 6px;
  font-family: var(--font-family);
  font-size: 10px;
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
}
.mm-tip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 1px 0;
  font-size: 11px;
  color: var(--text-secondary);
}
.mm-tip-row b { font-family: var(--font-mono); font-weight: var(--fw-semibold); color: var(--text-primary); }
.mm-tip-foot { margin-top: 6px; font-size: 10px; line-height: 1.4; color: var(--text-muted); }

/* ---------- Pie: de dónde sale cada cosa ---------- */
.mm-foot {
  margin: 0;
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  line-height: 1.45;
  color: var(--text-secondary);
}

/* ---------- Móvil: la página hace scroll, el mapa tiene alto propio ---------- */
@media (max-width: 768px) {
  .mm-wrap { height: auto; }
  .mm-body { flex: none; height: 70vh; min-height: 380px; }
  .mm-meta { width: 100%; margin-left: 0; }
}
